Zebediah Figura : winegstreamer: Don't hold the filter lock from the pad-added or pad-removed callbacks.

Alexandre Julliard julliard at winehq.org
Tue Dec 3 16:13:11 CST 2019


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

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Tue Dec  3 10:14:50 2019 -0600

winegstreamer: Don't hold the filter lock from the pad-added or pad-removed callbacks.

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>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 41e3a05418..623974642d 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)




More information about the wine-cvs mailing list