Commit 5058f792 authored by Sebastian Dröge's avatar Sebastian Dröge
Browse files

decodebin2: Don't use the same element multiple times in the same chain

This is going to lead to an infinite loop of this element and can easily
happen with parsers that accept their own src caps on the sinkpad.
parent 32c30b88
......@@ -1667,6 +1667,8 @@ connect_pad (GstDecodeBin * dbin, GstElement * src, GstDecodePad * dpad,
GstElement *element;
GstPad *sinkpad;
gboolean subtitle;
gboolean skip = FALSE;
GList *l;
/* Set dpad target to pad again, it might've been unset
* below but we came back here because something failed
......@@ -1678,6 +1680,29 @@ connect_pad (GstDecodeBin * dbin, GstElement * src, GstDecodePad * dpad,
/* Remove selected factory from the list. */
g_value_array_remove (factories, 0);
/* First check if this is a factory for which we have already
* created an element in this chain. If we have, we skip this
* factory because it will lead to an infinite loop. Examples
* for this are parsers that accept their own src caps on the
* sinkpad again.
for (l = chain->elements; l; l = l->next) {
GstElement *otherelement = GST_ELEMENT_CAST (l->data);
if (gst_element_get_factory (otherelement) == factory) {
skip = TRUE;
if (skip) {
"Skipping factory '%s' because it was already used in this chain",
gst_plugin_feature_get_name (GST_PLUGIN_FEATURE_CAST (factory)));
/* emit autoplug-select to see what we should do with it. */
g_signal_emit (G_OBJECT (dbin),
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment