mfplat: Release queue subscriber on queue release.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2021-04-14 09:49:10 +03:00 committed by Alexandre Julliard
parent e9a29249b8
commit ce37290a5a
2 changed files with 21 additions and 6 deletions

View File

@ -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;
}

View File

@ -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);
}