From 7e9ab8b45724a8bf37dea2c7b9ac9dad627e3081 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 8 Jan 2021 13:17:06 +0100 Subject: [PATCH] resample: first resample the data, then apply the new rate Else we might not have enough input samples for the new rate. --- spa/plugins/audioconvert/resample.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/spa/plugins/audioconvert/resample.c b/spa/plugins/audioconvert/resample.c index a3b1226f8..f93670ec0 100644 --- a/spa/plugins/audioconvert/resample.c +++ b/spa/plugins/audioconvert/resample.c @@ -817,14 +817,6 @@ static int impl_node_process(void *object) flush_in = draining = true; } - if (this->io_rate_match) { - if (SPA_FLAG_IS_SET(this->io_rate_match->flags, SPA_IO_RATE_MATCH_FLAG_ACTIVE)) { - resample_update_rate(&this->resample, this->io_rate_match->rate); - } else { - resample_update_rate(&this->resample, 1.0); - } - } - in_len = (size - inport->offset) / sizeof(float); out_len = (maxsize - outport->offset) / sizeof(float); @@ -881,6 +873,11 @@ static int impl_node_process(void *object) } if (this->io_rate_match) { + if (SPA_FLAG_IS_SET(this->io_rate_match->flags, SPA_IO_RATE_MATCH_FLAG_ACTIVE)) { + resample_update_rate(&this->resample, this->io_rate_match->rate); + } else { + resample_update_rate(&this->resample, 1.0); + } this->io_rate_match->delay = resample_delay(&this->resample); this->io_rate_match->size = resample_in_len(&this->resample, max); }