[PATCH 5/5] winegstreamer: Use the "flushing" field to unblock the streaming thread when stopping.

Zebediah Figura z.figura12 at gmail.com
Wed Jan 20 18:58:53 CST 2021


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/winegstreamer/gstdemux.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c
index e7a4740b566..58d8e0e2248 100644
--- a/dlls/winegstreamer/gstdemux.c
+++ b/dlls/winegstreamer/gstdemux.c
@@ -1014,14 +1014,14 @@ static DWORD CALLBACK stream_thread(void *arg)
 
     TRACE("Starting streaming thread for pin %p.\n", pin);
 
-    for (;;)
+    while (filter->streaming)
     {
         struct parser_event event;
 
         EnterCriticalSection(&pin->flushing_cs);
         EnterCriticalSection(&filter->cs);
 
-        while (filter->streaming && !filter->flushing && pin->event.type == PARSER_EVENT_NONE)
+        while (!filter->flushing && pin->event.type == PARSER_EVENT_NONE)
             SleepConditionVariableCS(&pin->event_cv, &filter->cs, INFINITE);
 
         if (filter->flushing)
@@ -1032,13 +1032,6 @@ static DWORD CALLBACK stream_thread(void *arg)
             continue;
         }
 
-        if (!filter->streaming)
-        {
-            LeaveCriticalSection(&filter->cs);
-            LeaveCriticalSection(&pin->flushing_cs);
-            break;
-        }
-
         if (!pin->event.type)
         {
             LeaveCriticalSection(&filter->cs);
@@ -1586,8 +1579,9 @@ static HRESULT parser_init_stream(struct strmbase_filter *iface)
     if (!filter->container)
         return S_OK;
 
-    EnterCriticalSection(&filter->cs);
     filter->streaming = true;
+    EnterCriticalSection(&filter->cs);
+    filter->flushing = false;
     LeaveCriticalSection(&filter->cs);
 
     /* DirectShow retains the old seek positions, but resets to them every time
@@ -1625,8 +1619,9 @@ static HRESULT parser_cleanup_stream(struct strmbase_filter *iface)
     if (!filter->container)
         return S_OK;
 
-    EnterCriticalSection(&filter->cs);
     filter->streaming = false;
+    EnterCriticalSection(&filter->cs);
+    filter->flushing = true;
     LeaveCriticalSection(&filter->cs);
 
     for (i = 0; i < filter->source_count; ++i)
@@ -1870,6 +1865,7 @@ static void parser_init_common(struct parser *object)
     object->error_event = CreateEventW(NULL, TRUE, FALSE, NULL);
     InitializeCriticalSection(&object->cs);
     object->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": parser.cs");
+    object->flushing = true;
 }
 
 HRESULT decodebin_parser_create(IUnknown *outer, IUnknown **out)
-- 
2.30.0




More information about the wine-devel mailing list