From 47d0efacf26367ae7b33af359b2cbf12ad330a2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 19 Nov 2014 17:17:06 +0100 Subject: [PATCH] aggregator: Unblock events/queries immediately if the pad is flushing https://bugzilla.gnome.org/show_bug.cgi?id=740376 --- libs/gst/base/gstaggregator.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/libs/gst/base/gstaggregator.c b/libs/gst/base/gstaggregator.c index 0fce62496d..3503d22b9e 100644 --- a/libs/gst/base/gstaggregator.c +++ b/libs/gst/base/gstaggregator.c @@ -1563,7 +1563,7 @@ _chain (GstPad * pad, GstObject * object, GstBuffer * buffer) PAD_LOCK_EVENT (aggpad); - while (aggpad->buffer) { + while (aggpad->buffer && g_atomic_int_get (&aggpad->priv->flushing) == FALSE) { GST_DEBUG_OBJECT (aggpad, "Waiting for buffer to be consumed"); PAD_WAIT_EVENT (aggpad); } @@ -1622,7 +1622,14 @@ pad_query_func (GstPad * pad, GstObject * parent, GstQuery * query) if (GST_QUERY_IS_SERIALIZED (query)) { PAD_LOCK_EVENT (aggpad); - while (aggpad->buffer) { + + if (g_atomic_int_get (&aggpad->priv->flushing) == TRUE) { + PAD_UNLOCK_EVENT (aggpad); + goto flushing; + } + + while (aggpad->buffer + && g_atomic_int_get (&aggpad->priv->flushing) == FALSE) { GST_DEBUG_OBJECT (aggpad, "Waiting for buffer to be consumed"); PAD_WAIT_EVENT (aggpad); } @@ -1649,7 +1656,15 @@ pad_event_func (GstPad * pad, GstObject * parent, GstEvent * event) if (GST_EVENT_IS_SERIALIZED (event) && GST_EVENT_TYPE (event) != GST_EVENT_EOS && GST_EVENT_TYPE (event) != GST_EVENT_SEGMENT_DONE) { PAD_LOCK_EVENT (aggpad); - while (aggpad->buffer) { + + if (g_atomic_int_get (&aggpad->priv->flushing) == TRUE + && GST_EVENT_TYPE (event) != GST_EVENT_FLUSH_STOP) { + PAD_UNLOCK_EVENT (aggpad); + goto flushing; + } + + while (aggpad->buffer + && g_atomic_int_get (&aggpad->priv->flushing) == FALSE) { GST_DEBUG_OBJECT (aggpad, "Waiting for buffer to be consumed"); PAD_WAIT_EVENT (aggpad); }