diff options
author | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2010-07-14 12:59:19 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2010-07-14 15:11:17 +0200 |
commit | 8bd37ab9956d390a867d99196fe9d363c11dd679 (patch) | |
tree | 0a557ebb1daddb8a7b1a2c9ec8fc0f56f063ac6d | |
parent | ac83fbfdbdc247be3362e1e64a418f7362655cb2 (diff) |
playbin2: Disconnect and destroy uridecodebins when going from READY to NULL
Fixes spurious errors that happen after an error and playing a working
stream afterwards or signals that are emitted for non-active groups.
Fixes bug #624266.
-rw-r--r-- | gst/playback/gstplaybin2.c | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/gst/playback/gstplaybin2.c b/gst/playback/gstplaybin2.c index 2c3ebdc4c..13a909061 100644 --- a/gst/playback/gstplaybin2.c +++ b/gst/playback/gstplaybin2.c @@ -3448,7 +3448,7 @@ setup_next_source (GstPlayBin * playbin, GstState target) /* first unlink the current source, if any */ old_group = playbin->curr_group; - if (old_group && old_group->valid) { + if (old_group && old_group->valid && old_group->active) { gst_play_bin_update_cached_duration (playbin); /* unlink our pads with the sink */ deactivate_group (playbin, old_group); @@ -3573,30 +3573,12 @@ gst_play_bin_change_state (GstElement * element, GstStateChange transition) GST_LOG_OBJECT (playbin, "dynamic lock taken, we can continue shutdown"); GST_PLAY_BIN_DYN_UNLOCK (playbin); break; - case GST_STATE_CHANGE_READY_TO_NULL:{ - guint i; - + case GST_STATE_CHANGE_READY_TO_NULL: memset (&playbin->duration, 0, sizeof (playbin->duration)); /* unlock so that all groups go to NULL */ groups_set_locked_state (playbin, FALSE); - - for (i = 0; i < 2; i++) { - if (playbin->groups[i].uridecodebin) { - gst_element_set_state (playbin->groups[i].uridecodebin, - GST_STATE_NULL); - gst_object_unref (playbin->groups[i].uridecodebin); - playbin->groups[i].uridecodebin = NULL; - } - if (playbin->groups[i].suburidecodebin) { - gst_element_set_state (playbin->groups[i].suburidecodebin, - GST_STATE_NULL); - gst_object_unref (playbin->groups[i].suburidecodebin); - playbin->groups[i].suburidecodebin = NULL; - } - } break; - } default: break; } @@ -3615,10 +3597,38 @@ gst_play_bin_change_state (GstElement * element, GstStateChange transition) save_current_group (playbin); break; case GST_STATE_CHANGE_READY_TO_NULL: + { + guint i; + + /* Deactive the groups, set the uridecodebins to NULL + * and unref them. + */ + for (i = 0; i < 2; i++) { + if (playbin->groups[i].active && playbin->groups[i].valid) { + deactivate_group (playbin, &playbin->groups[i]); + playbin->groups[i].valid = FALSE; + } + + if (playbin->groups[i].uridecodebin) { + gst_element_set_state (playbin->groups[i].uridecodebin, + GST_STATE_NULL); + gst_object_unref (playbin->groups[i].uridecodebin); + playbin->groups[i].uridecodebin = NULL; + } + + if (playbin->groups[i].suburidecodebin) { + gst_element_set_state (playbin->groups[i].suburidecodebin, + GST_STATE_NULL); + gst_object_unref (playbin->groups[i].suburidecodebin); + playbin->groups[i].suburidecodebin = NULL; + } + } + /* make sure the groups don't perform a state change anymore until we * enable them again */ groups_set_locked_state (playbin, TRUE); break; + } default: break; } @@ -3632,9 +3642,10 @@ failure: GstSourceGroup *curr_group; curr_group = playbin->curr_group; - if (curr_group && curr_group->valid) { + if (curr_group && curr_group->active && curr_group->valid) { /* unlink our pads with the sink */ deactivate_group (playbin, curr_group); + curr_group->valid = FALSE; } /* Swap current and next group back */ |