Commit c45ae2c6 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

mf/samplegrabber: Release current media type on shutdown.

parent 25f8698f
......@@ -655,34 +655,50 @@ static HRESULT WINAPI sample_grabber_stream_type_handler_GetCurrentMediaType(IMF
IMFMediaType **media_type)
{
struct sample_grabber *grabber = impl_from_IMFMediaTypeHandler(iface);
HRESULT hr = S_OK;
TRACE("%p, %p.\n", iface, media_type);
if (!media_type)
return E_POINTER;
EnterCriticalSection(&grabber->cs);
if (grabber->is_shut_down)
return MF_E_STREAMSINK_REMOVED;
{
hr = MF_E_STREAMSINK_REMOVED;
}
else
{
*media_type = grabber->current_media_type;
IMFMediaType_AddRef(*media_type);
}
*media_type = grabber->current_media_type;
IMFMediaType_AddRef(*media_type);
LeaveCriticalSection(&grabber->cs);
return S_OK;
return hr;
}
static HRESULT WINAPI sample_grabber_stream_type_handler_GetMajorType(IMFMediaTypeHandler *iface, GUID *type)
{
struct sample_grabber *grabber = impl_from_IMFMediaTypeHandler(iface);
HRESULT hr;
TRACE("%p, %p.\n", iface, type);
if (!type)
return E_POINTER;
EnterCriticalSection(&grabber->cs);
if (grabber->is_shut_down)
return MF_E_STREAMSINK_REMOVED;
hr = MF_E_STREAMSINK_REMOVED;
else
hr = IMFMediaType_GetMajorType(grabber->current_media_type, type);
return IMFMediaType_GetMajorType(grabber->current_media_type, type);
LeaveCriticalSection(&grabber->cs);
return hr;
}
static const IMFMediaTypeHandlerVtbl sample_grabber_stream_type_handler_vtbl =
......@@ -867,7 +883,8 @@ static ULONG WINAPI sample_grabber_sink_Release(IMFMediaSink *iface)
IMFSampleGrabberSinkCallback_Release(grabber->callback);
if (grabber->callback2)
IMFSampleGrabberSinkCallback2_Release(grabber->callback2);
IMFMediaType_Release(grabber->current_media_type);
if (grabber->current_media_type)
IMFMediaType_Release(grabber->current_media_type);
IMFMediaType_Release(grabber->media_type);
if (grabber->event_queue)
IMFMediaEventQueue_Release(grabber->event_queue);
......@@ -1091,6 +1108,8 @@ static HRESULT WINAPI sample_grabber_sink_Shutdown(IMFMediaSink *iface)
if (SUCCEEDED(hr = IMFSampleGrabberSinkCallback_OnShutdown(sample_grabber_get_callback(grabber))))
{
sample_grabber_set_presentation_clock(grabber, NULL);
IMFMediaType_Release(grabber->current_media_type);
grabber->current_media_type = NULL;
IMFMediaEventQueue_Shutdown(grabber->stream_event_queue);
IMFMediaEventQueue_Shutdown(grabber->event_queue);
}
......
......@@ -4697,10 +4697,9 @@ static void test_sample_grabber(void)
ok(hr == S_OK, "Failed to get type count, hr %#lx.\n", hr);
ref = IMFMediaType_Release(media_type2);
todo_wine
ok(ref == 0, "Release returned %ld\n", ref);
ok(!ref, "Unexpected refcount %ld.\n", ref);
ref = IMFMediaType_Release(media_type);
ok(ref == 0, "Release returned %ld\n", ref);
ok(!ref, "Unexpected refcount %ld.\n", ref);
hr = IMFMediaTypeHandler_GetMediaTypeByIndex(handler, 0, &media_type);
ok(hr == MF_E_NO_MORE_TYPES, "Unexpected hr %#lx.\n", hr);
......
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