1 From 83bed90c306ed3185d48febf6441177d638f7341 Mon Sep 17 00:00:00 2001
2 From: Song Bing <b06498@freescale.com>
3 Date: Wed, 24 Dec 2014 10:13:51 +0800
4 Subject: [PATCH] inputselector: sticky events haven't send out when active
7 EOS event hasn't been send to down-element. The resolution is block EOS event
8 of inactive pad, send the event after the pad actived.
10 https://bugzilla.gnome.org/show_bug.cgi?id=740949
12 Upstream-Status: Backport [1.5.1]
14 Signed-off-by: Song Bing <b06498@freescale.com>
16 plugins/elements/gstinputselector.c | 58 ++++++++++++++++++++++++++---------
17 plugins/elements/gstinputselector.h | 1 +
18 2 files changed, 45 insertions(+), 14 deletions(-)
20 diff --git a/plugins/elements/gstinputselector.c b/plugins/elements/gstinputselector.c
21 index fb50802..4461f7c 100644
22 --- a/plugins/elements/gstinputselector.c
23 +++ b/plugins/elements/gstinputselector.c
24 @@ -440,6 +440,17 @@ gst_selector_pad_iterate_linked_pads (GstPad * pad, GstObject * parent)
28 +gst_input_selector_eos_wait (GstInputSelector * self, GstSelectorPad * pad)
30 + while (!self->eos && !self->flushing && !pad->flushing) {
31 + /* we can be unlocked here when we are shutting down (flushing) or when we
33 + GST_INPUT_SELECTOR_WAIT (self);
35 + return self->flushing;
39 gst_selector_pad_event (GstPad * pad, GstObject * parent, GstEvent * event)
42 @@ -486,6 +497,7 @@ gst_selector_pad_event (GstPad * pad, GstObject * parent, GstEvent * event)
43 case GST_EVENT_FLUSH_START:
44 /* Unblock the pad if it's waiting */
45 selpad->flushing = TRUE;
47 GST_INPUT_SELECTOR_BROADCAST (sel);
49 case GST_EVENT_FLUSH_STOP:
50 @@ -523,21 +535,12 @@ gst_selector_pad_event (GstPad * pad, GstObject * parent, GstEvent * event)
55 - selpad->eos_sent = TRUE;
57 - GstSelectorPad *active_selpad;
59 - /* If the active sinkpad is in EOS state but EOS
60 - * was not sent downstream this means that the pad
61 - * got EOS before it was set as active pad and that
62 - * the previously active pad got EOS after it was
65 - active_selpad = GST_SELECTOR_PAD (active_sinkpad);
66 - forward = (active_selpad->eos && !active_selpad->eos_sent);
67 - active_selpad->eos_sent = TRUE;
69 + /* blocked until active the sind pad or flush */
70 + gst_input_selector_eos_wait (sel, selpad);
73 + selpad->eos_sent = TRUE;
74 GST_DEBUG_OBJECT (pad, "received EOS");
77 @@ -676,6 +679,12 @@ gst_input_selector_wait_running_time (GstInputSelector * sel,
78 gst_input_selector_activate_sinkpad (sel, GST_PAD_CAST (selpad));
79 active_selpad = GST_SELECTOR_PAD_CAST (active_sinkpad);
82 + GST_DEBUG_OBJECT (sel, "Not waiting because inputselector reach EOS.");
83 + GST_INPUT_SELECTOR_UNLOCK (sel);
87 if (seg->format != GST_FORMAT_TIME) {
88 GST_DEBUG_OBJECT (selpad,
89 "Not waiting because we don't have a TIME segment");
90 @@ -971,6 +980,12 @@ gst_selector_pad_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
91 GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)));
93 GST_INPUT_SELECTOR_LOCK (sel);
95 + GST_DEBUG_OBJECT (pad, "inputselector eos.");
96 + GST_INPUT_SELECTOR_UNLOCK (sel);
100 /* wait or check for flushing */
101 if (gst_input_selector_wait (sel, selpad)) {
102 GST_INPUT_SELECTOR_UNLOCK (sel);
103 @@ -1151,6 +1166,13 @@ flushing:
104 res = GST_FLOW_FLUSHING;
109 + GST_DEBUG_OBJECT (pad, "We are eos, discard buffer %p", buf);
110 + gst_buffer_unref (buf);
111 + res = GST_FLOW_EOS;
116 static void gst_input_selector_dispose (GObject * object);
117 @@ -1309,6 +1331,7 @@ gst_input_selector_init (GstInputSelector * sel)
118 g_mutex_init (&sel->lock);
119 g_cond_init (&sel->cond);
120 sel->blocked = FALSE;
123 /* lets give a change for downstream to do something on
124 * active-pad change before we start pushing new buffers */
125 @@ -1377,6 +1400,11 @@ gst_input_selector_set_active_pad (GstInputSelector * self, GstPad * pad)
126 GST_DEBUG_OBJECT (self, "New active pad is %" GST_PTR_FORMAT,
127 self->active_sinkpad);
129 + if (old != new && new->eos && !new->eos_sent) {
131 + GST_INPUT_SELECTOR_BROADCAST (self);
137 @@ -1771,6 +1799,7 @@ gst_input_selector_change_state (GstElement * element,
138 switch (transition) {
139 case GST_STATE_CHANGE_READY_TO_PAUSED:
140 GST_INPUT_SELECTOR_LOCK (self);
142 self->blocked = FALSE;
143 self->flushing = FALSE;
144 GST_INPUT_SELECTOR_UNLOCK (self);
145 @@ -1779,6 +1808,7 @@ gst_input_selector_change_state (GstElement * element,
146 /* first unlock before we call the parent state change function, which
147 * tries to acquire the stream lock when going to ready. */
148 GST_INPUT_SELECTOR_LOCK (self);
150 self->blocked = FALSE;
151 self->flushing = TRUE;
152 GST_INPUT_SELECTOR_BROADCAST (self);
153 diff --git a/plugins/elements/gstinputselector.h b/plugins/elements/gstinputselector.h
154 index 96c680f..9bf924f 100644
155 --- a/plugins/elements/gstinputselector.h
156 +++ b/plugins/elements/gstinputselector.h
157 @@ -77,6 +77,7 @@ struct _GstInputSelector {