concat: Make QoS forward MT-safe
authorEdward Hervey <edward@centricular.com>
Thu, 9 Nov 2017 16:38:19 +0000 (17:38 +0100)
committerEdward Hervey <bilboed@bilboed.com>
Thu, 9 Nov 2017 16:41:51 +0000 (17:41 +0100)
In the same way it's done for other event forwarding.

plugins/elements/gstconcat.c

index 4cc134d..1493b38 100644 (file)
@@ -715,16 +715,28 @@ gst_concat_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
       GstClockTimeDiff diff;
       GstClockTime timestamp;
       gdouble proportion;
+      GstPad *sinkpad = NULL;
 
-      gst_event_parse_qos (event, &type, &proportion, &diff, &timestamp);
-      gst_event_unref (event);
+      g_mutex_lock (&self->lock);
+      if ((sinkpad = self->current_sinkpad))
+        gst_object_ref (sinkpad);
+      g_mutex_unlock (&self->lock);
+
+      if (sinkpad) {
+        gst_event_parse_qos (event, &type, &proportion, &diff, &timestamp);
+        gst_event_unref (event);
 
-      if (timestamp != GST_CLOCK_TIME_NONE
-          && timestamp > self->current_start_offset) {
-        timestamp -= self->current_start_offset;
-        event = gst_event_new_qos (type, proportion, diff, timestamp);
-        ret = gst_pad_push_event (self->current_sinkpad, event);
+        if (timestamp != GST_CLOCK_TIME_NONE
+            && timestamp > self->current_start_offset) {
+          timestamp -= self->current_start_offset;
+          event = gst_event_new_qos (type, proportion, diff, timestamp);
+          ret = gst_pad_push_event (self->current_sinkpad, event);
+        } else {
+          ret = FALSE;
+        }
+        gst_object_unref (sinkpad);
       } else {
+        gst_event_unref (event);
         ret = FALSE;
       }
       break;