Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mf/sar.c | 30 +++++++++++++++++------------- dlls/mf/tests/mf.c | 2 ++ 2 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/dlls/mf/sar.c b/dlls/mf/sar.c index 80cfd94952..ed59075fc2 100644 --- a/dlls/mf/sar.c +++ b/dlls/mf/sar.c @@ -282,6 +282,21 @@ static HRESULT WINAPI audio_renderer_sink_GetStreamSinkById(IMFMediaSink *iface, return hr; }
+static void audio_renderer_set_presentation_clock(struct audio_renderer *renderer, IMFPresentationClock *clock) +{ + if (renderer->clock) + { + IMFPresentationClock_RemoveClockStateSink(renderer->clock, &renderer->IMFClockStateSink_iface); + IMFPresentationClock_Release(renderer->clock); + } + renderer->clock = clock; + if (renderer->clock) + { + IMFPresentationClock_AddRef(renderer->clock); + IMFPresentationClock_AddClockStateSink(renderer->clock, &renderer->IMFClockStateSink_iface); + } +} + static HRESULT WINAPI audio_renderer_sink_SetPresentationClock(IMFMediaSink *iface, IMFPresentationClock *clock) { struct audio_renderer *renderer = impl_from_IMFMediaSink(iface); @@ -294,19 +309,7 @@ static HRESULT WINAPI audio_renderer_sink_SetPresentationClock(IMFMediaSink *ifa if (renderer->is_shut_down) hr = MF_E_SHUTDOWN; else - { - if (renderer->clock) - { - IMFPresentationClock_RemoveClockStateSink(renderer->clock, &renderer->IMFClockStateSink_iface); - IMFPresentationClock_Release(renderer->clock); - } - renderer->clock = clock; - if (renderer->clock) - { - IMFPresentationClock_AddRef(renderer->clock); - IMFPresentationClock_AddClockStateSink(renderer->clock, &renderer->IMFClockStateSink_iface); - } - } + audio_renderer_set_presentation_clock(renderer, clock);
LeaveCriticalSection(&renderer->cs);
@@ -353,6 +356,7 @@ static HRESULT WINAPI audio_renderer_sink_Shutdown(IMFMediaSink *iface) renderer->is_shut_down = TRUE; IMFMediaEventQueue_Shutdown(renderer->event_queue); IMFMediaEventQueue_Shutdown(renderer->stream_event_queue); + audio_renderer_set_presentation_clock(renderer, NULL); LeaveCriticalSection(&renderer->cs);
return S_OK; diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index 511c6a8eb9..b7229b4f71 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -2970,8 +2970,10 @@ todo_wine IUnknown_Release(unk);
/* Shutdown */ + EXPECT_REF(present_clock, 2); hr = IMFMediaSink_Shutdown(sink); ok(hr == S_OK, "Failed to shut down, hr %#x.\n", hr); + EXPECT_REF(present_clock, 1);
hr = IMFMediaSink_Shutdown(sink); ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);