Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mf/session.c | 12 +++++++++--- dlls/mf/tests/mf.c | 4 ++++ 2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/dlls/mf/session.c b/dlls/mf/session.c index 0c7e1fbf01..a2a2ba6fe5 100644 --- a/dlls/mf/session.c +++ b/dlls/mf/session.c @@ -1364,13 +1364,19 @@ static HRESULT WINAPI mfsession_Shutdown(IMFMediaSession *iface) static HRESULT WINAPI mfsession_GetClock(IMFMediaSession *iface, IMFClock **clock) { struct media_session *session = impl_from_IMFMediaSession(iface); + HRESULT hr;
TRACE("%p, %p.\n", iface, clock);
- *clock = (IMFClock *)session->clock; - IMFClock_AddRef(*clock); + EnterCriticalSection(&session->cs); + if (SUCCEEDED(hr = session_is_shut_down(session))) + { + *clock = (IMFClock *)session->clock; + IMFClock_AddRef(*clock); + } + LeaveCriticalSection(&session->cs);
- return S_OK; + return hr; }
static HRESULT WINAPI mfsession_GetSessionCapabilities(IMFMediaSession *iface, DWORD *caps) diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index 8f3a80360f..5f3114da32 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -1100,6 +1100,7 @@ todo_wine
hr = IMFClock_GetProperties(clock, &clock_props); ok(hr == MF_E_CLOCK_NO_TIME_SOURCE, "Unexpected hr %#x.\n", hr); + IMFClock_Release(clock);
IMFRateControl_Release(rate_control); IMFRateSupport_Release(rate_support); @@ -1117,6 +1118,9 @@ todo_wine hr = IMFMediaSession_Close(session); ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
+ hr = IMFMediaSession_GetClock(session, &clock); + ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr); + IMFMediaSession_Release(session);
/* Custom topology loader, GUID is not registered. */