From d13a206866bbc573cdf996a9101f1e4c740335c4 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 20 Jun 2022 12:33:52 +0200 Subject: [PATCH] audioconvert: fix resampler in_offset Only advance the in_offset with the number of samples that were consumed by the resampler. In case when the resampler is filling up an old buffer, this can be less than n_samples. Fixes a2dp source and possibly others. --- spa/plugins/audioconvert/audioconvert.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spa/plugins/audioconvert/audioconvert.c b/spa/plugins/audioconvert/audioconvert.c index 4a669bcb4..55a323e80 100644 --- a/spa/plugins/audioconvert/audioconvert.c +++ b/spa/plugins/audioconvert/audioconvert.c @@ -2411,7 +2411,6 @@ static int impl_node_process(void *object) } } - this->in_offset += n_samples; if (!resample_passthrough) { uint32_t in_len, out_len; @@ -2424,10 +2423,12 @@ static int impl_node_process(void *object) in_len = n_samples; out_len = n_out; resample_process(&this->resample, in_datas, &in_len, out_datas, &out_len); - spa_log_trace_fp(this->log, "%p: resample %d->%d %d->%d %d", this, - n_samples, n_out, in_len, out_len, out_passthrough); + spa_log_trace_fp(this->log, "%p: resample %d/%d -> %d/%d %d", this, + n_samples, in_len, n_out, out_len, out_passthrough); + this->in_offset += in_len; n_samples = out_len; } else { + this->in_offset += n_samples; n_samples = SPA_MIN(n_samples, n_out); } this->out_offset += n_samples;