support audio ducking for SAPI5 on Windows 11#13118
Conversation
…audio ducking as SAPI5 does not use winmm on Windows 11. Rather, enable / disable audio ducking with SAPI's own events.
See test results for failed build of commit 73bf543ab4 |
|
I would appreciate if someone could please test this try build on Windows 10 and confirm that SAPI5 still correctly ducks audio: https://ci.appveyor.com/api/buildjobs/rrkpf0o0ek08nt74/artifacts/output%2Fnvda_snapshot_try-i12913-24309%2C7157aba3.exe |
LeonarddeR
left a comment
There was a problem hiding this comment.
Looks good to me code wise.
Is it likely that the dllImportTableHooks functionality in NVDAHelper will be ever used for something else in the future? I assume it was implemented solely for SAPI5?
|
I tested this Try Version with SApi5 of Windows 10 21H2 (x64) build 19044.1387, and it seems that the ducking audio function is good. |
| # Although background audio is ducked in SAPISink.StartStream | ||
| # and unducks in SAPISink.EndStream, | ||
| # those events are asynchronous and therefor enabling audio ducking | ||
| # cannot enforce a delay before the speech stream starts, | ||
| # while audio is being faded down. | ||
| # Therefore, create a temporary AudioDucker object, | ||
| # and enable and disable it directly around the call to speak, | ||
| # So that enabling audio ducking suitably delays the speak call if necessary. | ||
| # Although speak does not block and audio ducking is disabled straight after, | ||
| # Audio will be still ducked for enough time for the subsequent StartStream to keep it enabled. |
There was a problem hiding this comment.
Rather than use a tempAudioDucker, why not give speak the responsibility of enabling audio ducking, and StropStream the responsibility of disabling. Why is StartStream needed?
There was a problem hiding this comment.
When calling speak, it is possible that the synthesizer may not produce any audio, for instance if the text is empty or does not result in any pronounceable symbols. In that case, StartStream and EndStream will never be fired. This would be a very rare situation, but certainly not impossible. Really StartStream and EndStream are the true accurate places for controlling ducking. But because they are fired asynchronously, the enforced blocking when calling AudioDucker.enable (when not already ducked) will not block the start of speech, thus why we also need to do it temporarily around speak, to ensure that speak is delayed enough.
There was a problem hiding this comment.
Does temp audio ducker actually cause the audio to be ducked, or is it only used for timing?
Co-authored-by: Reef Turner <[email protected]>
Co-authored-by: Reef Turner <[email protected]>
feerrenrut
left a comment
There was a problem hiding this comment.
Thanks @michaelDCurran
Link to issue number:
Fixes #12913
Summary of the issue:
NVDA's SAPI5 synthDriver instructed Windows to duck and unduck background audio via hooked winmm waveOut functions. However, on Windows 11, it seems that these functions are no longer used by SAPI5, and therefore audio ducking no longer worked for SAPI5.
Description of how this pull request fixes the issue:
Rather than hooking winmm functions, instead make use of SAPI5's own events, and other SynthDriver methods to eanble and disable ducking.
Specifically:
Testing strategy:
Known issues with pull request:
None known.
Change log entries:
New features
Changes
Bug fixes
For Developers
Code Review Checklist: