Commit 97f949b9 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

mf: Shutdown samplegrabber event queue on sink shutdown.

parent 421e6b2b
......@@ -849,10 +849,7 @@ static ULONG WINAPI sample_grabber_sink_Release(IMFMediaSink *iface)
IMFSampleGrabberSinkCallback2_Release(grabber->callback2);
IMFMediaType_Release(grabber->media_type);
if (grabber->event_queue)
{
IMFMediaEventQueue_Shutdown(grabber->event_queue);
IMFMediaEventQueue_Release(grabber->event_queue);
}
if (grabber->clock)
IMFPresentationClock_Release(grabber->clock);
if (grabber->timer)
......@@ -1045,12 +1042,15 @@ static HRESULT WINAPI sample_grabber_sink_Shutdown(IMFMediaSink *iface)
grabber->is_shut_down = TRUE;
if (SUCCEEDED(hr = IMFSampleGrabberSinkCallback_OnShutdown(sample_grabber_get_callback(grabber))))
{
/* Detach stream. */
IMFMediaSink_Release(&grabber->stream->sink->IMFMediaSink_iface);
EnterCriticalSection(&grabber->stream->cs);
grabber->stream->sink = NULL;
LeaveCriticalSection(&grabber->stream->cs);
IMFStreamSink_Release(&grabber->stream->IMFStreamSink_iface);
grabber->stream = NULL;
IMFMediaEventQueue_Shutdown(grabber->event_queue);
}
LeaveCriticalSection(&grabber->cs);
......
......@@ -1925,6 +1925,7 @@ static void test_sample_grabber(void)
IMFMediaSink *sink, *sink2;
DWORD flags, count, id;
IMFActivate *activate;
IMFMediaEvent *event;
ULONG refcount;
IUnknown *unk;
HRESULT hr;
......@@ -1995,9 +1996,12 @@ static void test_sample_grabber(void)
ok(hr == S_OK, "Failed to get interface, hr %#x.\n", hr);
IMFClockStateSink_Release(clocksink);
/* Event generator. */
hr = IMFMediaSink_QueryInterface(sink, &IID_IMFMediaEventGenerator, (void **)&eg);
ok(hr == S_OK, "Failed to get interface, hr %#x.\n", hr);
IMFMediaEventGenerator_Release(eg);
hr = IMFMediaEventGenerator_GetEvent(eg, MF_EVENT_FLAG_NO_WAIT, &event);
ok(hr == MF_E_NO_EVENTS_AVAILABLE, "Unexpected hr %#x.\n", hr);
hr = IMFMediaSink_QueryInterface(sink, &IID_IMFPresentationTimeSource, (void **)&unk);
ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
......@@ -2130,9 +2134,18 @@ todo_wine
hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, NULL, NULL);
ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
hr = IMFMediaEventGenerator_GetEvent(eg, MF_EVENT_FLAG_NO_WAIT, &event);
ok(hr == MF_E_NO_EVENTS_AVAILABLE, "Unexpected hr %#x.\n", hr);
hr = IMFStreamSink_GetEvent(stream, MF_EVENT_FLAG_NO_WAIT, &event);
ok(hr == MF_E_NO_EVENTS_AVAILABLE, "Unexpected hr %#x.\n", hr);
hr = IMFMediaSink_Shutdown(sink);
ok(hr == S_OK, "Failed to shut down, hr %#x.\n", hr);
hr = IMFMediaEventGenerator_GetEvent(eg, MF_EVENT_FLAG_NO_WAIT, &event);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
hr = IMFMediaSink_Shutdown(sink);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
......@@ -2148,6 +2161,10 @@ todo_wine
hr = IMFMediaSink_GetStreamSinkByIndex(sink, 0, &stream2);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
hr = IMFStreamSink_GetEvent(stream, MF_EVENT_FLAG_NO_WAIT, &event);
todo_wine
ok(hr == MF_E_STREAMSINK_REMOVED, "Unexpected hr %#x.\n", hr);
hr = IMFStreamSink_GetMediaSink(stream, &sink2);
ok(hr == MF_E_STREAMSINK_REMOVED, "Unexpected hr %#x.\n", hr);
......@@ -2195,6 +2212,7 @@ todo_wine
hr = IMFStreamSink_GetMediaTypeHandler(stream, NULL);
ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
IMFMediaEventGenerator_Release(eg);
IMFMediaSink_Release(sink);
IMFStreamSink_Release(stream);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment