playbin: Keep inputselector around until we release its pads
authorSebastian Dröge <sebastian@centricular.com>
Tue, 18 Feb 2014 14:02:57 +0000 (15:02 +0100)
committerSebastian Dröge <sebastian@centricular.com>
Tue, 18 Feb 2014 14:06:25 +0000 (15:06 +0100)
Otherwise there's an interesting race condition when we destroy
the inputselector (actually it will be destroyed later when its state
change message gets destroyed) and afterwards release its sinkpad.

This is the code path when the last channel is removed from the
input selector.

Gave this warning sometimes, for chained oggs or whenever else
we change decode groups:
GStreamer-CRITICAL **: Padname '':sink_0 does not belong to element inputselector0 when removing

gst/playback/gstplaybin2.c

index 40c0252..f330e53 100644 (file)
@@ -3271,6 +3271,13 @@ pad_removed_cb (GstElement * decodebin, GstPad * pad, GstSourceGroup * group)
   if (!(peer = g_object_get_data (G_OBJECT (pad), "playbin.sinkpad")))
     goto not_linked;
 
+  /* unlink the pad now (can fail, the pad is unlinked before it's removed) */
+  gst_pad_unlink (pad, peer);
+
+  /* get combiner */
+  combiner = GST_ELEMENT_CAST (gst_pad_get_parent (peer));
+  g_assert (combiner != NULL);
+
   if ((combine = g_object_get_data (G_OBJECT (peer), "playbin.combine"))) {
     if (combine->has_tags) {
       gulong notify_tags_handler;
@@ -3315,17 +3322,6 @@ pad_removed_cb (GstElement * decodebin, GstPad * pad, GstSourceGroup * group)
     }
   }
 
-  /* unlink the pad now (can fail, the pad is unlinked before it's removed) */
-  gst_pad_unlink (pad, peer);
-
-  /* get combiner, this can be NULL when the element is removing the pads
-   * because it's being disposed. */
-  combiner = GST_ELEMENT_CAST (gst_pad_get_parent (peer));
-  if (!combiner) {
-    gst_object_unref (peer);
-    goto no_combiner;
-  }
-
   /* release the pad to the combiner, this will make the combiner choose a new
    * pad. */
   gst_element_release_request_pad (combiner, peer);
@@ -3346,11 +3342,6 @@ not_linked:
     GST_DEBUG_OBJECT (playbin, "pad not linked");
     goto exit;
   }
-no_combiner:
-  {
-    GST_DEBUG_OBJECT (playbin, "combiner not found");
-    goto exit;
-  }
 }
 
 /* we get called when all pads are available and we must connect the sinks to