[pulseaudio-discuss] [PATCH 6/6] resampler: Make some basic functions for rewinding
David Henningsson
david.henningsson at canonical.com
Wed Jan 28 14:14:50 PST 2015
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.
Note: Rewinds on the resampler happens very rarely - since this is
done on the sink-input side rather than the sink side, and PA keeps
a copy of already processed material, then this can only happen if
the client actively rewinds. And I don't know of any application that
actually uses that feature...
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 8e07c73..4b194d4 100644
--- a/src/pulsecore/resampler.c
+++ b/src/pulsecore/resampler.c
@@ -397,7 +397,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 10 seconds
+ r->lfe_filter = pa_lfe_filter_new(&wss, &r->o_cm, (float)crossover_freq, b->rate * 10);
pa_log_debug(" lfe filter activated (LR4 type), the crossover_freq = %uHz", crossover_freq);
}
@@ -555,6 +556,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 c7a60a4..bf281c0 100644
--- a/src/pulsecore/resampler.h
+++ b/src/pulsecore/resampler.h
@@ -142,6 +142,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
More information about the pulseaudio-discuss
mailing list