gst/playback/gstdecodebin.c: If we can't activate one of the decoders we plugged...
authorTim-Philipp Müller <tim@centricular.net>
Thu, 1 May 2008 19:11:42 +0000 (19:11 +0000)
committerTim-Philipp Müller <tim@centricular.net>
Thu, 1 May 2008 19:11:42 +0000 (19:11 +0000)
Original commit message from CVS:
* gst/playback/gstdecodebin.c: (free_pad_probe_for_element),
(try_to_link_1):
If we can't activate one of the decoders we plugged in (such as,
say, musepackdec) for some reason (it might not support push mode,
for example), remove any pad probes that close_pad_link() might
have set up. This makes sure we later don't try to remove a probe
for a pad that doesn't exist any longer, and avoids nast warnings
and probably other things too.

ChangeLog
gst/playback/gstdecodebin.c

index 336e0a9..7f314b6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2008-05-01  Tim-Philipp Müller  <tim.muller at collabora co uk>
+
+       * gst/playback/gstdecodebin.c: (free_pad_probe_for_element),
+         (try_to_link_1):
+         If we can't activate one of the decoders we plugged in (such as,
+         say, musepackdec) for some reason (it might not support push mode,
+         for example), remove any pad probes that close_pad_link() might
+         have set up. This makes sure we later don't try to remove a probe
+         for a pad that doesn't exist any longer, and avoids nast warnings
+         and probably other things too.
+
 2008-04-30  Tim-Philipp Müller  <tim.muller at collabora co uk>
 
        * gst/typefind/gsttypefindfunctions.c:
index f437987..0fb7123 100644 (file)
@@ -569,6 +569,25 @@ free_pad_probes (GstDecodeBin * decode_bin)
   decode_bin->probes = NULL;
 }
 
+/* used when we need to remove a probe because the decoder we plugged failed
+ * to activate */
+static void
+free_pad_probe_for_element (GstDecodeBin * decode_bin, GstElement * element)
+{
+  GList *l;
+
+  for (l = decode_bin->probes; l != NULL; l = g_list_next (l)) {
+    PadProbeData *data = (PadProbeData *) l->data;
+
+    if (GST_ELEMENT_CAST (GST_PAD_PARENT (data->pad)) == element) {
+      gst_pad_remove_data_probe (data->pad, data->sigid);
+      decode_bin->probes = g_list_delete_link (decode_bin->probes, l);
+      g_free (data);
+      return;
+    }
+  }
+}
+
 static gboolean
 add_fakesink (GstDecodeBin * decode_bin)
 {
@@ -992,6 +1011,8 @@ try_to_link_1 (GstDecodeBin * decode_bin, GstElement * srcelement, GstPad * pad,
                   GST_STATE_PAUSED)) == GST_STATE_CHANGE_FAILURE) {
         GST_WARNING_OBJECT (decode_bin, "Couldn't set %s to PAUSED",
             GST_ELEMENT_NAME (element));
+        /* close_link -> close_pad_link -> might have set up a pad probe */
+        free_pad_probe_for_element (decode_bin, element);
         gst_element_set_state (element, GST_STATE_NULL);
         gst_bin_remove (GST_BIN (decode_bin), element);
         continue;