From 6a2f017bfa9cb73c6db65eea0b84b1d5b56febb7 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Wed, 8 Oct 2014 08:54:57 +0200 Subject: [PATCH] playbin: Only check sinks which are in >= GST_STATE_READY Otherwise we endup with bogus caps intersection (from the pad template caps and not from what the actual hardware/device supports) https://bugzilla.gnome.org/show_bug.cgi?id=738131 --- gst/playback/gstplaybin2.c | 49 +++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/gst/playback/gstplaybin2.c b/gst/playback/gstplaybin2.c index 031d09060..b69e46bc2 100644 --- a/gst/playback/gstplaybin2.c +++ b/gst/playback/gstplaybin2.c @@ -4325,25 +4325,29 @@ autoplug_continue_cb (GstElement * element, GstPad * pad, GstCaps * caps, GstSourceGroup * group) { gboolean ret = TRUE; - GstElement *sink; GstPad *sinkpad = NULL; + gboolean activated_sink; GST_SOURCE_GROUP_LOCK (group); - if ((sink = group->text_sink)) - sinkpad = gst_element_get_static_pad (sink, "sink"); - if (sinkpad) { - GstCaps *sinkcaps; + if (group->text_sink && + activate_sink (group->playbin, group->text_sink, &activated_sink)) { + sinkpad = gst_element_get_static_pad (group->text_sink, "sink"); + if (sinkpad) { + GstCaps *sinkcaps; - sinkcaps = gst_pad_query_caps (sinkpad, NULL); - if (!gst_caps_is_any (sinkcaps)) - ret = !gst_pad_query_accept_caps (sinkpad, caps); - gst_caps_unref (sinkcaps); - gst_object_unref (sinkpad); - } else { - GstCaps *subcaps = gst_subtitle_overlay_create_factory_caps (); - ret = !gst_caps_is_subset (caps, subcaps); - gst_caps_unref (subcaps); + sinkcaps = gst_pad_query_caps (sinkpad, NULL); + if (!gst_caps_is_any (sinkcaps)) + ret = !gst_pad_query_accept_caps (sinkpad, caps); + gst_caps_unref (sinkcaps); + gst_object_unref (sinkpad); + } else { + GstCaps *subcaps = gst_subtitle_overlay_create_factory_caps (); + ret = !gst_caps_is_subset (caps, subcaps); + gst_caps_unref (subcaps); + } + if (activated_sink) + gst_element_set_state (group->text_sink, GST_STATE_NULL); } /* If autoplugging can stop don't do additional checks */ if (!ret) @@ -4356,8 +4360,10 @@ autoplug_continue_cb (GstElement * element, GstPad * pad, GstCaps * caps, GST_OBJECT_CAST (group->suburidecodebin))) goto done; - if ((sink = group->audio_sink)) { - sinkpad = gst_element_get_static_pad (sink, "sink"); + if (group->audio_sink && + activate_sink (group->playbin, group->audio_sink, &activated_sink)) { + + sinkpad = gst_element_get_static_pad (group->audio_sink, "sink"); if (sinkpad) { GstCaps *sinkcaps; @@ -4367,12 +4373,15 @@ autoplug_continue_cb (GstElement * element, GstPad * pad, GstCaps * caps, gst_caps_unref (sinkcaps); gst_object_unref (sinkpad); } + if (activated_sink) + gst_element_set_state (group->audio_sink, GST_STATE_NULL); } if (!ret) goto done; - if ((sink = group->video_sink)) { - sinkpad = gst_element_get_static_pad (sink, "sink"); + if (group->video_sink + && activate_sink (group->playbin, group->video_sink, &activated_sink)) { + sinkpad = gst_element_get_static_pad (group->video_sink, "sink"); if (sinkpad) { GstCaps *sinkcaps; @@ -4382,6 +4391,8 @@ autoplug_continue_cb (GstElement * element, GstPad * pad, GstCaps * caps, gst_caps_unref (sinkcaps); gst_object_unref (sinkpad); } + if (activated_sink) + gst_element_set_state (group->video_sink, GST_STATE_NULL); } done: @@ -4628,7 +4639,7 @@ autoplug_select_cb (GstElement * decodebin, GstPad * pad, /* now see if we already have a sink element */ GST_SOURCE_GROUP_LOCK (group); - if (*sinkp) { + if (*sinkp && GST_STATE (*sinkp) >= GST_STATE_READY) { GstElement *sink = gst_object_ref (*sinkp); if (sink_accepts_caps (playbin, sink, caps)) { -- 2.34.1