mf: Release presentation clock on sample grabber shutdown.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2020-04-22 16:32:14 +03:00 committed by Alexandre Julliard
parent a0035b848e
commit e49c550bdc
2 changed files with 30 additions and 23 deletions

View File

@ -956,17 +956,7 @@ static HRESULT WINAPI sample_grabber_sink_GetStreamSinkById(IMFMediaSink *iface,
return hr;
}
static HRESULT WINAPI sample_grabber_sink_SetPresentationClock(IMFMediaSink *iface, IMFPresentationClock *clock)
{
struct sample_grabber *grabber = impl_from_IMFMediaSink(iface);
HRESULT hr;
TRACE("%p, %p.\n", iface, clock);
EnterCriticalSection(&grabber->cs);
if (SUCCEEDED(hr = IMFSampleGrabberSinkCallback_OnSetPresentationClock(sample_grabber_get_callback(grabber),
clock)))
static void sample_grabber_set_presentation_clock(struct sample_grabber *grabber, IMFPresentationClock *clock)
{
if (grabber->clock)
{
@ -991,6 +981,21 @@ static HRESULT WINAPI sample_grabber_sink_SetPresentationClock(IMFMediaSink *ifa
}
}
static HRESULT WINAPI sample_grabber_sink_SetPresentationClock(IMFMediaSink *iface, IMFPresentationClock *clock)
{
struct sample_grabber *grabber = impl_from_IMFMediaSink(iface);
HRESULT hr;
TRACE("%p, %p.\n", iface, clock);
EnterCriticalSection(&grabber->cs);
if (SUCCEEDED(hr = IMFSampleGrabberSinkCallback_OnSetPresentationClock(sample_grabber_get_callback(grabber),
clock)))
{
sample_grabber_set_presentation_clock(grabber, clock);
}
LeaveCriticalSection(&grabber->cs);
return hr;
@ -1035,6 +1040,7 @@ static HRESULT WINAPI sample_grabber_sink_Shutdown(IMFMediaSink *iface)
grabber->is_shut_down = TRUE;
if (SUCCEEDED(hr = IMFSampleGrabberSinkCallback_OnShutdown(sample_grabber_get_callback(grabber))))
{
sample_grabber_set_presentation_clock(grabber, NULL);
IMFMediaEventQueue_Shutdown(grabber->stream_event_queue);
IMFMediaEventQueue_Shutdown(grabber->event_queue);
}

View File

@ -2102,8 +2102,6 @@ static void test_sample_grabber(void)
ok(hr == S_OK, "Failed to set time source, hr %#x.\n", hr);
IMFPresentationTimeSource_Release(time_source);
IMFPresentationClock_Release(clock);
hr = IMFMediaSink_GetCharacteristics(sink, &flags);
ok(hr == S_OK, "Failed to get sink flags, hr %#x.\n", hr);
@ -2221,8 +2219,10 @@ static void test_sample_grabber(void)
hr = IMFStreamSink_GetEvent(stream, MF_EVENT_FLAG_NO_WAIT, &event);
ok(hr == MF_E_NO_EVENTS_AVAILABLE, "Unexpected hr %#x.\n", hr);
EXPECT_REF(clock, 3);
hr = IMFMediaSink_Shutdown(sink);
ok(hr == S_OK, "Failed to shut down, hr %#x.\n", hr);
EXPECT_REF(clock, 1);
hr = IMFMediaEventGenerator_GetEvent(eg, MF_EVENT_FLAG_NO_WAIT, &event);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
@ -2355,6 +2355,7 @@ static void test_sample_grabber(void)
IMFActivate_Release(activate);
IMFMediaType_Release(media_type);
IMFPresentationClock_Release(clock);
hr = MFShutdown();
ok(hr == S_OK, "Failed to shut down, hr %#x.\n", hr);