Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove winmm support from NVDA #17496

Merged
merged 28 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e14bd71
Make espeak tests when using WASAPI
SaschaCowley Nov 7, 2024
f49373c
Make WavePlayer point to WasapiWavePlayer, and remove logic for handl…
SaschaCowley Nov 7, 2024
7263f5b
Removed nvwave.WinmmWavePlayer
SaschaCowley Nov 7, 2024
213986b
Merge branch 'master' into i16080
SaschaCowley Dec 9, 2024
c456ca7
Rewrote device enumeration to use mmdevice
SaschaCowley Dec 9, 2024
f60405f
Removed un used methods classes and attributes
SaschaCowley Dec 9, 2024
83869d3
Removed old commented winmm code
SaschaCowley Dec 10, 2024
6f1ac30
Added a default value to the GUI
SaschaCowley Dec 10, 2024
facde51
Removed 'Use WASAPI' setting from settings and UG
SaschaCowley Dec 10, 2024
d63bc78
Added change log entries
SaschaCowley Dec 10, 2024
e3cc972
Removed WASAPI check from settings
SaschaCowley Dec 11, 2024
9c23de9
Removed WASAPI check from soundsplit
SaschaCowley Dec 11, 2024
953e96b
Removed WASAPI check from apps volume
SaschaCowley Dec 11, 2024
75ef9fa
Removed WASAPI check from audio utilities initialisation and termination
SaschaCowley Dec 11, 2024
fe04d48
Removed usingWasapiWavePlayer from nvwave
SaschaCowley Dec 11, 2024
1b394a7
Made changes for developers more complete
SaschaCowley Dec 11, 2024
7a9f8c6
Removed the WASAPI option from config
SaschaCowley Dec 11, 2024
107c907
Removed references to disabling WASAPI from the user guide
SaschaCowley Dec 11, 2024
9f59c03
Merge branch 'master' into i16080
SaschaCowley Dec 11, 2024
3764928
Fixed location of changes entry and removed extranious space
SaschaCowley Dec 11, 2024
57cfeaf
Removed WASAPI disabled message
SaschaCowley Dec 11, 2024
5caee71
Type hints for _getOutputDevices
SaschaCowley Dec 11, 2024
c16618f
Added type hint for getOutputDeviceNames
SaschaCowley Dec 11, 2024
c27839c
Added type hint to deviceIDToName
SaschaCowley Dec 11, 2024
3d5ccfb
Added type hints for outputDeviceNameToID
SaschaCowley Dec 11, 2024
53b8e89
Added type hint for fileWavePlayerThread
SaschaCowley Dec 11, 2024
5afe251
Fixed type hint for _getOutputDevices
SaschaCowley Dec 11, 2024
8f9aa5e
Added note about IDs changing
SaschaCowley Dec 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions source/audio/appsVolume.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,6 @@ def _updateAppsVolumeImpl(
_activeCallback.register()


_WASAPI_DISABLED_MESSAGE: str = _(
# Translators: error message when wasapi is turned off.
"Application volume cannot be controlled by NVDA when WASAPI is disabled. "
"Please enable it in the advanced settings panel.",
)


_VOLUME_ADJUSTMENT_DISABLED_MESSAGE: str = _(
# Translators: error message when applications' volume is disabled
"Application volume control disabled",
Expand Down
38 changes: 17 additions & 21 deletions source/nvwave.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

"""Provides a simple Python interface to playing audio using the Windows multimedia waveOut functions, as well as other useful utilities."""

from collections.abc import Iterator
import threading
import typing
from typing import (
Expand Down Expand Up @@ -99,9 +100,9 @@ class AudioPurpose(Enum):
SOUNDS = auto()


def _getOutputDevices():
"""Generator, returning device ID and device Name in device ID order.
@note: Depending on number of devices being fetched, this may take some time (~3ms)
def _getOutputDevices() -> Iterator[tuple[str, str]]:
SaschaCowley marked this conversation as resolved.
Show resolved Hide resolved
"""Generator, yielding device ID and device Name in device ID order.
..note: Depending on number of devices being fetched, this may take some time (~3ms)
"""
endpointCollection = AudioUtilities.GetDeviceEnumerator().EnumAudioEndpoints(
EDataFlow.eRender.value,
Expand All @@ -116,35 +117,30 @@ def _getOutputDevices():
continue


def getOutputDeviceNames():
def getOutputDeviceNames() -> list[str]:
"""Obtain the names of all audio output devices on the system.
@return: The names of all output devices on the system.
@rtype: [str, ...]
@note: Depending on number of devices being fetched, this may take some time (~3ms)
:return: The names of all output devices on the system.
..note: Depending on number of devices being fetched, this may take some time (~3ms)
"""
return [name for ID, name in _getOutputDevices()]


def outputDeviceIDToName(ID):
def outputDeviceIDToName(ID: str) -> str:
"""Obtain the name of an output device given its device ID.
@param ID: The device ID.
@type ID: int
@return: The device name.
@rtype: str
:param ID: The device ID.
:return: The device name.
"""
device = AudioUtilities.GetDeviceEnumerator().GetDevice(id)
return AudioUtilities.CreateDevice(device).FriendlyName


def outputDeviceNameToID(name: str, useDefaultIfInvalid=False) -> int:
def outputDeviceNameToID(name: str, useDefaultIfInvalid: bool = False) -> str:
SaschaCowley marked this conversation as resolved.
Show resolved Hide resolved
"""Obtain the device ID of an output device given its name.
@param name: The device name.
@param useDefaultIfInvalid: C{True} to use the default device (wave mapper) if there is no such device,
C{False} to raise an exception.
@return: The device ID.
@raise LookupError: If there is no such device and C{useDefaultIfInvalid} is C{False}.
@note: Depending on number of devices, and the position of the device in the list,
this may take some time (~3ms)
:param name: The device name.
:param useDefaultIfInvalid: `True` to use the default device if there is no such device, `False` to raise an exception.
:return: The device ID.
:raise LookupError: If there is no such device and `useDefaultIfInvalid` is `False`.
..note: Depending on number of devices, and the position of the device in the list, this may take some time (~3ms)
"""
for curID, curName in _getOutputDevices():
if curName == name:
Expand Down Expand Up @@ -571,7 +567,7 @@ def _isDefaultDevice(cls, name):

WavePlayer = WasapiWavePlayer
fileWavePlayer: Optional[WavePlayer] = None
fileWavePlayerThread = None
fileWavePlayerThread: threading.Thread | None = None


def initialize():
Expand Down