When setting the volume, don't raise an exception if the audio device doesn't support 2 channels.#16771
Conversation
… doesn't support 2 channels.
|
Hi @jcsteh Thanks |
WalkthroughThe recent changes to Changes
Assessment against linked issues
Tip Early access features: enabledWe are currently testing the following features in early access:
Note:
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
|
Hi @jcsteh @seanbudd The reasons are as follows:
Thanks |
Link to issue number:
Fixes #16770.
Summary of the issue:
WasapiWavePlayer.setVolume assumes that the audio device supports 2 channels. Some devices do not. This causes an exception when trying to set the second channel.
Description of user facing changes
Playing NVDA sounds no longer fails on a mono audio device.
Description of development approach
Catch E_INVALIDARG which is the documented error code for this situation. Alternatively, we could check the number of channels before trying to set, but I don't think there's any benefit to that approach and that would require more C++ code.
I also removed
_wasPlay_errcheck. That was never actually called and was unnecessary because raising an exception for a failure is already handled by setting .restype to HRESULT. Furthermore,_wasPlay_errcheckwas raising WindowsError with the wrong parameters, so it wouldn't have been what we wanted even if it had worked.Testing strategy:
I don't have a device that reproduces this. I changed channel 1 to channel 2 in the code and verified that it doesn't raise an exception.
The original reporter @cary-rowen confirmed that this fixes the problem in #16771 (comment).
Known issues with pull request:
None.
Code Review Checklist:
Summary by CodeRabbit
New Features
Bug Fixes