From: Sebastian Dröge Date: Wed, 23 May 2012 14:34:37 +0000 (+0200) Subject: playbin2: Put sinks before the other element factories in the autoplug factory list X-Git-Tag: 1.19.3~511^2~6449 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a67d9b349d1973d730995c52dde4fe0c472d83fa;p=platform%2Fupstream%2Fgstreamer.git playbin2: Put sinks before the other element factories in the autoplug factory list This makes sure that we always prefer sinks that support a format without decoding, independant of its rank. Previously we only sorted by rank. Conflicts: gst/playback/gstplaybin2.c --- diff --git a/gst/playback/gstplaybin2.c b/gst/playback/gstplaybin2.c index d35d29e..a634399 100644 --- a/gst/playback/gstplaybin2.c +++ b/gst/playback/gstplaybin2.c @@ -1247,6 +1247,35 @@ colorbalance_value_changed_cb (GstColorBalance * balance, gst_color_balance_value_changed (GST_COLOR_BALANCE (playbin), channel, value); } +static gint +compare_factories_func (gconstpointer p1, gconstpointer p2) +{ + GstPluginFeature *f1, *f2; + gint diff; + gboolean s1, s2; + + f1 = (GstPluginFeature *) p1; + f2 = (GstPluginFeature *) p2; + + s1 = gst_element_factory_list_is_type (GST_ELEMENT_FACTORY_CAST (f1), + GST_ELEMENT_FACTORY_TYPE_SINK); + s2 = gst_element_factory_list_is_type (GST_ELEMENT_FACTORY_CAST (f2), + GST_ELEMENT_FACTORY_TYPE_SINK); + + if (s1 && !s2) + return -1; + else if (!s1 && s2) + return 1; + + diff = f2->rank - f1->rank; + if (diff != 0) + return diff; + + diff = strcmp (f2->name, f1->name); + + return diff; +} + /* Must be called with elements lock! */ static void gst_play_bin_update_elements_list (GstPlayBin * playbin) @@ -1265,8 +1294,7 @@ gst_play_bin_update_elements_list (GstPlayBin * playbin) gst_element_factory_list_get_elements (GST_ELEMENT_FACTORY_TYPE_AUDIOVIDEO_SINKS, GST_RANK_MARGINAL); playbin->elements = g_list_concat (res, tmp); - playbin->elements = - g_list_sort (playbin->elements, gst_plugin_feature_rank_compare_func); + playbin->elements = g_list_sort (playbin->elements, compare_factories_func); playbin->elements_cookie = cookie; } }