decodebin: Close a small race posting 100% buffering
authorJan Schmidt <jan@centricular.com>
Fri, 17 Mar 2017 14:10:54 +0000 (01:10 +1100)
committerJan Schmidt <jan@centricular.com>
Fri, 17 Mar 2017 15:03:47 +0000 (02:03 +1100)
When posting 100% buffering due to removing the last
buffering element, we still need to hold the posting
lock as well, to avoid any race with other elements
that might post a buffering message at that exact
moment

gst/playback/gstdecodebin2.c

index 439c3dc..45b0b67 100644 (file)
@@ -5514,6 +5514,7 @@ gst_decode_bin_remove_element (GstBin * bin, GstElement * element)
   GList *iter;
 
   BUFFERING_LOCK (bin);
+  g_mutex_lock (&dbin->buffering_post_lock);
   for (iter = dbin->buffering_status; iter; iter = iter->next) {
     GstMessage *bufstats = iter->data;
 
@@ -5536,6 +5537,7 @@ gst_decode_bin_remove_element (GstBin * bin, GstElement * element)
     gst_element_post_message (GST_ELEMENT_CAST (bin),
         gst_message_new_buffering (GST_OBJECT_CAST (dbin), 100));
   }
+  g_mutex_unlock (&dbin->buffering_post_lock);
 
   return GST_BIN_CLASS (parent_class)->remove_element (bin, element);
 }