[PATCH v4 0/2] MR7696: mf: Specify the multithreaded queue for timer callbacks.
This fixes audio dropout in the game Birdcage. I made a test which shows Windows delivering samples from two different threads, which implies a multithreaded queue. The test is probably not suitable for upstream because multithreaded queues respond to load, and a system with sufficient performance may use one thread. -- v4: mf: Specify the multithreaded queue for sample grabber timer callbacks. mf: Specify the multithreaded queue for presentation clock callbacks. https://gitlab.winehq.org/wine/wine/-/merge_requests/7696
From: Conor McCarthy <cmccarthy@codeweavers.com> Callback invocation for timed work occurs in the standard queue. For the session engine, this results in samples being delivered from the same thread which manages the session and executes transforms, which in some cases causes lag and dropped audio. In native Windows, samples may be delivered from at least two different threads. The multithreaded work queue responds to load, and new threads are created only when necessary. --- dlls/mf/clock.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dlls/mf/clock.c b/dlls/mf/clock.c index b13faaf44c9..219ef4384e2 100644 --- a/dlls/mf/clock.c +++ b/dlls/mf/clock.c @@ -1037,7 +1037,9 @@ static ULONG WINAPI present_clock_sink_callback_Release(IMFAsyncCallback *iface) static HRESULT WINAPI present_clock_callback_GetParameters(IMFAsyncCallback *iface, DWORD *flags, DWORD *queue) { - return E_NOTIMPL; + *flags = 0; + *queue = MFASYNC_CALLBACK_QUEUE_MULTITHREADED; + return S_OK; } static HRESULT WINAPI present_clock_sink_callback_Invoke(IMFAsyncCallback *iface, IMFAsyncResult *result) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/7696
From: Conor McCarthy <cmccarthy@codeweavers.com> --- dlls/mf/samplegrabber.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dlls/mf/samplegrabber.c b/dlls/mf/samplegrabber.c index 09ea06f39eb..5f2c28d254b 100644 --- a/dlls/mf/samplegrabber.c +++ b/dlls/mf/samplegrabber.c @@ -729,7 +729,9 @@ static ULONG WINAPI sample_grabber_stream_timer_callback_Release(IMFAsyncCallbac static HRESULT WINAPI sample_grabber_stream_timer_callback_GetParameters(IMFAsyncCallback *iface, DWORD *flags, DWORD *queue) { - return E_NOTIMPL; + *flags = 0; + *queue = MFASYNC_CALLBACK_QUEUE_MULTITHREADED; + return S_OK; } static HRESULT WINAPI sample_grabber_stream_timer_callback_Invoke(IMFAsyncCallback *iface, IMFAsyncResult *result) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/7696
Rebased. These changes now fix audio issues found in the wild, in the game Birdcage. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/7696#note_134675
I made a test which shows Windows delivering samples from two different threads, which implies a multithreaded queue. The test is probably not suitable for upstream because multithreaded queues respond to load, and a system with sufficient performance may use one thread.
Was this test for the sample grabber? For the session documentation implies that it's normal to have a queue "per-branch" whatever that means for transforms with multiple inputs/outputs. We could still enable MT like you did. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/7696#note_134700
This merge request was approved by Nikolay Sivov. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/7696
participants (3)
-
Conor McCarthy -
Conor McCarthy (@cmccarthy) -
Nikolay Sivov (@nsivov)