summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Crête <olivier.crete@collabora.com>2015-09-17 19:42:34 -0400
committerSebastian Dröge <sebastian@centricular.com>2015-09-18 12:17:49 +0200
commit473145197404c02b00f659d3a303561d81ffce36 (patch)
tree2412a4eb6f7cf7811716d2dea00d07eef07864b8
parentf770363d6c15f94e535db5552e50e2fa96f6b8b9 (diff)
downloadgstreamer-plugins-bad-473145197404c02b00f659d3a303561d81ffce36.tar.gz
aggregator: Keep at least two buffers in the queue in live mode
When in live mode, the queue needs to hold the currently processed buffer and one more at least. https://bugzilla.gnome.org/show_bug.cgi?id=754851
-rw-r--r--gst-libs/gst/base/gstaggregator.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/gst-libs/gst/base/gstaggregator.c b/gst-libs/gst/base/gstaggregator.c
index 9a0a55cf1..9d3164991 100644
--- a/gst-libs/gst/base/gstaggregator.c
+++ b/gst-libs/gst/base/gstaggregator.c
@@ -216,6 +216,7 @@ struct _GstAggregatorPadPrivate
gboolean pending_eos;
GQueue buffers;
+ guint num_buffers;
GstClockTime head_position;
GstClockTime tail_position;
GstClockTime head_time;
@@ -777,6 +778,7 @@ gst_aggregator_pad_set_flushing (GstAggregatorPad * aggpad,
}
item = next;
}
+ aggpad->priv->num_buffers = 0;
PAD_BROADCAST_EVENT (aggpad);
PAD_UNLOCK (aggpad);
@@ -2041,7 +2043,7 @@ gst_aggregator_get_type (void)
return type;
}
-/* Must be called with PAD lock held */
+/* Must be called with SRC lock and PAD lock held */
static gboolean
gst_aggregator_pad_has_space (GstAggregator * self, GstAggregatorPad * aggpad)
{
@@ -2049,6 +2051,11 @@ gst_aggregator_pad_has_space (GstAggregator * self, GstAggregatorPad * aggpad)
if (g_queue_get_length (&aggpad->priv->buffers) == 0)
return TRUE;
+ /* We also want at least two buffers, one is being processed and one is ready
+ * for the next iteration when we operate in live mode. */
+ if (self->priv->peer_latency_live && aggpad->priv->num_buffers < 2)
+ return TRUE;
+
/* zero latency, if there is a buffer, it's full */
if (self->priv->latency == 0)
return FALSE;
@@ -2135,6 +2142,7 @@ gst_aggregator_pad_chain_internal (GstAggregator * self,
else
g_queue_push_tail (&aggpad->priv->buffers, actual_buf);
apply_buffer (aggpad, actual_buf, head);
+ aggpad->priv->num_buffers++;
actual_buf = buffer = NULL;
SRC_BROADCAST (self);
break;
@@ -2431,6 +2439,7 @@ gst_aggregator_pad_steal_buffer (GstAggregatorPad * pad)
if (buffer) {
apply_buffer (pad, buffer, FALSE);
+ pad->priv->num_buffers--;
GST_TRACE_OBJECT (pad, "Consuming buffer");
if (gst_aggregator_pad_queue_is_empty (pad) && pad->priv->pending_eos) {
pad->priv->pending_eos = FALSE;