Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mf/samplegrabber.c | 6 +++--- dlls/mf/tests/mf.c | 20 +++++++++++++++++++- 2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/dlls/mf/samplegrabber.c b/dlls/mf/samplegrabber.c index f44df9f32b..f4dbe4f283 100644 --- a/dlls/mf/samplegrabber.c +++ b/dlls/mf/samplegrabber.c @@ -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);
diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index da533d05d3..ebab86aab6 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -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);