summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2009-05-27 18:12:10 +0200
committerWim Taymans <wim.taymans@collabora.co.uk>2009-05-27 18:12:10 +0200
commit650215bcfda5c7ca6ec6d14f7442c7b32f94f636 (patch)
tree5db8aef500b7b6105f07d63ab8cd2ad9917ee520
parentde06a6adb5d34990e2306d1006e2ff00a5a0e41c (diff)
decodebin2: remove leftover elements
Remove all of the elements inside decodebin2 when goint to READY and NULL. Makes decodebin2 reusable. Fixes #583750
-rw-r--r--gst/playback/gstdecodebin2.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/gst/playback/gstdecodebin2.c b/gst/playback/gstdecodebin2.c
index d63cb6550..6ff9223c5 100644
--- a/gst/playback/gstdecodebin2.c
+++ b/gst/playback/gstdecodebin2.c
@@ -663,6 +663,10 @@ static void
gst_decode_bin_remove_groups (GstDecodeBin * dbin)
{
GList *tmp;
+ GstIterator *it;
+ gpointer point;
+ gboolean done;
+ GstIteratorResult res;
GST_DEBUG_OBJECT (dbin, "cleaning up");
@@ -690,6 +694,44 @@ gst_decode_bin_remove_groups (GstDecodeBin * dbin)
}
g_list_free (dbin->oldgroups);
dbin->oldgroups = NULL;
+
+ GST_DEBUG_OBJECT (dbin, "removing last elements");
+
+ /* remove all remaining elements */
+ it = gst_bin_iterate_elements (GST_BIN_CAST (dbin));
+restart:
+ done = FALSE;
+ while (!done) {
+ res = gst_iterator_next (it, &point);
+ switch (res) {
+ case GST_ITERATOR_DONE:
+ done = TRUE;
+ break;
+ case GST_ITERATOR_RESYNC:
+ gst_iterator_resync (it);
+ goto restart;
+ case GST_ITERATOR_ERROR:
+ GST_WARNING_OBJECT (dbin,
+ "Had an error while iterating bin %s", GST_ELEMENT_NAME (dbin));
+ done = TRUE;
+ break;
+ case GST_ITERATOR_OK:
+ {
+ GstElement *elem = GST_ELEMENT_CAST (point);
+
+ /* don't remove the typefind element */
+ if (elem != dbin->typefind) {
+ GST_DEBUG_OBJECT (dbin, "remove element %s", GST_ELEMENT_NAME (elem));
+ gst_bin_remove (GST_BIN_CAST (dbin), elem);
+ gst_element_set_state (elem, GST_STATE_NULL);
+ }
+ gst_object_unref (elem);
+ break;
+ }
+ default:
+ break;
+ }
+ }
}
static void