decodebin: try harder to always expose pads in the same order
authorTim-Philipp Müller <tim@centricular.net>
Sat, 19 Jan 2013 13:03:03 +0000 (13:03 +0000)
committerTim-Philipp Müller <tim@centricular.net>
Sat, 19 Jan 2013 13:03:03 +0000 (13:03 +0000)
Use stream-id as sort criterion in addition to the media type.

https://bugzilla.gnome.org/show_bug.cgi?id=634407

gst/playback/gstdecodebin2.c

index 815de73..09626b1 100644 (file)
@@ -3471,6 +3471,8 @@ sort_end_pads (GstDecodePad * da, GstDecodePad * db)
   GstCaps *capsa, *capsb;
   GstStructure *sa, *sb;
   const gchar *namea, *nameb;
+  gchar *ida, *idb;
+  gint ret;
 
   capsa = get_pad_caps (GST_PAD_CAST (da));
   capsb = get_pad_caps (GST_PAD_CAST (db));
@@ -3506,7 +3508,17 @@ sort_end_pads (GstDecodePad * da, GstDecodePad * db)
   gst_caps_unref (capsa);
   gst_caps_unref (capsb);
 
-  return va - vb;
+  if (va != vb)
+    return va - vb;
+
+  /* if otherwise the same, sort by stream-id */
+  ida = gst_pad_get_stream_id (GST_PAD_CAST (da));
+  idb = gst_pad_get_stream_id (GST_PAD_CAST (db));
+  ret = (ida) ? ((idb) ? strcmp (ida, idb) : -1) : 1;
+  g_free (ida);
+  g_free (idb);
+
+  return ret;
 }
 
 static GstCaps *