From fc917fb8cfd7d4e200857d0872fd841bbe676a75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 3 Mar 2015 20:03:55 +0100 Subject: [PATCH] audiomixer: Latency is twice the output buffer duration, not only once Let's assume a source that outputs outputs 20ms buffers, and audiomixer having a 20ms output buffer duration. However timestamps don't align perfectly, the source buffers are offsetted by 5ms. For our ASCII art picture, each letter is 5ms, each pipe is the start of a 20ms buffer. So what happens is the following: 0 20 40 60 OOOOOOOOOOOOOOOO | | | | 5 25 45 65 IIIIIIIIIIIIIIII | | | | This means that the second output buffer (20 to 40ms) only gets its last 5ms at time 45ms (the timestamp of the next buffer is the time when the buffer arrives). But if we only have a latency of 20ms, we would wait until 40ms to generate the output buffer and miss the last 5ms of the input buffer. --- gst/audiomixer/gstaudiomixer.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gst/audiomixer/gstaudiomixer.c b/gst/audiomixer/gstaudiomixer.c index 8881d63ebb..da0884238d 100644 --- a/gst/audiomixer/gstaudiomixer.c +++ b/gst/audiomixer/gstaudiomixer.c @@ -826,7 +826,8 @@ gst_audiomixer_init (GstAudioMixer * audiomixer) audiomixer->discont_wait = DEFAULT_DISCONT_WAIT; audiomixer->output_buffer_duration = DEFAULT_OUTPUT_BUFFER_DURATION; gst_aggregator_set_latency (GST_AGGREGATOR (audiomixer), - audiomixer->output_buffer_duration, audiomixer->output_buffer_duration); + 2 * audiomixer->output_buffer_duration, + 2 * audiomixer->output_buffer_duration); } static void @@ -877,8 +878,8 @@ gst_audiomixer_set_property (GObject * object, guint prop_id, case PROP_OUTPUT_BUFFER_DURATION: audiomixer->output_buffer_duration = g_value_get_uint64 (value); gst_aggregator_set_latency (GST_AGGREGATOR (audiomixer), - audiomixer->output_buffer_duration, - audiomixer->output_buffer_duration); + 2 * audiomixer->output_buffer_duration, + 2 * audiomixer->output_buffer_duration); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);