The resampler framework just forwards the request to the lfe filter. There are no resampler impl that can rewind yet, so just reset the resampler impl instead of properly rewinding yet. Signed-off-by: David Henningsson <david.henningsson at canonical.com> --- src/pulsecore/resampler.c | 17 ++++++++++++++++- src/pulsecore/resampler.h | 3 +++ src/pulsecore/sink-input.c | 4 ++-- src/pulsecore/source-output.c | 2 +- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/pulsecore/resampler.c b/src/pulsecore/resampler.c index 13b272f..9ca87d8 100644 --- a/src/pulsecore/resampler.c +++ b/src/pulsecore/resampler.c @@ -419,7 +419,8 @@ pa_resampler* pa_resampler_new( if (lfe_filter_required) { pa_sample_spec wss = r->o_ss; wss.format = r->work_format; - r->lfe_filter = pa_lfe_filter_new(&wss, &r->o_cm, (float)crossover_freq); + /* FIXME: For now just hardcode maxrewind to 3 seconds */ + r->lfe_filter = pa_lfe_filter_new(&wss, &r->o_cm, (float)crossover_freq, b->rate * 3); pa_log_debug(" lfe filter activated (LR4 type), the crossover_freq = %uHz", crossover_freq); } @@ -577,6 +578,20 @@ void pa_resampler_reset(pa_resampler *r) { *r->have_leftover = false; } +void pa_resampler_rewind(pa_resampler *r, size_t amount) { + pa_assert(r); + + /* For now, we don't have any rewindable resamplers, so we just + reset the resampler instead (and hope that nobody hears the difference). */ + if (r->impl.reset) + r->impl.reset(r); + + if (r->lfe_filter) + pa_lfe_filter_rewind(r->lfe_filter, amount); + + *r->have_leftover = false; +} + pa_resample_method_t pa_resampler_get_method(pa_resampler *r) { pa_assert(r); diff --git a/src/pulsecore/resampler.h b/src/pulsecore/resampler.h index 3bc1054..ef683e2 100644 --- a/src/pulsecore/resampler.h +++ b/src/pulsecore/resampler.h @@ -145,6 +145,9 @@ void pa_resampler_set_output_rate(pa_resampler *r, uint32_t rate); /* Reinitialize state of the resampler, possibly due to seeking or other discontinuities */ void pa_resampler_reset(pa_resampler *r); +/* Rewind resampler */ +void pa_resampler_rewind(pa_resampler *r, size_t amount); + /* Return the resampling method of the resampler object */ pa_resample_method_t pa_resampler_get_method(pa_resampler *r); diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c index 7d2202e..fe980c3 100644 --- a/src/pulsecore/sink-input.c +++ b/src/pulsecore/sink-input.c @@ -1106,9 +1106,9 @@ void pa_sink_input_process_rewind(pa_sink_input *i, size_t nbytes /* in sink sam if (i->thread_info.rewrite_flush) pa_memblockq_silence(i->thread_info.render_memblockq); - /* And reset the resampler */ + /* And rewind the resampler */ if (i->thread_info.resampler) - pa_resampler_reset(i->thread_info.resampler); + pa_resampler_rewind(i->thread_info.resampler, amount); } } diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c index 4cc1053..9000972 100644 --- a/src/pulsecore/source-output.c +++ b/src/pulsecore/source-output.c @@ -851,7 +851,7 @@ void pa_source_output_process_rewind(pa_source_output *o, size_t nbytes /* in so o->process_rewind(o, nbytes); if (o->thread_info.resampler) - pa_resampler_reset(o->thread_info.resampler); + pa_resampler_rewind(o->thread_info.resampler, nbytes); } else pa_memblockq_rewind(o->thread_info.delay_memblockq, nbytes); -- 1.9.1