mf/sar: Allow requesting more than a sample per period.
commitadffa11609093c3c21cf43970bbecda1b2c43eb1
authorGiovanni Mascellani <gmascellani@codeweavers.com>
Mon, 28 Jun 2021 09:06:44 +0000 (28 11:06 +0200)
committerAlexandre Julliard <julliard@winehq.org>
Tue, 6 Jul 2021 15:49:21 +0000 (6 17:49 +0200)
tree8e0801d82eb7532c82fb88cfcca6f4bd42bb123a
parenta9db6c050d6e98924b0cbc7fe08ff8d22ac0051e
mf/sar: Allow requesting more than a sample per period.

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, so it is critical that the SAR is able to process more than
a sample per period.

This is not currently the case: a new sample is requested only in
audio_renderer_render, which is executed (at most) once per period.
This results in the SAR not being able to keep up with the audio
client, and eventually underrunning.

With this patch the SAR keeps a count of how many frames are
currently queued, and a new sample is immediately requested if
the internal queue has less than a buffer worth of frames.

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>
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
dlls/mf/sar.c