Zebediah Figura : winegstreamer: Factor out get_stream_event().

Alexandre Julliard julliard at winehq.org
Mon Jan 25 16:42:05 CST 2021


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

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Sat Jan 23 12:43:45 2021 -0600

winegstreamer: Factor out get_stream_event().

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

---

 dlls/winegstreamer/gstdemux.c | 46 ++++++++++++++++++++++++-------------------
 1 file changed, 26 insertions(+), 20 deletions(-)

diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c
index d16a8d28dd4..ea1268ef0dd 100644
--- a/dlls/winegstreamer/gstdemux.c
+++ b/dlls/winegstreamer/gstdemux.c
@@ -1023,6 +1023,31 @@ static void send_buffer(struct parser_source *pin, GstBuffer *buf)
     gst_buffer_unref(buf);
 }
 
+static bool get_stream_event(struct parser_source *pin, struct parser_event *event)
+{
+    struct parser *filter = impl_from_strmbase_filter(pin->pin.pin.filter);
+
+    pthread_mutex_lock(&filter->mutex);
+
+    while (!filter->flushing && pin->event.type == PARSER_EVENT_NONE)
+        pthread_cond_wait(&pin->event_cond, &filter->mutex);
+
+    if (filter->flushing)
+    {
+        pthread_mutex_unlock(&filter->mutex);
+        TRACE("Filter is flushing.\n");
+        return false;
+    }
+
+    *event = pin->event;
+    pin->event.type = PARSER_EVENT_NONE;
+
+    pthread_mutex_unlock(&filter->mutex);
+    pthread_cond_signal(&pin->event_empty_cond);
+
+    return true;
+}
+
 static DWORD CALLBACK stream_thread(void *arg)
 {
     struct parser_source *pin = arg;
@@ -1035,32 +1060,13 @@ static DWORD CALLBACK stream_thread(void *arg)
         struct parser_event event;
 
         EnterCriticalSection(&pin->flushing_cs);
-        pthread_mutex_lock(&filter->mutex);
 
-        while (!filter->flushing && pin->event.type == PARSER_EVENT_NONE)
-            pthread_cond_wait(&pin->event_cond, &filter->mutex);
-
-        if (filter->flushing)
+        if (!get_stream_event(pin, &event))
         {
-            pthread_mutex_unlock(&filter->mutex);
             LeaveCriticalSection(&pin->flushing_cs);
-            TRACE("Filter is flushing.\n");
             continue;
         }
 
-        if (!pin->event.type)
-        {
-            pthread_mutex_unlock(&filter->mutex);
-            LeaveCriticalSection(&pin->flushing_cs);
-            continue;
-        }
-
-        event = pin->event;
-        pin->event.type = PARSER_EVENT_NONE;
-        pthread_cond_signal(&pin->event_empty_cond);
-
-        pthread_mutex_unlock(&filter->mutex);
-
         TRACE("Got event of type %#x.\n", event.type);
 
         switch (event.type)




More information about the wine-cvs mailing list