[PATCH 5/6] quartz/videorenderer: Wait in Receive() while paused.

Zebediah Figura z.figura12 at gmail.com
Thu Nov 21 18:11:26 CST 2019


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/quartz/tests/videorenderer.c | 10 +++++-----
 dlls/quartz/videorenderer.c       | 25 ++++++++++++++++++++++++-
 2 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/dlls/quartz/tests/videorenderer.c b/dlls/quartz/tests/videorenderer.c
index e7c0e15edd..046d94b0b8 100644
--- a/dlls/quartz/tests/videorenderer.c
+++ b/dlls/quartz/tests/videorenderer.c
@@ -744,7 +744,7 @@ static void test_filter_state(IMemInputPin *input, IFilterGraph2 *graph)
     hr = IMediaControl_GetState(control, 1000, &state);
     ok(hr == S_OK, "Got hr %#x.\n", hr);
 
-    todo_wine ok(WaitForSingleObject(thread, 100) == WAIT_TIMEOUT, "Thread should block in Receive().\n");
+    ok(WaitForSingleObject(thread, 100) == WAIT_TIMEOUT, "Thread should block in Receive().\n");
 
     hr = IMediaControl_Stop(control);
     ok(hr == S_OK, "Got hr %#x.\n", hr);
@@ -777,7 +777,7 @@ static void test_filter_state(IMemInputPin *input, IFilterGraph2 *graph)
     hr = IMediaControl_GetState(control, 1000, &state);
     ok(hr == S_OK, "Got hr %#x.\n", hr);
 
-    todo_wine ok(WaitForSingleObject(thread, 100) == WAIT_TIMEOUT, "Thread should block in Receive().\n");
+    ok(WaitForSingleObject(thread, 100) == WAIT_TIMEOUT, "Thread should block in Receive().\n");
 
     hr = IMediaControl_Run(control);
     todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
@@ -803,7 +803,7 @@ static void test_filter_state(IMemInputPin *input, IFilterGraph2 *graph)
     hr = IMediaControl_GetState(control, 1000, &state);
     ok(hr == S_OK, "Got hr %#x.\n", hr);
 
-    todo_wine ok(WaitForSingleObject(thread, 100) == WAIT_TIMEOUT, "Thread should block in Receive().\n");
+    ok(WaitForSingleObject(thread, 100) == WAIT_TIMEOUT, "Thread should block in Receive().\n");
 
     hr = IMediaControl_Run(control);
     todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
@@ -868,7 +868,7 @@ static void test_flushing(IPin *pin, IMemInputPin *input, IFilterGraph2 *graph)
     ok(hr == S_FALSE, "Got hr %#x.\n", hr);
 
     thread = send_frame(input);
-    todo_wine ok(WaitForSingleObject(thread, 100) == WAIT_TIMEOUT, "Thread should block in Receive().\n");
+    ok(WaitForSingleObject(thread, 100) == WAIT_TIMEOUT, "Thread should block in Receive().\n");
 
     hr = IMediaControl_GetState(control, 0, &state);
     ok(hr == S_OK, "Got hr %#x.\n", hr);
@@ -892,7 +892,7 @@ static void test_flushing(IPin *pin, IMemInputPin *input, IFilterGraph2 *graph)
     todo_wine ok(hr == VFW_S_STATE_INTERMEDIATE, "Got hr %#x.\n", hr);
 
     thread = send_frame(input);
-    todo_wine ok(WaitForSingleObject(thread, 100) == WAIT_TIMEOUT, "Thread should block in Receive().\n");
+    ok(WaitForSingleObject(thread, 100) == WAIT_TIMEOUT, "Thread should block in Receive().\n");
 
     hr = IMediaControl_Run(control);
     todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
diff --git a/dlls/quartz/videorenderer.c b/dlls/quartz/videorenderer.c
index db889bb661..bd228277cb 100644
--- a/dlls/quartz/videorenderer.c
+++ b/dlls/quartz/videorenderer.c
@@ -54,6 +54,8 @@ typedef struct VideoRendererImpl
     LONG FullScreenMode;
 
     DWORD saved_style;
+
+    HANDLE run_event;
 } VideoRendererImpl;
 
 static inline VideoRendererImpl *impl_from_BaseWindow(BaseWindow *iface)
@@ -176,6 +178,15 @@ static HRESULT WINAPI VideoRenderer_DoRenderSample(struct strmbase_renderer *ifa
             pbSrcStream, (BITMAPINFO *)bih, DIB_RGB_COLORS, SRCCOPY);
     ReleaseDC(filter->baseControlWindow.baseWindow.hWnd, dc);
 
+    if (filter->renderer.filter.state == State_Paused)
+    {
+        const HANDLE events[2] = {filter->run_event, filter->renderer.flush_event};
+
+        LeaveCriticalSection(&filter->renderer.csRenderLock);
+        WaitForMultipleObjects(2, events, FALSE, INFINITE);
+        EnterCriticalSection(&filter->renderer.csRenderLock);
+    }
+
     return S_OK;
 }
 
@@ -234,7 +245,7 @@ static void video_renderer_destroy(struct strmbase_renderer *iface)
 
     BaseControlWindow_Destroy(&filter->baseControlWindow);
     BaseControlVideo_Destroy(&filter->baseControlVideo);
-
+    CloseHandle(filter->run_event);
     strmbase_renderer_cleanup(&filter->renderer);
     CoTaskMemFree(filter);
 }
@@ -267,6 +278,13 @@ static HRESULT video_renderer_pin_query_interface(struct strmbase_renderer *ifac
     return S_OK;
 }
 
+static void video_renderer_start_stream(struct strmbase_renderer *iface)
+{
+    VideoRendererImpl *filter = impl_from_strmbase_renderer(iface);
+
+    SetEvent(filter->run_event);
+}
+
 static void video_renderer_stop_stream(struct strmbase_renderer *iface)
 {
     VideoRendererImpl *This = impl_from_strmbase_renderer(iface);
@@ -276,6 +294,8 @@ static void video_renderer_stop_stream(struct strmbase_renderer *iface)
     if (This->baseControlWindow.AutoShow)
         /* Black it out */
         RedrawWindow(This->baseControlWindow.baseWindow.hWnd, NULL, NULL, RDW_INVALIDATE|RDW_ERASE);
+
+    ResetEvent(This->run_event);
 }
 
 static void video_renderer_init_stream(struct strmbase_renderer *iface)
@@ -315,6 +335,7 @@ static const struct strmbase_renderer_ops renderer_ops =
     .pfnCheckMediaType = VideoRenderer_CheckMediaType,
     .pfnDoRenderSample = VideoRenderer_DoRenderSample,
     .renderer_init_stream = video_renderer_init_stream,
+    .renderer_start_stream = video_renderer_start_stream,
     .renderer_stop_stream = video_renderer_stop_stream,
     .pfnShouldDrawSampleNow = VideoRenderer_ShouldDrawSampleNow,
     .renderer_destroy = video_renderer_destroy,
@@ -722,6 +743,8 @@ HRESULT VideoRenderer_create(IUnknown *outer, void **out)
     if (FAILED(hr = BaseWindowImpl_PrepareWindow(&pVideoRenderer->baseControlWindow.baseWindow)))
         goto fail;
 
+    pVideoRenderer->run_event = CreateEventW(NULL, TRUE, FALSE, NULL);
+
     *out = &pVideoRenderer->renderer.filter.IUnknown_inner;
     return S_OK;
 
-- 
2.24.0




More information about the wine-devel mailing list