diff --git a/spa/plugins/audioconvert/resample.c b/spa/plugins/audioconvert/resample.c index 71901333b..ae89929d0 100644 --- a/spa/plugins/audioconvert/resample.c +++ b/spa/plugins/audioconvert/resample.c @@ -391,6 +391,8 @@ static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size) static void update_rate_match(struct impl *this, bool passthrough, uint32_t out_size, uint32_t in_queued) { + double r = this->rate_scale / this->props.rate; + if (this->io_rate_match) { uint32_t delay, match_size; @@ -399,9 +401,9 @@ static void update_rate_match(struct impl *this, bool passthrough, uint32_t out_ match_size = out_size; } else { if (SPA_FLAG_IS_SET(this->io_rate_match->flags, SPA_IO_RATE_MATCH_FLAG_ACTIVE)) - resample_update_rate(&this->resample, this->rate_scale * this->io_rate_match->rate); + resample_update_rate(&this->resample, r * this->io_rate_match->rate); else - resample_update_rate(&this->resample, this->rate_scale); + resample_update_rate(&this->resample, r); delay = resample_delay(&this->resample) + in_queued; match_size = resample_in_len(&this->resample, out_size); @@ -412,12 +414,13 @@ static void update_rate_match(struct impl *this, bool passthrough, uint32_t out_ spa_log_trace_fp(this->log, "%p: next match:%u queued:%u delay:%u", this, match_size, in_queued, delay); } else { - resample_update_rate(&this->resample, this->rate_scale * this->props.rate); + resample_update_rate(&this->resample, r); } } static inline bool is_passthrough(struct impl *this) { - return this->resample.i_rate == this->resample.o_rate && this->rate_scale == 1.0 && + return this->resample.i_rate == this->resample.o_rate && + this->rate_scale == 1.0 && this->props.rate == 1.0 && (this->io_rate_match == NULL || this->props.disabled || !SPA_FLAG_IS_SET(this->io_rate_match->flags, SPA_IO_RATE_MATCH_FLAG_ACTIVE)); }