Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mfplat/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c index 9078702c854..de2b5c6ee51 100644 --- a/dlls/mfplat/main.c +++ b/dlls/mfplat/main.c @@ -7109,7 +7109,7 @@ static void queue_notify_subscriber(struct event_queue *queue) static HRESULT WINAPI eventqueue_BeginGetEvent(IMFMediaEventQueue *iface, IMFAsyncCallback *callback, IUnknown *state) { struct event_queue *queue = impl_from_IMFMediaEventQueue(iface); - MFASYNCRESULT *result_data; + RTWQASYNCRESULT *result_data; HRESULT hr;
TRACE("%p, %p, %p.\n", iface, callback, state); @@ -7121,9 +7121,9 @@ static HRESULT WINAPI eventqueue_BeginGetEvent(IMFMediaEventQueue *iface, IMFAsy
if (queue->is_shut_down) hr = MF_E_SHUTDOWN; - else if ((result_data = (MFASYNCRESULT *)queue->subscriber)) + else if ((result_data = (RTWQASYNCRESULT *)queue->subscriber)) { - if (result_data->pCallback == callback) + if (result_data->pCallback == (IRtwqAsyncCallback *)callback) hr = IRtwqAsyncResult_GetStateNoAddRef(queue->subscriber) == state ? MF_S_MULTIPLE_BEGIN : MF_E_MULTIPLE_BEGIN; else
From: "Rémi Bernon" rbernon@codeweavers.com
Signed-off-by: Rémi Bernon rbernon@codeweavers.com Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mfplat/main.c | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c index de2b5c6ee51..e23c648c823 100644 --- a/dlls/mfplat/main.c +++ b/dlls/mfplat/main.c @@ -7006,6 +7006,13 @@ static IMFMediaEvent *queue_pop_event(struct event_queue *queue) return event; }
+static void event_queue_clear_subscriber(struct event_queue *queue) +{ + if (queue->subscriber) + IRtwqAsyncResult_Release(queue->subscriber); + queue->subscriber = NULL; +} + static void event_queue_cleanup(struct event_queue *queue) { IMFMediaEvent *event; @@ -7258,6 +7265,7 @@ static HRESULT WINAPI eventqueue_Shutdown(IMFMediaEventQueue *iface) if (!queue->is_shut_down) { event_queue_cleanup(queue); + event_queue_clear_subscriber(queue); queue->is_shut_down = TRUE; }
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mfplat/main.c | 6 ++---- dlls/mfplat/tests/mfplat.c | 21 +++++++++++++++++++-- 2 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c index e23c648c823..5a35350f5c5 100644 --- a/dlls/mfplat/main.c +++ b/dlls/mfplat/main.c @@ -7019,6 +7019,7 @@ static void event_queue_cleanup(struct event_queue *queue)
while ((event = queue_pop_event(queue))) IMFMediaEvent_Release(event); + event_queue_clear_subscriber(queue); }
static HRESULT WINAPI eventqueue_QueryInterface(IMFMediaEventQueue *iface, REFIID riid, void **out) @@ -7162,9 +7163,7 @@ static HRESULT WINAPI eventqueue_EndGetEvent(IMFMediaEventQueue *iface, IMFAsync else if (queue->subscriber == (IRtwqAsyncResult *)result) { *event = queue_pop_event(queue); - if (queue->subscriber) - IRtwqAsyncResult_Release(queue->subscriber); - queue->subscriber = NULL; + event_queue_clear_subscriber(queue); queue->notified = FALSE; hr = *event ? S_OK : E_FAIL; } @@ -7265,7 +7264,6 @@ static HRESULT WINAPI eventqueue_Shutdown(IMFMediaEventQueue *iface) if (!queue->is_shut_down) { event_queue_cleanup(queue); - event_queue_clear_subscriber(queue); queue->is_shut_down = TRUE; }
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 603dbbe22ff..fd9a27d599c 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -326,6 +326,7 @@ static WCHAR *load_resource(const WCHAR *name) struct test_callback { IMFAsyncCallback IMFAsyncCallback_iface; + LONG refcount; HANDLE event; DWORD param; IMFMediaEvent *media_event; @@ -352,12 +353,14 @@ static HRESULT WINAPI testcallback_QueryInterface(IMFAsyncCallback *iface, REFII
static ULONG WINAPI testcallback_AddRef(IMFAsyncCallback *iface) { - return 2; + struct test_callback *callback = impl_from_IMFAsyncCallback(iface); + return InterlockedIncrement(&callback->refcount); }
static ULONG WINAPI testcallback_Release(IMFAsyncCallback *iface) { - return 1; + struct test_callback *callback = impl_from_IMFAsyncCallback(iface); + return InterlockedDecrement(&callback->refcount); }
static HRESULT WINAPI testcallback_GetParameters(IMFAsyncCallback *iface, DWORD *flags, DWORD *queue) @@ -2462,6 +2465,7 @@ static void init_test_callback(struct test_callback *callback) { callback->IMFAsyncCallback_iface.lpVtbl = &testcallbackvtbl; callback->event = NULL; + callback->refcount = 1; }
static void test_MFCreateAsyncResult(void) @@ -3114,6 +3118,19 @@ static void test_event_queue(void)
IMFMediaEventQueue_Release(queue);
+ /* Release while subscribed. */ + init_test_callback(&callback); + + hr = MFCreateEventQueue(&queue); + ok(hr == S_OK, "Failed to create event queue, hr %#x.\n", hr); + + hr = IMFMediaEventQueue_BeginGetEvent(queue, &callback.IMFAsyncCallback_iface, NULL); + ok(hr == S_OK, "Failed to Begin*, hr %#x.\n", hr); + EXPECT_REF(&callback.IMFAsyncCallback_iface, 2); + + IMFMediaEventQueue_Release(queue); + EXPECT_REF(&callback.IMFAsyncCallback_iface, 1); + hr = MFShutdown(); ok(hr == S_OK, "Failed to shut down, hr %#x.\n", hr); }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=88690
Your paranoid android.
=== w7u_adm (32 bit report) ===
mfplat: 0a24:mfplat: unhandled exception c0000005 at 6D387D24
=== wvistau64 (64 bit report) ===
mfplat: mfplat.c:3132: Test failed: Unexpected refcount 2, expected 1.
On Wed, 14 Apr 2021, Marvin wrote: [...]
=== wvistau64 (64 bit report) ===
mfplat: mfplat.c:3132: Test failed: Unexpected refcount 2, expected 1.
This has turned into a systematic failure on Vista. The test seems to be expecting a specific refcount value which maybe is a bit too strict.
Could you have a look?
https://test.winehq.org/data/tests/mfplat:mfplat.html
On 4/21/21 7:41 PM, Francois Gouget wrote:
On Wed, 14 Apr 2021, Marvin wrote: [...]
=== wvistau64 (64 bit report) ===
mfplat: mfplat.c:3132: Test failed: Unexpected refcount 2, expected 1.
This has turned into a systematic failure on Vista. The test seems to be expecting a specific refcount value which maybe is a bit too strict.
Could you have a look?
That means Vista leaks it, not something we want to do. I'd rather skip all tests on Vista.