Finish WinMM Removal#17678
Conversation
|
@seanbudd, per the PR description
As I can see add-ons wanting to enumerate output audio endpoints, should I make |
|
@jcsteh sorry to ping you on this, but you've commented on the WinMM removal project before: are you aware of any other remnants of WinMM that are yet to be removed (excluding the SAPI4 code, which is scheduled for removal next year)? |
|
Nothing else I'm aware of or can spot on a brief look. My only open question is our use of winsound.MessageBeep. That uses MessageBeep in user32.dll, which isn't specifically WinMM, but:
|
|
I think that this is more about removing WinMM usage from NVDA's code, rather than getting rid of WinMM entirely. Surprisingly, MessageBeep doesn't load any DLL at all. From its documentation, I guess that the sound is played by the "SystemSoundService", instead of the process calling MessageBeep. MessageBeep merely "queues the sound". Also, although the SAPI5 synth driver was changed to use WASAPI, it still needs a default wave format as the stream format. The way I'm using is to get the format from the default audio output device of SAPI5, which loads winmm.dll indirectly. Come to think of it, I realized that the default audio output of SAPI5 is not necessarily the audio device chosen by the user, so this logic may apply wave formats across different devices. I'll see what I can do to fix this. |
|
@SaschaCowley - if there is a need for add-ons it's a good idea to do it. Do we think the proposed API is particularly risky or likely to change? |
|
I don't think it's particularly risky, nor do I think it's likely to change, unless we wanted to move |
|
I think creating an API is worthwhile then |
Hmm. It'd really be a lot nicer if we could get the format that the particular speech engine uses natively (or prefers). That's how this works everywhere else: we let Windows resample as needed, rather than making the synth resample. Failing that, I wonder whether we should just always specify 48k 16 bit mono. |
This comment was marked as off-topic.
This comment was marked as off-topic.
It looks like
No idea on that one |
It would need to link against winmm.lib and would thus load winmm.dll. The question is whether it tells the linker to delay load the dll or not. I also don't know how much NV Access cares about winmm.dll just being loaded if it isn't used; I'm just flagging it in case you do. |
|
@gexgd0419, it might be worth it, but as you say, it does carry some risk. Honestly, I'm inclined to suggest we should just always pass a constant format; e.g. 48k 16 bit mono. The Windows mixer probably runs at 48k on most systems these days except for higher end audio interfaces where it might run higher, though that is anecdotal based on what I've seen; I have no data to reference. |
|
I guess using the audio device's format is better than hard-coded; you resample once (or not at all) instead of potentially twice. I imagine there are WASAPI calls to get that info, but I haven't looked at how they work. But even then, if the default device changes or a device is disconnected, you're now potentially using a different format without knowing and now you're resampling anyway. There are no good answers. :( |
It doesn't look like they do.
Neither do I. @seanbudd, @gerald-hartig? |
|
We don't want to load the DLL. The security risk comes from loading it |
|
In that case, you'll probably want to replace calls to winsound.MessageBeep with (likely indirect) calls to ctypes.windll.user32.MessageBeep. |
|
@seanbudd I could prevent SAPI5 from loading Is loading If so, then I guess that using any system built-in SAPI5 voice would become a security risk, because |
|
@SaschaCowley - could you resolve merge conflicts when you can? |
# Conflicts: # source/nvwave.py # user_docs/en/changes.md
|
@seanbudd done |
See test results for failed build of commit 876001990e |
Link to issue number:
None
Summary of the issue:
There are still some remnants of WinMM left in NVDA, as well as some no-longer used code.
Description of user facing changes
None.
Description of development approach
Removed
nvwave.getOutputDevices,nvwave.OutputDeviceIdToNameandnvwave.outputDeviceNameToId, as these are no longer used internally.Renamed
nvwave.WasapiWavePlayertoWavePlayer, and removed theWavePlayervariable that proxiedWasapiWavePlayer.Removed the underscore prefixes from
utils.mmdevice._AudioOutputDeviceandutils.mmdevice.getOutputDevices.Testing strategy:
Unit and system tests.
Known issues with pull request:
None known.
Code Review Checklist:
@coderabbitai summary