mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
resample: tweak the resampler to keep delay number of samples
Instead of requiring the upstream node to resubmit the delayed samples, keep the samples ourselves. The benefit is probably too small to measure but it simplifies things a lot.
This commit is contained in:
parent
84eed9ef6f
commit
7f007b6bca
3 changed files with 12 additions and 12 deletions
|
|
@ -226,7 +226,7 @@ static void impl_native_process(struct resample *r,
|
|||
|
||||
if (SPA_LIKELY(hist)) {
|
||||
/* first work on the history if any. */
|
||||
if (SPA_UNLIKELY(hist < n_taps)) {
|
||||
if (SPA_UNLIKELY(hist <= n_taps)) {
|
||||
/* we need at least n_taps to completely process the
|
||||
* history before we can work on the new input. When
|
||||
* we have less, refill the history. */
|
||||
|
|
@ -265,7 +265,7 @@ static void impl_native_process(struct resample *r,
|
|||
r, *in_len, in, *out_len, out);
|
||||
|
||||
remain = *in_len - skip - in;
|
||||
if (remain > 0 && remain < n_taps) {
|
||||
if (remain > 0 && remain <= n_taps) {
|
||||
/* not enough input data remaining for more output,
|
||||
* copy to history */
|
||||
for (c = 0; c < r->channels; c++)
|
||||
|
|
|
|||
|
|
@ -802,11 +802,15 @@ static int impl_node_process(void *object)
|
|||
|
||||
switch (this->mode) {
|
||||
case MODE_SPLIT:
|
||||
/* in split mode we need to output exactly the size of the
|
||||
* duration so we don't try to flush early */
|
||||
maxsize = SPA_MIN(maxsize, max * sizeof(float));
|
||||
flush_out = flush_in = this->io_rate_match != NULL;
|
||||
flush_out = false;
|
||||
break;
|
||||
case MODE_MERGE:
|
||||
default:
|
||||
/* in merge mode we consume one duration of samples and
|
||||
* always output the resulting data */
|
||||
flush_out = true;
|
||||
break;
|
||||
}
|
||||
|
|
@ -873,11 +877,10 @@ 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)) {
|
||||
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 {
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue