nvda
2b2f347a - WASAPI: Switch back to the preferred device if it becomes available. (#15781)

Commit
2 years ago
WASAPI: Switch back to the preferred device if it becomes available. (#15781) Fixes #15759. Summary of the issue: If the audio output device is set to something other than the default and that device is (or becomes) unavailable (e.g. it is disconnected), NVDA will switch to the default device. However, when that device becomes available again (e.g. it is reconnected), NVDA continues to use the default device instead of switching back to the configured device. Worse, this can't be fixed by opening the audio preferences and pressing OK, since the Settings dialog only looks at the configuration and doesn't realise that the WASAPI code has fallen back to the default device. Description of user facing changes If the audio output device is set to something other than the default and that device becomes available again after being unavailable, NVDA will now switch back to the configured device instead of continuing to use the default device. (#15759) Description of development approach 1. Pass the device name to the WasapiPlayer C++ code instead of the device id. This means that WasapiPlayer is created with the device name of the preferred device, even if that device is unavailable, allowing us to manage that in the C++ code. 2. Removed wasPlay_getDevices and its Python callers, since they are no longer needed. 3. Changed WasapiPlayer::open to detect whether the specified device is unavailable using an error code. If so, it falls back to the default device. We leave the preferred device name alone so we can use it later. 4. If the device is unavailable, WasapiPlayer::feed still falls back to the default device, but again does not clear the device name. 5. In NotificationClient, we now track device state change notifications in the same way we track default device changes. 6. In WasapiPlayer::feed, we now handle device state changes similar to how we handle default device changes. 7. If a device state change occurs, we scan for the preferred device by name. If it is available, we switch back to that.
Author
Parents
Loading