[PATCH v3 2/4] winegstreamer: Don't hold the filter lock from the pad-added or pad-removed callbacks.

Zebediah Figura z.figura12 at gmail.com
Tue Dec 3 10:14:50 CST 2019


These may be called from the streaming thread, so it's not safe to do so.

Nor does it seem necessary. We expect that no streaming thread should ever
call methods on our pad or pin, and as long as we hold the filter lock and
wait for the no-more-pads signal when connecting or starting the stream, we
cannot race with application threads.

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

diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c
index 5fa9d66c93..9eddf78ced 100644
--- a/dlls/winegstreamer/gstdemux.c
+++ b/dlls/winegstreamer/gstdemux.c
@@ -814,13 +814,17 @@ static void removed_decoded_pad(GstElement *bin, GstPad *pad, gpointer user)
 
     TRACE("%p %p %p\n", This, bin, pad);
 
-    EnterCriticalSection(&This->filter.csFilter);
     for (x = 0; x < This->cStreams; ++x) {
         if (This->ppPins[x]->their_src == pad)
             break;
     }
     if (x == This->cStreams)
-        goto out;
+    {
+        char *name = gst_pad_get_name(pad);
+        WARN("No pin matching pad %s found.\n", debugstr_a(name));
+        g_free(name);
+        return;
+    }
 
     pin = This->ppPins[x];
 
@@ -831,9 +835,6 @@ static void removed_decoded_pad(GstElement *bin, GstPad *pad, gpointer user)
 
     gst_object_unref(pin->their_src);
     pin->their_src = NULL;
-out:
-    TRACE("Removed %i/%i\n", x, This->cStreams);
-    LeaveCriticalSection(&This->filter.csFilter);
 }
 
 static void init_new_decoded_pad(GstElement *bin, GstPad *pad, struct gstdemux *This)
@@ -971,7 +972,6 @@ static void existing_new_pad(GstElement *bin, GstPad *pad, gpointer user)
         return;
     }
 
-    EnterCriticalSection(&This->filter.csFilter);
     for (x = 0; x < This->cStreams; ++x) {
         struct gstdemux_source *pin = This->ppPins[x];
         if (!pin->their_src) {
@@ -986,13 +986,11 @@ static void existing_new_pad(GstElement *bin, GstPad *pad, gpointer user)
                 pin->their_src = pad;
                 gst_object_ref(pin->their_src);
                 TRACE("Relinked\n");
-                LeaveCriticalSection(&This->filter.csFilter);
                 return;
             }
         }
     }
     init_new_decoded_pad(bin, pad, This);
-    LeaveCriticalSection(&This->filter.csFilter);
 }
 
 static gboolean query_function(GstPad *pad, GstObject *parent, GstQuery *query)
-- 
2.24.0




More information about the wine-devel mailing list