summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Henningsson <david.henningsson@canonical.com>2015-03-24 10:29:18 +0100
committerDavid Henningsson <david.henningsson@canonical.com>2015-03-30 10:52:30 +0200
commit7fb531d9369bb8a8edcdf84633e5e455b0fa7e40 (patch)
tree70224c3b8293538ca8cae6a4895c701ddc1c0293 /src
parentdefc2b702bd7358634e70635a7614172836d632e (diff)
resampler: Make some basic functions for rewinding
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@canonical.com>
Diffstat (limited to 'src')
-rw-r--r--src/pulsecore/resampler.c18
-rw-r--r--src/pulsecore/resampler.h3
-rw-r--r--src/pulsecore/sink-input.c4
-rw-r--r--src/pulsecore/source-output.c2
4 files changed, 22 insertions, 5 deletions
diff --git a/src/pulsecore/resampler.c b/src/pulsecore/resampler.c
index db296982e..f5a0e167f 100644
--- a/src/pulsecore/resampler.c
+++ b/src/pulsecore/resampler.c
@@ -578,6 +578,20 @@ void pa_resampler_reset(pa_resampler *r) {
*r->have_leftover = false;
}
+void pa_resampler_rewind(pa_resampler *r, size_t out_frames) {
+ 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, out_frames);
+
+ *r->have_leftover = false;
+}
+
pa_resample_method_t pa_resampler_get_method(pa_resampler *r) {
pa_assert(r);
@@ -818,8 +832,8 @@ static void setup_remap(const pa_resampler *r, pa_remap_t *m, bool *lfe_filter_r
} else {
/* OK, we shall do the full monty: upmixing and downmixing. Our
- * algorithm is relatively simple, does not do spacialization, delay
- * elements or apply lowpass filters for LFE. Patches are always
+ * algorithm is relatively simple, does not do spacialization, or delay
+ * elements. LFE filters are done after the remap step. Patches are always
* welcome, though. Oh, and it doesn't do any matrix decoding. (Which
* probably wouldn't make any sense anyway.)
*
diff --git a/src/pulsecore/resampler.h b/src/pulsecore/resampler.h
index 3bc105491..4469022e0 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 out_frames);
+
/* 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 7d2202e0d..fe980c3e3 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 4cc10534c..9000972ac 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);