From f19bb850acb3863ce1ed26407593d9ea42b78c8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 16 Mar 2011 18:19:11 +0100 Subject: [PATCH] inputselector: Return GST_FLOW_OK until the selected pad pushed something downstream This makes sure that during switches at no point in time all pads have returned not-linked, which can happen when playing an audio-only file with playbin2 and switching between the streams for example. Fixes bug #644935. --- plugins/elements/gstinputselector.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/elements/gstinputselector.c b/plugins/elements/gstinputselector.c index 7ef7be2be3..2a67584100 100644 --- a/plugins/elements/gstinputselector.c +++ b/plugins/elements/gstinputselector.c @@ -137,6 +137,7 @@ struct _GstSelectorPad GstPad parent; gboolean active; /* when buffer have passed the pad */ + gboolean pushed; /* when buffer was pushed downstream since activation */ gboolean eos; /* when EOS has been received */ gboolean discont; /* after switching we create a discont */ gboolean always_ok; @@ -329,6 +330,7 @@ gst_selector_pad_reset (GstSelectorPad * pad) { GST_OBJECT_LOCK (pad); pad->active = FALSE; + pad->pushed = FALSE; pad->eos = FALSE; pad->segment_pending = FALSE; pad->discont = FALSE; @@ -542,7 +544,7 @@ not_active: /* unselected pad, perform fallback alloc or return unlinked when * asked */ GST_OBJECT_LOCK (selpad); - if (selpad->always_ok) { + if (selpad->always_ok || !GST_SELECTOR_PAD_CAST (active_sinkpad)->pushed) { GST_DEBUG_OBJECT (pad, "Not selected, performing fallback allocation"); *buf = NULL; result = GST_FLOW_OK; @@ -675,6 +677,7 @@ gst_selector_pad_chain (GstPad * pad, GstBuffer * buf) } res = gst_pad_push (sel->srcpad, buf); + selpad->pushed = TRUE; done: gst_object_unref (sel); @@ -691,7 +694,7 @@ ignore: /* figure out what to return upstream */ GST_OBJECT_LOCK (selpad); - if (selpad->always_ok) + if (selpad->always_ok || !GST_SELECTOR_PAD_CAST (active_sinkpad)->pushed) res = GST_FLOW_OK; else res = GST_FLOW_NOT_LINKED; @@ -1032,6 +1035,8 @@ gst_input_selector_set_active_pad (GstInputSelector * self, gst_segment_set_stop (&self->segment, stop_time); self->pending_close = TRUE; } + if (old) + old->pushed = FALSE; if (new && new->active && start_time >= 0) { GST_DEBUG_OBJECT (self, "setting start_time to %" GST_TIME_FORMAT, @@ -1040,6 +1045,8 @@ gst_input_selector_set_active_pad (GstInputSelector * self, gst_segment_set_start (&new->segment, start_time); new->segment_pending = TRUE; } + if (new) + new->pushed = FALSE; active_pad_p = &self->active_sinkpad; gst_object_replace ((GstObject **) active_pad_p, GST_OBJECT_CAST (pad));