Zebediah Figura : winegstreamer: Move wg_parser flushing to the Unix library.

Alexandre Julliard julliard at winehq.org
Tue Feb 16 16:03:18 CST 2021


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

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Mon Feb 15 17:01:53 2021 -0600

winegstreamer: Move wg_parser flushing to the Unix library.

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

---

 dlls/winegstreamer/gst_private.h |  3 +++
 dlls/winegstreamer/gstdemux.c    | 28 ++++------------------------
 dlls/winegstreamer/wg_parser.c   | 25 +++++++++++++++++++++++++
 3 files changed, 32 insertions(+), 24 deletions(-)

diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h
index 08ff6ee21f0..ee698bdf32f 100644
--- a/dlls/winegstreamer/gst_private.h
+++ b/dlls/winegstreamer/gst_private.h
@@ -215,6 +215,9 @@ struct unix_funcs
     HRESULT (CDECL *wg_parser_connect)(struct wg_parser *parser, uint64_t file_size);
     void (CDECL *wg_parser_disconnect)(struct wg_parser *parser);
 
+    void (CDECL *wg_parser_begin_flush)(struct wg_parser *parser);
+    void (CDECL *wg_parser_end_flush)(struct wg_parser *parser);
+
     uint32_t (CDECL *wg_parser_get_stream_count)(struct wg_parser *parser);
     struct wg_parser_stream *(CDECL *wg_parser_get_stream)(struct wg_parser *parser, uint32_t index);
 
diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c
index d4614ca5a65..63368febc5c 100644
--- a/dlls/winegstreamer/gstdemux.c
+++ b/dlls/winegstreamer/gstdemux.c
@@ -856,9 +856,7 @@ static HRESULT parser_init_stream(struct strmbase_filter *iface)
         return S_OK;
 
     filter->streaming = true;
-    pthread_mutex_lock(&parser->mutex);
-    parser->flushing = false;
-    pthread_mutex_unlock(&parser->mutex);
+    unix_funcs->wg_parser_end_flush(filter->wg_parser);
 
     /* DirectShow retains the old seek positions, but resets to them every time
      * it transitions from stopped -> paused. */
@@ -899,17 +897,7 @@ static HRESULT parser_cleanup_stream(struct strmbase_filter *iface)
         return S_OK;
 
     filter->streaming = false;
-    pthread_mutex_lock(&parser->mutex);
-    parser->flushing = true;
-    pthread_mutex_unlock(&parser->mutex);
-
-    for (i = 0; i < parser->stream_count; ++i)
-    {
-        struct wg_parser_stream *stream = parser->streams[i];
-
-        if (stream->enabled)
-            pthread_cond_signal(&stream->event_cond);
-    }
+    unix_funcs->wg_parser_begin_flush(filter->wg_parser);
 
     for (i = 0; i < filter->source_count; ++i)
     {
@@ -1228,7 +1216,6 @@ static HRESULT WINAPI GST_Seeking_SetPositions(IMediaSeeking *iface,
     struct parser_source *pin = impl_from_IMediaSeeking(iface);
     struct wg_parser_stream *stream = pin->wg_stream;
     struct parser *filter = impl_from_strmbase_filter(pin->pin.pin.filter);
-    struct wg_parser *parser = filter->wg_parser;
     GstSeekFlags flags = 0;
     HRESULT hr = S_OK;
     int i;
@@ -1247,17 +1234,12 @@ static HRESULT WINAPI GST_Seeking_SetPositions(IMediaSeeking *iface,
 
     if (!(current_flags & AM_SEEKING_NoFlush))
     {
-        pthread_mutex_lock(&parser->mutex);
-        parser->flushing = true;
-        pthread_mutex_unlock(&parser->mutex);
+        unix_funcs->wg_parser_begin_flush(filter->wg_parser);
 
         for (i = 0; i < filter->source_count; ++i)
         {
             if (filter->sources[i]->pin.pin.peer)
-            {
-                pthread_cond_signal(&stream->event_cond);
                 IPin_BeginFlush(filter->sources[i]->pin.pin.peer);
-            }
         }
 
         if (filter->reader)
@@ -1296,9 +1278,7 @@ static HRESULT WINAPI GST_Seeking_SetPositions(IMediaSeeking *iface,
 
     if (!(current_flags & AM_SEEKING_NoFlush))
     {
-        pthread_mutex_lock(&parser->mutex);
-        parser->flushing = false;
-        pthread_mutex_unlock(&parser->mutex);
+        unix_funcs->wg_parser_end_flush(filter->wg_parser);
 
         for (i = 0; i < filter->source_count; ++i)
         {
diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c
index b3f8eff43ad..bb1d6188a8b 100644
--- a/dlls/winegstreamer/wg_parser.c
+++ b/dlls/winegstreamer/wg_parser.c
@@ -327,6 +327,28 @@ static struct wg_parser_stream * CDECL wg_parser_get_stream(struct wg_parser *pa
     return parser->streams[index];
 }
 
+static void CDECL wg_parser_begin_flush(struct wg_parser *parser)
+{
+    unsigned int i;
+
+    pthread_mutex_lock(&parser->mutex);
+    parser->flushing = true;
+    pthread_mutex_unlock(&parser->mutex);
+
+    for (i = 0; i < parser->stream_count; ++i)
+    {
+        if (parser->streams[i]->enabled)
+            pthread_cond_signal(&parser->streams[i]->event_cond);
+    }
+}
+
+static void CDECL wg_parser_end_flush(struct wg_parser *parser)
+{
+    pthread_mutex_lock(&parser->mutex);
+    parser->flushing = false;
+    pthread_mutex_unlock(&parser->mutex);
+}
+
 static void CDECL wg_parser_stream_get_preferred_format(struct wg_parser_stream *stream, struct wg_format *format)
 {
     *format = stream->preferred_format;
@@ -1520,6 +1542,9 @@ static const struct unix_funcs funcs =
     wg_parser_connect,
     wg_parser_disconnect,
 
+    wg_parser_begin_flush,
+    wg_parser_end_flush,
+
     wg_parser_get_stream_count,
     wg_parser_get_stream,
 




More information about the wine-cvs mailing list