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.
This commit is contained in:
Sebastian Dröge 2015-03-03 20:03:55 +01:00
parent 5fc7d39090
commit fc917fb8cf

View file

@ -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);