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:
parent
e9a29249b8
commit
ce37290a5a
|
@ -7019,6 +7019,7 @@ static void event_queue_cleanup(struct event_queue *queue)
|
||||||
|
|
||||||
while ((event = queue_pop_event(queue)))
|
while ((event = queue_pop_event(queue)))
|
||||||
IMFMediaEvent_Release(event);
|
IMFMediaEvent_Release(event);
|
||||||
|
event_queue_clear_subscriber(queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI eventqueue_QueryInterface(IMFMediaEventQueue *iface, REFIID riid, void **out)
|
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)
|
else if (queue->subscriber == (IRtwqAsyncResult *)result)
|
||||||
{
|
{
|
||||||
*event = queue_pop_event(queue);
|
*event = queue_pop_event(queue);
|
||||||
if (queue->subscriber)
|
event_queue_clear_subscriber(queue);
|
||||||
IRtwqAsyncResult_Release(queue->subscriber);
|
|
||||||
queue->subscriber = NULL;
|
|
||||||
queue->notified = FALSE;
|
queue->notified = FALSE;
|
||||||
hr = *event ? S_OK : E_FAIL;
|
hr = *event ? S_OK : E_FAIL;
|
||||||
}
|
}
|
||||||
|
@ -7265,7 +7264,6 @@ static HRESULT WINAPI eventqueue_Shutdown(IMFMediaEventQueue *iface)
|
||||||
if (!queue->is_shut_down)
|
if (!queue->is_shut_down)
|
||||||
{
|
{
|
||||||
event_queue_cleanup(queue);
|
event_queue_cleanup(queue);
|
||||||
event_queue_clear_subscriber(queue);
|
|
||||||
queue->is_shut_down = TRUE;
|
queue->is_shut_down = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -326,6 +326,7 @@ static WCHAR *load_resource(const WCHAR *name)
|
||||||
struct test_callback
|
struct test_callback
|
||||||
{
|
{
|
||||||
IMFAsyncCallback IMFAsyncCallback_iface;
|
IMFAsyncCallback IMFAsyncCallback_iface;
|
||||||
|
LONG refcount;
|
||||||
HANDLE event;
|
HANDLE event;
|
||||||
DWORD param;
|
DWORD param;
|
||||||
IMFMediaEvent *media_event;
|
IMFMediaEvent *media_event;
|
||||||
|
@ -352,12 +353,14 @@ static HRESULT WINAPI testcallback_QueryInterface(IMFAsyncCallback *iface, REFII
|
||||||
|
|
||||||
static ULONG WINAPI testcallback_AddRef(IMFAsyncCallback *iface)
|
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)
|
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)
|
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->IMFAsyncCallback_iface.lpVtbl = &testcallbackvtbl;
|
||||||
callback->event = NULL;
|
callback->event = NULL;
|
||||||
|
callback->refcount = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_MFCreateAsyncResult(void)
|
static void test_MFCreateAsyncResult(void)
|
||||||
|
@ -3114,6 +3118,19 @@ static void test_event_queue(void)
|
||||||
|
|
||||||
IMFMediaEventQueue_Release(queue);
|
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();
|
hr = MFShutdown();
|
||||||
ok(hr == S_OK, "Failed to shut down, hr %#x.\n", hr);
|
ok(hr == S_OK, "Failed to shut down, hr %#x.\n", hr);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue