summaryrefslogtreecommitdiff
path: root/src/pulsecore/resampler.h
diff options
context:
space:
mode:
authorGeorg Chini <georg@chini.tk>2021-01-01 00:22:11 +0100
committerPulseAudio Marge Bot <pulseaudio-maintainers@lists.freedesktop.org>2021-11-03 18:37:31 +0000
commit656179a8fe16126a17b8dc48ae44f97bfcfb26a6 (patch)
treeec174774bc0e6295f4c394a6cbbaad2a134d9215 /src/pulsecore/resampler.h
parent1bfabd6512cf83a0c3ecadea3942f38ad0cb786a (diff)
downloadpulseaudio-656179a8fe16126a17b8dc48ae44f97bfcfb26a6.tar.gz
resampler: Add pa_resampler_prepare() and pa_resampler_get_delay() functions
The pa_resampler_get_delay() function allows to retrieve the current resampler delay in input samples for all supported resamplers. The return value is a double to maintain precision when using variable rate resamplers. Because in many places the delay is needed in usec, pa_resampler_get_delay_usec() was also supplied. The speex resampler now skips leading zero samples to provide meaningful delay values. In the next patch, the pa_resampler_prepare() function will be used to train the resampler after a rewind. It takes data from a history memblockq and runs it through the resampler. The output data is discarded. To make this logic possible, the soxr resampler had to be converted to use variable rate. The fixed rate version has a variable delay, therefore the logic above could not be applied. Additionally, with fixed rate, the delay is larger than 150ms in some situations, while with variable rate the delay is fixed and comparable to the other resamplers. Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/120>
Diffstat (limited to 'src/pulsecore/resampler.h')
-rw-r--r--src/pulsecore/resampler.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/pulsecore/resampler.h b/src/pulsecore/resampler.h
index 783f69999..e98146d85 100644
--- a/src/pulsecore/resampler.h
+++ b/src/pulsecore/resampler.h
@@ -111,6 +111,9 @@ struct pa_resampler {
pa_remap_t remap;
bool map_required;
+ double in_frames;
+ double out_frames;
+
pa_lfe_filter_t *lfe_filter;
pa_resampler_impl impl;
@@ -149,8 +152,11 @@ 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);
+/* Prepare resampler for use by running some old data through it. */
+size_t pa_resampler_prepare(pa_resampler *r, pa_memblockq *history_queue, size_t amount);
+
/* Rewind resampler */
-void pa_resampler_rewind(pa_resampler *r, size_t out_frames);
+size_t pa_resampler_rewind(pa_resampler *r, size_t out_bytes, pa_memblockq *history_queue, size_t amount);
/* Return the resampling method of the resampler object */
pa_resample_method_t pa_resampler_get_method(pa_resampler *r);
@@ -164,6 +170,12 @@ const char *pa_resample_method_to_string(pa_resample_method_t m);
/* Return 1 when the specified resampling method is supported */
int pa_resample_method_supported(pa_resample_method_t m);
+/* Get delay of the resampler in input frames */
+double pa_resampler_get_delay(pa_resampler *r, bool allow_negative);
+
+/* Get delay of the resampler in usec */
+pa_usec_t pa_resampler_get_delay_usec(pa_resampler *r);
+
const pa_channel_map* pa_resampler_input_channel_map(pa_resampler *r);
const pa_sample_spec* pa_resampler_input_sample_spec(pa_resampler *r);
const pa_channel_map* pa_resampler_output_channel_map(pa_resampler *r);