mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 06:58:56 +00:00
decodebin2: remove leftover elements
Remove all of the elements inside decodebin2 when goint to READY and NULL. Makes decodebin2 reusable. Fixes #583750
This commit is contained in:
parent
de06a6adb5
commit
650215bcfd
1 changed files with 42 additions and 0 deletions
|
@ -663,6 +663,10 @@ static void
|
||||||
gst_decode_bin_remove_groups (GstDecodeBin * dbin)
|
gst_decode_bin_remove_groups (GstDecodeBin * dbin)
|
||||||
{
|
{
|
||||||
GList *tmp;
|
GList *tmp;
|
||||||
|
GstIterator *it;
|
||||||
|
gpointer point;
|
||||||
|
gboolean done;
|
||||||
|
GstIteratorResult res;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (dbin, "cleaning up");
|
GST_DEBUG_OBJECT (dbin, "cleaning up");
|
||||||
|
|
||||||
|
@ -690,6 +694,44 @@ gst_decode_bin_remove_groups (GstDecodeBin * dbin)
|
||||||
}
|
}
|
||||||
g_list_free (dbin->oldgroups);
|
g_list_free (dbin->oldgroups);
|
||||||
dbin->oldgroups = NULL;
|
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
|
static void
|
||||||
|
|
Loading…
Reference in a new issue