From 6382d4c0adacf2c154f024054944acd5977cafef Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Wed, 6 Feb 2013 11:09:52 -0300 Subject: [PATCH] decodebin2: do not handle the next-groups list as if it was a single item Decodebin2's chains store a next_groups list that was being handled as it could only have a single element. This is true for most of the chaining streams scenarios where streams change not very often. In more stressfull changing scenarios, like adaptive streams, those changes can happen very often, and in short time intervals. This could confuse decodebin2 as this list was always being used as a single element list. This patches makes it handle as a real list, using iteration instead of picking the first element as the correct one always. --- gst/playback/gstdecodebin2.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/gst/playback/gstdecodebin2.c b/gst/playback/gstdecodebin2.c index 39de78b..4577155 100644 --- a/gst/playback/gstdecodebin2.c +++ b/gst/playback/gstdecodebin2.c @@ -2573,7 +2573,12 @@ no_more_pads_cb (GstElement * element, GstDecodeChain * chain) if (!chain->next_groups && chain->active_group) { group = chain->active_group; } else if (chain->next_groups) { - group = chain->next_groups->data; + GList *iter; + for (iter = chain->next_groups; iter; iter = g_list_next (iter)) { + group = iter->data; + if (!group->no_more_pads) + break; + } } if (!group) { GST_ERROR_OBJECT (chain->dbin, "can't find group for element"); @@ -2742,10 +2747,19 @@ gst_decode_chain_get_current_group (GstDecodeChain * chain) } else if (!chain->active_group->overrun && !chain->active_group->no_more_pads) { group = chain->active_group; - } else if (chain->next_groups && (group = chain->next_groups->data) - && !group->overrun && !group->no_more_pads) { - /* group = chain->next_groups->data */ } else { + GList *iter; + group = NULL; + for (iter = chain->next_groups; iter; iter = g_list_next (iter)) { + GstDecodeGroup *next_group = iter->data; + + if (!next_group->overrun && !next_group->no_more_pads) { + group = next_group; + break; + } + } + } + if (!group) { group = gst_decode_group_new (chain->dbin, chain); chain->next_groups = g_list_append (chain->next_groups, group); } -- 2.7.4