From 841d738f7ca982010a9c64d75a749ce08e7031bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 2 Jul 2013 14:02:57 +0200 Subject: [PATCH] playbin: Don't change the state of sinks that we passed to playsink already --- gst/playback/gstplaybin2.c | 52 +++++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/gst/playback/gstplaybin2.c b/gst/playback/gstplaybin2.c index b62bc10eb9..6f087443b7 100644 --- a/gst/playback/gstplaybin2.c +++ b/gst/playback/gstplaybin2.c @@ -1294,6 +1294,19 @@ init_group (GstPlayBin * playbin, GstSourceGroup * group) group->combiner[PLAYBIN_STREAM_TEXT].channels = group->text_channels; } +static gboolean +is_playsink_sink (GstPlayBin * playbin, GstElement * sink, GstPlaySinkType type) +{ + GstElement *tmp; + gboolean ret; + + tmp = gst_play_sink_get_sink (playbin->playsink, type); + ret = (tmp == sink); + if (tmp) + gst_object_unref (tmp); + return ret; +} + static void free_group (GstPlayBin * playbin, GstSourceGroup * group) { @@ -1305,13 +1318,15 @@ free_group (GstPlayBin * playbin, GstSourceGroup * group) g_mutex_clear (&group->lock); if (group->audio_sink) { - if (group->audio_sink != playbin->audio_sink) + if (!is_playsink_sink (playbin, group->audio_sink, + GST_PLAY_SINK_TYPE_AUDIO)) gst_element_set_state (group->audio_sink, GST_STATE_NULL); gst_object_unref (group->audio_sink); } group->audio_sink = NULL; if (group->video_sink) { - if (group->video_sink != playbin->video_sink) + if (!is_playsink_sink (playbin, group->video_sink, + GST_PLAY_SINK_TYPE_VIDEO)) gst_element_set_state (group->video_sink, GST_STATE_NULL); gst_object_unref (group->video_sink); } @@ -3412,6 +3427,7 @@ no_more_pads_cb (GstElement * decodebin, GstSourceGroup * group) } } GST_SOURCE_GROUP_UNLOCK (group); + gst_play_sink_reconfigure (playbin->playsink); } GST_PLAY_BIN_SHUTDOWN_UNLOCK (playbin); @@ -4267,8 +4283,11 @@ autoplug_select_cb (GstElement * decodebin, GstPad * pad, * sink or if we have a fixed sink, try the decoder. We will fail later * anyway */ gst_object_unref (sinkpad); - if ((isaudiodec && group->audio_sink != playbin->audio_sink) || - (isvideodec && group->video_sink != playbin->video_sink)) { + if ((isaudiodec + && is_playsink_sink (playbin, group->audio_sink, + GST_PLAY_SINK_TYPE_AUDIO)) || (isvideodec + && is_playsink_sink (playbin, group->video_sink, + GST_PLAY_SINK_TYPE_VIDEO))) { gst_element_set_state (*sinkp, GST_STATE_NULL); gst_object_unref (*sinkp); *sinkp = NULL; @@ -4316,8 +4335,11 @@ autoplug_select_cb (GstElement * decodebin, GstPad * pad, /* If it is not compatible, either continue with the next possible * sink or if we have a fixed sink, skip the decoder */ - if ((isaudiodec && group->audio_sink != playbin->audio_sink) || - (isvideodec && group->video_sink != playbin->video_sink)) { + if ((isaudiodec + && is_playsink_sink (playbin, group->audio_sink, + GST_PLAY_SINK_TYPE_AUDIO)) || (isvideodec + && is_playsink_sink (playbin, group->video_sink, + GST_PLAY_SINK_TYPE_VIDEO))) { gst_element_set_state (*sinkp, GST_STATE_NULL); gst_object_unref (*sinkp); *sinkp = NULL; @@ -4949,14 +4971,16 @@ no_decodebin: /* delete any custom sinks we might have */ if (group->audio_sink) { /* If this is a automatically created sink set it to NULL */ - if (group->audio_sink != playbin->audio_sink) + if (!is_playsink_sink (playbin, group->audio_sink, + GST_PLAY_SINK_TYPE_AUDIO)) gst_element_set_state (group->audio_sink, GST_STATE_NULL); gst_object_unref (group->audio_sink); } group->audio_sink = NULL; if (group->video_sink) { /* If this is a automatically created sink set it to NULL */ - if (group->video_sink != playbin->video_sink) + if (!is_playsink_sink (playbin, group->video_sink, + GST_PLAY_SINK_TYPE_VIDEO)) gst_element_set_state (group->video_sink, GST_STATE_NULL); gst_object_unref (group->video_sink); } @@ -4977,14 +5001,16 @@ uridecodebin_failure: /* delete any custom sinks we might have */ if (group->audio_sink) { /* If this is a automatically created sink set it to NULL */ - if (group->audio_sink != playbin->audio_sink) + if (!is_playsink_sink (playbin, group->audio_sink, + GST_PLAY_SINK_TYPE_AUDIO)) gst_element_set_state (group->audio_sink, GST_STATE_NULL); gst_object_unref (group->audio_sink); } group->audio_sink = NULL; if (group->video_sink) { /* If this is a automatically created sink set it to NULL */ - if (group->video_sink != playbin->video_sink) + if (!is_playsink_sink (playbin, group->video_sink, + GST_PLAY_SINK_TYPE_VIDEO)) gst_element_set_state (group->video_sink, GST_STATE_NULL); gst_object_unref (group->video_sink); } @@ -5051,14 +5077,16 @@ deactivate_group (GstPlayBin * playbin, GstSourceGroup * group) /* delete any custom sinks we might have */ if (group->audio_sink) { /* If this is a automatically created sink set it to NULL */ - if (group->audio_sink != playbin->audio_sink) + if (!is_playsink_sink (playbin, group->audio_sink, + GST_PLAY_SINK_TYPE_AUDIO)) gst_element_set_state (group->audio_sink, GST_STATE_NULL); gst_object_unref (group->audio_sink); } group->audio_sink = NULL; if (group->video_sink) { /* If this is a automatically created sink set it to NULL */ - if (group->video_sink != playbin->video_sink) + if (!is_playsink_sink (playbin, group->video_sink, + GST_PLAY_SINK_TYPE_VIDEO)) gst_element_set_state (group->video_sink, GST_STATE_NULL); gst_object_unref (group->video_sink); }