[pulseaudio-discuss] [PATCH 07/11] remap: Add (optional) state to remap struct
Peter Meerwald
pmeerw at pmeerw.net
Thu Apr 24 09:09:15 PDT 2014
From: Peter Meerwald <p.meerwald at bct-electronic.com>
State can be used by remap function implementations to
speed up the remapping, e.g. by precomputing things or
even by generating specialized code for a specific channel
remapping task
Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>
---
src/pulsecore/remap.h | 1 +
src/pulsecore/resampler.c | 9 +++++++++
2 files changed, 10 insertions(+)
diff --git a/src/pulsecore/remap.h b/src/pulsecore/remap.h
index fcfe682..3d1eec1 100644
--- a/src/pulsecore/remap.h
+++ b/src/pulsecore/remap.h
@@ -35,6 +35,7 @@ struct pa_remap {
float map_table_f[PA_CHANNELS_MAX][PA_CHANNELS_MAX];
int32_t map_table_i[PA_CHANNELS_MAX][PA_CHANNELS_MAX];
pa_do_remap_func_t do_remap;
+ void *state; /* optional state information for the remap function */
};
void pa_init_remap_func(pa_remap_t *m);
diff --git a/src/pulsecore/resampler.c b/src/pulsecore/resampler.c
index 3cbd68c..ebdce15 100644
--- a/src/pulsecore/resampler.c
+++ b/src/pulsecore/resampler.c
@@ -116,6 +116,7 @@ static int libsamplerate_init(pa_resampler*r);
#endif
static void setup_remap(const pa_resampler *r, pa_remap_t *m);
+static void free_remap(pa_remap_t *m);
static int (* const init_table[])(pa_resampler*r) = {
#ifdef HAVE_LIBSAMPLERATE
@@ -478,6 +479,8 @@ void pa_resampler_free(pa_resampler *r) {
if (r->from_work_format_buf.memblock)
pa_memblock_unref(r->from_work_format_buf.memblock);
+ free_remap(&r->remap);
+
pa_xfree(r);
}
@@ -1153,6 +1156,12 @@ static void setup_remap(const pa_resampler *r, pa_remap_t *m) {
pa_init_remap_func(m);
}
+static void free_remap(pa_remap_t *m) {
+ pa_assert(m);
+
+ pa_xfree(m->state);
+}
+
/* check if buf's memblock is large enough to hold 'len' bytes; create a
* new memblock if necessary and optionally preserve 'copy' data bytes */
static void fit_buf(pa_resampler *r, pa_memchunk *buf, size_t len, size_t *size, size_t copy) {
--
1.7.9.5
More information about the pulseaudio-discuss
mailing list