playbin2: Always prefer the custom set sink and also set it back to NULL in all cases.

This commit is contained in:
Sebastian Dröge 2011-03-16 15:56:34 +01:00
parent 4e49d58917
commit a0ff13217a

View file

@ -1139,11 +1139,17 @@ free_group (GstPlayBin * playbin, GstSourceGroup * group)
g_ptr_array_free (group->text_channels, TRUE);
g_mutex_free (group->lock);
if (group->audio_sink)
if (group->audio_sink) {
if (group->audio_sink != playbin->audio_sink)
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) {
if (group->video_sink != playbin->video_sink)
gst_element_set_state (group->video_sink, GST_STATE_NULL);
gst_object_unref (group->video_sink);
}
group->video_sink = NULL;
g_list_free (group->stream_changed_pending);
@ -1239,12 +1245,18 @@ gst_play_bin_finalize (GObject * object)
if (playbin->source)
gst_object_unref (playbin->source);
if (playbin->video_sink)
if (playbin->video_sink) {
gst_element_set_state (playbin->video_sink, GST_STATE_NULL);
gst_object_unref (playbin->video_sink);
if (playbin->audio_sink)
}
if (playbin->audio_sink) {
gst_element_set_state (playbin->audio_sink, GST_STATE_NULL);
gst_object_unref (playbin->audio_sink);
if (playbin->text_sink)
}
if (playbin->text_sink) {
gst_element_set_state (playbin->text_sink, GST_STATE_NULL);
gst_object_unref (playbin->text_sink);
}
if (playbin->elements)
gst_plugin_feature_list_free (playbin->elements);
@ -2756,30 +2768,22 @@ no_more_pads_cb (GstElement * decodebin, GstSourceGroup * group)
if (configure) {
/* if we have custom sinks, configure them now */
GST_SOURCE_GROUP_LOCK (group);
if (group->audio_sink) {
GST_INFO_OBJECT (playbin, "setting custom audio sink %" GST_PTR_FORMAT,
group->audio_sink);
gst_play_sink_set_sink (playbin->playsink, GST_PLAY_SINK_TYPE_AUDIO,
group->audio_sink);
} else {
GST_INFO_OBJECT (playbin, "setting default audio sink %" GST_PTR_FORMAT,
playbin->audio_sink);
gst_play_sink_set_sink (playbin->playsink, GST_PLAY_SINK_TYPE_AUDIO,
playbin->audio_sink);
}
if (group->video_sink) {
GST_INFO_OBJECT (playbin, "setting custom video sink %" GST_PTR_FORMAT,
group->video_sink);
gst_play_sink_set_sink (playbin->playsink, GST_PLAY_SINK_TYPE_VIDEO,
group->video_sink);
} else {
GST_INFO_OBJECT (playbin, "setting default video sink %" GST_PTR_FORMAT,
playbin->video_sink);
gst_play_sink_set_sink (playbin->playsink, GST_PLAY_SINK_TYPE_VIDEO,
playbin->video_sink);
}
GST_INFO_OBJECT (playbin, "setting custom audio sink %" GST_PTR_FORMAT,
group->audio_sink);
gst_play_sink_set_sink (playbin->playsink, GST_PLAY_SINK_TYPE_AUDIO,
group->audio_sink);
GST_INFO_OBJECT (playbin, "setting custom video sink %" GST_PTR_FORMAT,
group->video_sink);
gst_play_sink_set_sink (playbin->playsink, GST_PLAY_SINK_TYPE_VIDEO,
group->video_sink);
GST_INFO_OBJECT (playbin, "setting custom text sink %" GST_PTR_FORMAT,
playbin->text_sink);
gst_play_sink_set_sink (playbin->playsink, GST_PLAY_SINK_TYPE_TEXT,
playbin->text_sink);
GST_SOURCE_GROUP_UNLOCK (group);
GST_LOG_OBJECT (playbin, "reconfigure sink");
@ -2961,8 +2965,9 @@ autoplug_continue_cb (GstElement * element, GstPad * pad, GstCaps * caps,
if ((sink = group->playbin->text_sink))
sinkpad = gst_element_get_static_pad (sink, "sink");
if (sinkpad) {
GstCaps *sinkcaps = gst_pad_get_caps_reffed (sinkpad);
GstCaps *sinkcaps;
sinkcaps = gst_pad_get_caps_reffed (sinkpad);
if (!gst_caps_is_any (sinkcaps))
ret = !gst_pad_accept_caps (sinkpad, caps);
gst_caps_unref (sinkcaps);
@ -2983,11 +2988,12 @@ autoplug_continue_cb (GstElement * element, GstPad * pad, GstCaps * caps,
GST_OBJECT_CAST (group->suburidecodebin)))
goto done;
if ((sink = group->playbin->audio_sink)) {
if ((sink = group->audio_sink)) {
sinkpad = gst_element_get_static_pad (sink, "sink");
if (sinkpad) {
GstCaps *sinkcaps = gst_pad_get_caps_reffed (sinkpad);
GstCaps *sinkcaps;
sinkcaps = gst_pad_get_caps_reffed (sinkpad);
if (!gst_caps_is_any (sinkcaps))
ret = !gst_pad_accept_caps (sinkpad, caps);
gst_caps_unref (sinkcaps);
@ -2997,11 +3003,12 @@ autoplug_continue_cb (GstElement * element, GstPad * pad, GstCaps * caps,
if (!ret)
goto done;
if ((sink = group->playbin->video_sink)) {
if ((sink = group->video_sink)) {
sinkpad = gst_element_get_static_pad (sink, "sink");
if (sinkpad) {
GstCaps *sinkcaps = gst_pad_get_caps_reffed (sinkpad);
GstCaps *sinkcaps;
sinkcaps = gst_pad_get_caps_reffed (sinkpad);
if (!gst_caps_is_any (sinkcaps))
ret = !gst_pad_accept_caps (sinkpad, caps);
gst_caps_unref (sinkcaps);
@ -3183,6 +3190,12 @@ activate_group (GstPlayBin * playbin, GstSourceGroup * group, GstState target)
GST_SOURCE_GROUP_LOCK (group);
/* First set up the custom sources */
if (playbin->audio_sink)
group->audio_sink = gst_object_ref (playbin->audio_sink);
if (playbin->video_sink)
group->video_sink = gst_object_ref (playbin->video_sink);
g_list_free (group->stream_changed_pending);
group->stream_changed_pending = NULL;
if (!group->stream_changed_pending_lock)
@ -3334,6 +3347,22 @@ no_decodebin:
{
GstMessage *msg;
/* 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)
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)
gst_element_set_state (group->video_sink, GST_STATE_NULL);
gst_object_unref (group->video_sink);
}
group->video_sink = NULL;
GST_SOURCE_GROUP_UNLOCK (group);
msg =
gst_missing_element_message_new (GST_ELEMENT_CAST (playbin),
@ -3346,6 +3375,22 @@ no_decodebin:
}
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)
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)
gst_element_set_state (group->video_sink, GST_STATE_NULL);
gst_object_unref (group->video_sink);
}
group->video_sink = NULL;
GST_DEBUG_OBJECT (playbin, "failed state change of uridecodebin");
return FALSE;
}
@ -3403,11 +3448,19 @@ deactivate_group (GstPlayBin * playbin, GstSourceGroup * group)
}
}
/* delete any custom sinks we might have */
if (group->audio_sink)
if (group->audio_sink) {
/* If this is a automatically created sink set it to NULL */
if (group->audio_sink != playbin->audio_sink)
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) {
/* If this is a automatically created sink set it to NULL */
if (group->video_sink != playbin->video_sink)
gst_element_set_state (group->video_sink, GST_STATE_NULL);
gst_object_unref (group->video_sink);
}
group->video_sink = NULL;
if (group->uridecodebin) {
@ -3623,6 +3676,14 @@ gst_play_bin_change_state (GstElement * element, GstStateChange transition)
}
}
/* Set our sinks back to NULL, they might not be child of playbin */
if (playbin->audio_sink)
gst_element_set_state (playbin->audio_sink, GST_STATE_NULL);
if (playbin->video_sink)
gst_element_set_state (playbin->video_sink, GST_STATE_NULL);
if (playbin->text_sink)
gst_element_set_state (playbin->text_sink, GST_STATE_NULL);
/* make sure the groups don't perform a state change anymore until we
* enable them again */
groups_set_locked_state (playbin, TRUE);