From d7f6cb23dec483f538239eb42e21c321713c976e Mon Sep 17 00:00:00 2001 From: uau Date: Thu, 1 Nov 2007 06:52:50 +0000 Subject: A/V sync: take audio filter buffers into account Substract the delay caused by filter buffering when calculating currently playing audio position. This matters for af_scaletempo which buffers significant and varying amounts of data. For other current filters the effect is normally insignificant. Instead of the old time-based filter delay field (which was ignored) this version stores the per-filter delay in units of bytes input read without corresponding output. This allows the current scaletempo behavior where other filters before and after it can see the same nominal samplerate even though the real duration of the data varies; in this case the other filters can not know the delay they're causing in terms of real time. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@24928 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libaf/af_scaletempo.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'libaf/af_scaletempo.c') diff --git a/libaf/af_scaletempo.c b/libaf/af_scaletempo.c index 4cdde2d5c0..3ed14aec68 100644 --- a/libaf/af_scaletempo.c +++ b/libaf/af_scaletempo.c @@ -261,6 +261,11 @@ static af_data_t* play(struct af_instance_s* af, af_data_t* data) offset_in += fill_queue(af, data, offset_in); } + // This filter can have a negative delay when scale > 1: + // output corresponding to some length of input can be decided and written + // after receiving only a part of that input. + af->delay = s->bytes_queued - s->bytes_to_slide; + data->audio = af->data->audio; data->len = pout - (int8_t *)af->data->audio; return data; -- cgit v1.2.3