The IAudioClient implementation from both Windows and winepulse.drv never sets the event more than once per period, which is usually around 10 ms long. Some codecs produce audio samples shorter than 10 ms, which currently result into the SAR not being able to keep up with the audio client, because the SAR never requests more than a sample per event cycle.
This patch causes the event to be set each time a sample is received; this way the queue is immediately processed, and if required a new sample is immediately requested, instead of having to wait for the next IAudioClient period.
Of course it would be even better if the codecs didn't generate too short samples, because they uselessly require more CPU cycles, but we should handle them properly anyway.
This patch fixes audio stuttering problems in the logo videos of Borderlands 3, Deep Rock Galactic and Mutant Year Zero.
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- v2: Remove some changes that didn't really help the solution and update the description accordingly.
dlls/mf/sar.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/dlls/mf/sar.c b/dlls/mf/sar.c index eba822ae0fe..6218eec54bb 100644 --- a/dlls/mf/sar.c +++ b/dlls/mf/sar.c @@ -1360,6 +1360,7 @@ static HRESULT WINAPI audio_renderer_stream_ProcessSample(IMFStreamSink *iface, if (renderer->state == STREAM_STATE_RUNNING) hr = stream_queue_sample(renderer, sample); renderer->flags &= ~SAR_SAMPLE_REQUESTED; + SetEvent(renderer->buffer_ready_event); LeaveCriticalSection(&renderer->cs);
return hr;