Zebediah Figura : quartz: Implement IMediaControl::StopWhenReady().

Alexandre Julliard julliard at winehq.org
Tue May 19 16:07:48 CDT 2020


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

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Mon May 18 15:57:59 2020 -0500

quartz: Implement IMediaControl::StopWhenReady().

This allows The Bunker to exit cleanly.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/quartz/filtergraph.c       | 56 +++++++++++++++++++++++++++++++++++++++--
 dlls/quartz/tests/filtergraph.c | 20 +++++++++++++++
 2 files changed, 74 insertions(+), 2 deletions(-)

diff --git a/dlls/quartz/filtergraph.c b/dlls/quartz/filtergraph.c
index 2afd128919..6217516db1 100644
--- a/dlls/quartz/filtergraph.c
+++ b/dlls/quartz/filtergraph.c
@@ -2132,11 +2132,63 @@ static HRESULT WINAPI MediaControl_get_RegFilterCollection(IMediaControl *iface,
     return S_OK;
 }
 
+static void CALLBACK wait_pause_cb(TP_CALLBACK_INSTANCE *instance, void *context)
+{
+    IMediaControl *control = context;
+    OAFilterState state;
+    HRESULT hr;
+
+    if ((hr = IMediaControl_GetState(control, INFINITE, &state)) != S_OK)
+        ERR("Failed to get paused state, hr %#x.\n", hr);
+
+    if (FAILED(hr = IMediaControl_Stop(control)))
+        ERR("Failed to stop, hr %#x.\n", hr);
+
+    if ((hr = IMediaControl_GetState(control, INFINITE, &state)) != S_OK)
+        ERR("Failed to get paused state, hr %#x.\n", hr);
+
+    IMediaControl_Release(control);
+}
+
+static void CALLBACK wait_stop_cb(TP_CALLBACK_INSTANCE *instance, void *context)
+{
+    IMediaControl *control = context;
+    OAFilterState state;
+    HRESULT hr;
+
+    if ((hr = IMediaControl_GetState(control, INFINITE, &state)) != S_OK)
+        ERR("Failed to get state, hr %#x.\n", hr);
+
+    IMediaControl_Release(control);
+}
+
 static HRESULT WINAPI MediaControl_StopWhenReady(IMediaControl *iface)
 {
-    IFilterGraphImpl *This = impl_from_IMediaControl(iface);
+    IFilterGraphImpl *graph = impl_from_IMediaControl(iface);
+    HRESULT hr;
+
+    TRACE("graph %p.\n", graph);
+
+    /* Even if we are already stopped, we still pause. */
+    hr = IMediaControl_Pause(iface);
+    if (FAILED(hr))
+        return hr;
+    else if (hr == S_FALSE)
+    {
+        IMediaControl_AddRef(iface);
+        TrySubmitThreadpoolCallback(wait_pause_cb, iface, NULL);
+        return S_FALSE;
+    }
 
-    FIXME("(%p/%p)->(): stub !!!\n", This, iface);
+    hr = IMediaControl_Stop(iface);
+    if (FAILED(hr))
+        return hr;
+    else if (hr == S_FALSE)
+    {
+        IMediaControl_AddRef(iface);
+        TrySubmitThreadpoolCallback(wait_stop_cb, iface, NULL);
+        return S_FALSE;
+    }
 
     return S_OK;
 }
diff --git a/dlls/quartz/tests/filtergraph.c b/dlls/quartz/tests/filtergraph.c
index 9aad189979..e926b109ec 100644
--- a/dlls/quartz/tests/filtergraph.c
+++ b/dlls/quartz/tests/filtergraph.c
@@ -3178,6 +3178,26 @@ static void test_filter_state(void)
     ok(hr == S_OK, "Got hr %#x.\n", hr);
     check_filter_state(graph, State_Stopped);
 
+    hr = IMediaControl_Pause(control);
+    ok(hr == S_OK, "Got hr %#x.\n", hr);
+    check_filter_state(graph, State_Paused);
+
+    hr = IMediaControl_StopWhenReady(control);
+    ok(hr == S_OK, "Got hr %#x.\n", hr);
+    check_filter_state(graph, State_Stopped);
+
+    hr = IMediaControl_Run(control);
+    ok(hr == S_OK, "Got hr %#x.\n", hr);
+    check_filter_state(graph, State_Running);
+
+    hr = IMediaControl_StopWhenReady(control);
+    ok(hr == S_OK, "Got hr %#x.\n", hr);
+    check_filter_state(graph, State_Stopped);
+
+    hr = IMediaControl_StopWhenReady(control);
+    ok(hr == S_OK, "Got hr %#x.\n", hr);
+    check_filter_state(graph, State_Stopped);
+
     IReferenceClock_Release(clock);
     IMediaFilter_Release(filter);
     IMediaControl_Release(control);




More information about the wine-cvs mailing list