From d3853f10610f1528aac1e1c59ec46f82c34bb615 Mon Sep 17 00:00:00 2001 From: Sascha Cowley <16543535+SaschaCowley@users.noreply.github.com> Date: Mon, 16 Dec 2024 14:29:14 +1100 Subject: [PATCH 1/7] Fix default device detection --- source/nvwave.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/source/nvwave.py b/source/nvwave.py index 67f87f7b984..8380cde326b 100644 --- a/source/nvwave.py +++ b/source/nvwave.py @@ -258,7 +258,7 @@ class WasapiWavePlayer(garbageHandler.TrackedObject): #: Whether there is a pending stream idle check. _isIdleCheckPending: bool = False #: Use the default device, this is the configSpec default value. - DEFAULT_DEVICE_KEY = "default" + DEFAULT_DEVICE_KEY = config.conf.getConfigValidation(("speech", "outputDevice")).default #: The silence output device, None if not initialized. _silenceDevice: typing.Optional[str] = None @@ -303,7 +303,7 @@ def __init__( if audioDucking.isAudioDuckingSupported(): self._audioDucker = audioDucking.AudioDucker() self._purpose = purpose - if self._isDefaultDevice(outputDevice): + if outputDevice == self.DEFAULT_DEVICE_KEY: outputDevice = "" self._player = NVDAHelper.localLib.wasPlay_create( outputDevice, @@ -557,13 +557,6 @@ def _idleCheck(cls): # Schedule another check here in case feed isn't called for a while. cls._scheduleIdleCheck() - @classmethod - def _isDefaultDevice(cls, name): - if name in (WAVE_MAPPER, cls.DEFAULT_DEVICE_KEY): - return True - # Check if this is the WinMM sound mapper device, which means default. - return name == next(_getOutputDevices())[1] - WavePlayer = WasapiWavePlayer fileWavePlayer: Optional[WavePlayer] = None From 90f0cbc7e4918c774ba4412db953611ee61029d0 Mon Sep 17 00:00:00 2001 From: Sascha Cowley <16543535+SaschaCowley@users.noreply.github.com> Date: Mon, 16 Dec 2024 14:36:45 +1100 Subject: [PATCH 2/7] Improve type hints and make DEFAULT_DEVICE_KEY pull directly from config defaults, rather than repeating it --- source/nvwave.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/source/nvwave.py b/source/nvwave.py index 8380cde326b..3ae9e7b6d31 100644 --- a/source/nvwave.py +++ b/source/nvwave.py @@ -80,7 +80,6 @@ class WAVEFORMATEX(Structure): WAVE_FORMAT_PCM = 1 -WAVE_MAPPER = -1 CALLBACK_NULL = 0 # CALLBACK_FUNCTION = 0x30000 @@ -258,7 +257,7 @@ class WasapiWavePlayer(garbageHandler.TrackedObject): #: Whether there is a pending stream idle check. _isIdleCheckPending: bool = False #: Use the default device, this is the configSpec default value. - DEFAULT_DEVICE_KEY = config.conf.getConfigValidation(("speech", "outputDevice")).default + DEFAULT_DEVICE_KEY = typing.cast(str, config.conf.getConfigValidation(("speech", "outputDevice")).default) #: The silence output device, None if not initialized. _silenceDevice: typing.Optional[str] = None @@ -267,7 +266,7 @@ def __init__( channels: int, samplesPerSec: int, bitsPerSample: int, - outputDevice: typing.Union[str, int] = WAVE_MAPPER, + outputDevice: str = DEFAULT_DEVICE_KEY, closeWhenIdle: bool = False, wantDucking: bool = True, buffered: bool = False, From ad90022a51ff6f309849c6a0c549b9fc57c09c55 Mon Sep 17 00:00:00 2001 From: Sascha Cowley <16543535+SaschaCowley@users.noreply.github.com> Date: Mon, 16 Dec 2024 14:43:53 +1100 Subject: [PATCH 3/7] Removed unneeded initialisation parameters --- source/nvwave.py | 7 +------ source/synthDrivers/_espeak.py | 1 - 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/source/nvwave.py b/source/nvwave.py index 3ae9e7b6d31..212200c4635 100644 --- a/source/nvwave.py +++ b/source/nvwave.py @@ -267,20 +267,15 @@ def __init__( samplesPerSec: int, bitsPerSample: int, outputDevice: str = DEFAULT_DEVICE_KEY, - closeWhenIdle: bool = False, wantDucking: bool = True, - buffered: bool = False, purpose: AudioPurpose = AudioPurpose.SPEECH, ): """Constructor. @param channels: The number of channels of audio; e.g. 2 for stereo, 1 for mono. @param samplesPerSec: Samples per second (hz). @param bitsPerSample: The number of bits per sample. - @param outputDevice: The name of the audio output device to use, - WAVE_MAPPER for default. - @param closeWhenIdle: Deprecated; ignored. + @param outputDevice: The name of the audio output device to use, defaults to WasapiWavePlayer.DEFAULT_DEVICE_KEY @param wantDucking: if true then background audio will be ducked on Windows 8 and higher - @param buffered: Whether to buffer small chunks of audio to prevent audio glitches. @param purpose: The purpose of this audio. @note: If C{outputDevice} is a name and no such device exists, the default device will be used. @raise WindowsError: If there was an error opening the audio output device. diff --git a/source/synthDrivers/_espeak.py b/source/synthDrivers/_espeak.py index 297012d5664..1df6ca7dc9f 100755 --- a/source/synthDrivers/_espeak.py +++ b/source/synthDrivers/_espeak.py @@ -383,7 +383,6 @@ def initialize(indexCallback=None): samplesPerSec=sampleRate, bitsPerSample=16, outputDevice=config.conf["speech"]["outputDevice"], - buffered=True, ) onIndexReached = indexCallback espeakDLL.espeak_SetSynthCallback(callback) From 108f073bb01e0ee6c98d7e6af5374fe34d431ea3 Mon Sep 17 00:00:00 2001 From: Sascha Cowley <16543535+SaschaCowley@users.noreply.github.com> Date: Mon, 16 Dec 2024 14:49:16 +1100 Subject: [PATCH 4/7] Removed unneeded symbols --- source/nvwave.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/source/nvwave.py b/source/nvwave.py index 212200c4635..0dc620374ac 100644 --- a/source/nvwave.py +++ b/source/nvwave.py @@ -14,7 +14,6 @@ ) from enum import Enum, auto from ctypes import ( - POINTER, Structure, c_uint, byref, @@ -76,17 +75,8 @@ class WAVEFORMATEX(Structure): ] -LPWAVEFORMATEX = POINTER(WAVEFORMATEX) - - WAVE_FORMAT_PCM = 1 -CALLBACK_NULL = 0 -# CALLBACK_FUNCTION = 0x30000 -CALLBACK_EVENT = 0x50000 -# waveOutProc = CFUNCTYPE(HANDLE, UINT, DWORD, DWORD, DWORD) -# WOM_DONE = 0x3bd - def _isDebugForNvWave(): return config.conf["debugLog"]["nvwave"] From edaa8694166a1ad0d7a747387b97dd70242c1427 Mon Sep 17 00:00:00 2001 From: Sascha Cowley <16543535+SaschaCowley@users.noreply.github.com> Date: Mon, 16 Dec 2024 16:26:45 +1100 Subject: [PATCH 5/7] Updated changes --- user_docs/en/changes.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/user_docs/en/changes.md b/user_docs/en/changes.md index 37ab4b9e3b8..66bfc0fa974 100644 --- a/user_docs/en/changes.md +++ b/user_docs/en/changes.md @@ -142,10 +142,13 @@ As the NVDA update check URL is now configurable directly within NVDA, no replac * The `space` keyword argument for `brailleDisplayDrivers.seikantk.InputGesture` now expects an `int` rather than a `bool`. (#17047, @school510587) * The `[upgrade]` configuration section including `[upgrade][newLaptopKeyboardLayout]` has been removed. (#17191) * Due to the retirement of NVDA's winmm support: - * The following symbols have been removed from `nvwave`: `HWAVEOUT`, `LPHWAVEOUT`, `LPWAVEHDR`, `MAXPNAMELEN`, `MMSYSERR_NOERROR`, `usingWasapiWavePlayer`, `WAVEHDR`, `WAVEOUTCAPS`, `WHDR_DONE`, `WinmmWavePlayer`, and `winmm`. +-# = CFUNCTYPE(HANDLE, UINT, DWORD, DWORD, DWORD) + * The following symbols have been removed from `nvwave`: `CALLBACK_EVENT`, `CALLBACK_FUNCTION`, `CALLBACK_NULL`, `HWAVEOUT`, `LPHWAVEOUT`, `LPWAVEFORMATEX`, `LPWAVEHDR`, `MAXPNAMELEN`, `MMSYSERR_NOERROR`, `usingWasapiWavePlayer`, `WAVEHDR`, `WAVEOUTCAPS`, `waveOutProc`, `WAVE_MAPPER`, `WHDR_DONE`, `WinmmWavePlayer`, and `winmm`. * `gui.settingsDialogs.AdvancedPanelControls.wasapiComboBox` has been removed. * The `WASAPI` key has been removed from the `audio` section of the config spec. * The output from `nvwave.outputDeviceNameToID`, and input to `nvwave.outputDeviceIDToName` are now string identifiers. + * The `outputDevice` parameter to `WasapiWavePlayer.__init__` should now only be passed string arguments. + * The deprecated `closeWhenIdle` and `buffered` parameters to `WasapiWavePlayer.__init__` have been removed. * In `NVDAObjects.window.scintilla.ScintillaTextInfo`, if no text is selected, the `collapse` method is overriden to expand to line if the `end` parameter is set to `True` (#17431, @nvdaes) * The following symbols have been removed with no replacement: `languageHandler.getLanguageCliArgs`, `__main__.quitGroup` and `__main__.installGroup` . (#17486, @CyrilleB79) * Prefix matching on command line flags, e.g. using `--di` for `--disable-addons` is no longer supported. (#11644, @CyrilleB79) From 4912899c15e3cf8d1f5856d4de07f14c79a971de Mon Sep 17 00:00:00 2001 From: Sascha Cowley <16543535+SaschaCowley@users.noreply.github.com> Date: Tue, 17 Dec 2024 16:26:29 +1100 Subject: [PATCH 6/7] Update user_docs/en/changes.md --- user_docs/en/changes.md | 1 - 1 file changed, 1 deletion(-) diff --git a/user_docs/en/changes.md b/user_docs/en/changes.md index 66bfc0fa974..d8874048c6d 100644 --- a/user_docs/en/changes.md +++ b/user_docs/en/changes.md @@ -142,7 +142,6 @@ As the NVDA update check URL is now configurable directly within NVDA, no replac * The `space` keyword argument for `brailleDisplayDrivers.seikantk.InputGesture` now expects an `int` rather than a `bool`. (#17047, @school510587) * The `[upgrade]` configuration section including `[upgrade][newLaptopKeyboardLayout]` has been removed. (#17191) * Due to the retirement of NVDA's winmm support: --# = CFUNCTYPE(HANDLE, UINT, DWORD, DWORD, DWORD) * The following symbols have been removed from `nvwave`: `CALLBACK_EVENT`, `CALLBACK_FUNCTION`, `CALLBACK_NULL`, `HWAVEOUT`, `LPHWAVEOUT`, `LPWAVEFORMATEX`, `LPWAVEHDR`, `MAXPNAMELEN`, `MMSYSERR_NOERROR`, `usingWasapiWavePlayer`, `WAVEHDR`, `WAVEOUTCAPS`, `waveOutProc`, `WAVE_MAPPER`, `WHDR_DONE`, `WinmmWavePlayer`, and `winmm`. * `gui.settingsDialogs.AdvancedPanelControls.wasapiComboBox` has been removed. * The `WASAPI` key has been removed from the `audio` section of the config spec. From ed852efff8d3c318bc1b8cc97621b9f4adc5da6e Mon Sep 17 00:00:00 2001 From: Sascha Cowley <16543535+SaschaCowley@users.noreply.github.com> Date: Tue, 17 Dec 2024 16:31:14 +1100 Subject: [PATCH 7/7] Update user_docs/en/changes.md --- user_docs/en/changes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_docs/en/changes.md b/user_docs/en/changes.md index d8874048c6d..59086a27091 100644 --- a/user_docs/en/changes.md +++ b/user_docs/en/changes.md @@ -141,7 +141,7 @@ As the NVDA update check URL is now configurable directly within NVDA, no replac * `SymphonyDocument.script_toggleTextAttribute` to `SymphonyDocument.script_changeTextFormatting` * The `space` keyword argument for `brailleDisplayDrivers.seikantk.InputGesture` now expects an `int` rather than a `bool`. (#17047, @school510587) * The `[upgrade]` configuration section including `[upgrade][newLaptopKeyboardLayout]` has been removed. (#17191) -* Due to the retirement of NVDA's winmm support: +* Due to the retirement of NVDA's winmm support (#17496, #17532): * The following symbols have been removed from `nvwave`: `CALLBACK_EVENT`, `CALLBACK_FUNCTION`, `CALLBACK_NULL`, `HWAVEOUT`, `LPHWAVEOUT`, `LPWAVEFORMATEX`, `LPWAVEHDR`, `MAXPNAMELEN`, `MMSYSERR_NOERROR`, `usingWasapiWavePlayer`, `WAVEHDR`, `WAVEOUTCAPS`, `waveOutProc`, `WAVE_MAPPER`, `WHDR_DONE`, `WinmmWavePlayer`, and `winmm`. * `gui.settingsDialogs.AdvancedPanelControls.wasapiComboBox` has been removed. * The `WASAPI` key has been removed from the `audio` section of the config spec.