audioconvert: also place resample output in rate_io

We can also place the estimated size that the resampler will produce in
the rate_io for output streams.

See #3750
This commit is contained in:
Wim Taymans 2024-01-16 13:29:57 +01:00
parent 05c969381d
commit 627f148665

View file

@ -1813,13 +1813,13 @@ static int ensure_tmp(struct impl *this, uint32_t maxsize, uint32_t maxports)
return 0;
}
static uint32_t resample_update_rate_match(struct impl *this, bool passthrough, uint32_t out_size, uint32_t in_queued)
static uint32_t resample_update_rate_match(struct impl *this, bool passthrough, uint32_t size, uint32_t queued)
{
uint32_t delay, match_size;
if (passthrough) {
delay = 0;
match_size = out_size;
match_size = size;
} else {
double rate = this->rate_scale / this->props.rate;
if (this->io_rate_match &&
@ -1827,14 +1827,17 @@ static uint32_t resample_update_rate_match(struct impl *this, bool passthrough,
rate *= this->io_rate_match->rate;
resample_update_rate(&this->resample, rate);
delay = resample_delay(&this->resample);
match_size = resample_in_len(&this->resample, out_size);
if (this->direction == SPA_DIRECTION_INPUT)
match_size = resample_in_len(&this->resample, size);
else
match_size = resample_out_len(&this->resample, size);
}
match_size -= SPA_MIN(match_size, in_queued);
match_size -= SPA_MIN(match_size, queued);
spa_log_trace_fp(this->log, "%p: next match %u", this, match_size);
if (this->io_rate_match) {
this->io_rate_match->delay = delay + in_queued;
this->io_rate_match->delay = delay + queued;
this->io_rate_match->size = match_size;
}
return match_size;
@ -3251,10 +3254,20 @@ static int impl_node_process(void *object)
spa_log_trace_fp(this->log, "%p: no output buffer", this);
}
}
if (resample_update_rate_match(this, resample_passthrough,
max_out - this->out_offset,
max_in - this->in_offset) > 0)
res |= SPA_STATUS_NEED_DATA;
{
uint32_t size, queued;
if (this->direction == SPA_DIRECTION_INPUT) {
size = max_out - this->out_offset;
queued = max_in - this->in_offset;
} else {
size = quant_samples;
queued = 0;
}
if (resample_update_rate_match(this, resample_passthrough,
size, queued) > 0)
res |= SPA_STATUS_NEED_DATA;
}
return res;
}