Nikolay Sivov : mf: Create presentation clock on session creation.

Alexandre Julliard julliard at winehq.org
Tue May 14 15:43:03 CDT 2019


Module: wine
Branch: master
Commit: 42ba38c14cc1b8f59e8c2f0b36f213f848fac850
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=42ba38c14cc1b8f59e8c2f0b36f213f848fac850

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Tue May 14 16:08:52 2019 +0300

mf: Create presentation clock on session creation.

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/mf/session.c  | 46 +++++++++++++++++++++++++++++++++++++---------
 dlls/mf/tests/mf.c |  5 -----
 2 files changed, 37 insertions(+), 14 deletions(-)

diff --git a/dlls/mf/session.c b/dlls/mf/session.c
index e33a5ce..e92ae40 100644
--- a/dlls/mf/session.c
+++ b/dlls/mf/session.c
@@ -60,6 +60,7 @@ struct media_session
     IMFAsyncCallback commands_callback;
     LONG refcount;
     IMFMediaEventQueue *event_queue;
+    IMFPresentationClock *clock;
     struct list topologies;
     CRITICAL_SECTION cs;
 };
@@ -292,6 +293,8 @@ static ULONG WINAPI mfsession_Release(IMFMediaSession *iface)
         session_clear_topologies(session);
         if (session->event_queue)
             IMFMediaEventQueue_Release(session->event_queue);
+        if (session->clock)
+            IMFPresentationClock_Release(session->clock);
         DeleteCriticalSection(&session->cs);
         heap_free(session);
     }
@@ -419,9 +422,14 @@ static HRESULT WINAPI mfsession_Shutdown(IMFMediaSession *iface)
 
 static HRESULT WINAPI mfsession_GetClock(IMFMediaSession *iface, IMFClock **clock)
 {
-    FIXME("(%p)->(%p)\n", iface, clock);
+    struct media_session *session = impl_from_IMFMediaSession(iface);
 
-    return E_NOTIMPL;
+    TRACE("%p, %p.\n", iface, clock);
+
+    *clock = (IMFClock *)session->clock;
+    IMFClock_AddRef(*clock);
+
+    return S_OK;
 }
 
 static HRESULT WINAPI mfsession_GetSessionCapabilities(IMFMediaSession *iface, DWORD *caps)
@@ -694,17 +702,22 @@ HRESULT WINAPI MFCreateMediaSession(IMFAttributes *config, IMFMediaSession **ses
     object->IMFRateControl_iface.lpVtbl = &session_rate_control_vtbl;
     object->commands_callback.lpVtbl = &session_commands_callback_vtbl;
     object->refcount = 1;
-    if (FAILED(hr = MFCreateEventQueue(&object->event_queue)))
-    {
-        IMFMediaSession_Release(&object->IMFMediaSession_iface);
-        return hr;
-    }
     list_init(&object->topologies);
     InitializeCriticalSection(&object->cs);
 
+    if (FAILED(hr = MFCreateEventQueue(&object->event_queue)))
+        goto failed;
+
+    if (FAILED(hr = MFCreatePresentationClock(&object->clock)))
+        goto failed;
+
     *session = &object->IMFMediaSession_iface;
 
     return S_OK;
+
+failed:
+    IMFMediaSession_Release(&object->IMFMediaSession_iface);
+    return hr;
 }
 
 static HRESULT WINAPI present_clock_QueryInterface(IMFPresentationClock *iface, REFIID riid, void **out)
@@ -818,9 +831,24 @@ static HRESULT WINAPI present_clock_GetState(IMFPresentationClock *iface, DWORD
 
 static HRESULT WINAPI present_clock_GetProperties(IMFPresentationClock *iface, MFCLOCK_PROPERTIES *props)
 {
-    FIXME("%p, %p.\n", iface, props);
+    struct presentation_clock *clock = impl_from_IMFPresentationClock(iface);
+    HRESULT hr;
 
-    return E_NOTIMPL;
+    TRACE("%p, %p.\n", iface, props);
+
+    EnterCriticalSection(&clock->cs);
+
+    if (clock->time_source)
+    {
+        FIXME("%p, %p.\n", iface, props);
+        hr = E_NOTIMPL;
+    }
+    else
+        hr = MF_E_CLOCK_NO_TIME_SOURCE;
+
+    LeaveCriticalSection(&clock->cs);
+
+    return hr;
 }
 
 static HRESULT WINAPI present_clock_SetTimeSource(IMFPresentationClock *iface,
diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c
index b64d3f9..18aa10d 100644
--- a/dlls/mf/tests/mf.c
+++ b/dlls/mf/tests/mf.c
@@ -976,11 +976,8 @@ static void test_media_session(void)
     IUnknown_Release(unk);
 
     hr = IMFMediaSession_GetClock(session, &clock);
-todo_wine
     ok(hr == S_OK, "Failed to get clock, hr %#x.\n", hr);
 
-if (SUCCEEDED(hr))
-{
     hr = IMFClock_QueryInterface(clock, &IID_IMFRateControl, (void **)&rc2);
     ok(hr == S_OK, "Failed to get rate control, hr %#x.\n", hr);
     IMFRateControl_Release(rc2);
@@ -988,7 +985,6 @@ if (SUCCEEDED(hr))
     hr = IMFClock_GetProperties(clock, &clock_props);
     ok(hr == MF_E_CLOCK_NO_TIME_SOURCE, "Unexpected hr %#x.\n", hr);
 
-}
     IMFRateControl_Release(rc);
     IMFRateSupport_Release(rs);
 
@@ -1204,7 +1200,6 @@ todo_wine
     ok(value == 0, "Unexpected value %u.\n", value);
 
     hr = IMFPresentationClock_GetProperties(clock, &props);
-todo_wine
     ok(hr == MF_E_CLOCK_NO_TIME_SOURCE, "Unexpected hr %#x.\n", hr);
 
     hr = IMFPresentationClock_GetState(clock, 0, &state);




More information about the wine-cvs mailing list