summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Meerwald <p.meerwald@bct-electronic.com>2014-04-16 15:00:45 +0200
committerPeter Meerwald <pmeerw@pmeerw.net>2014-04-29 00:00:06 +0200
commite92e8b11f1f3b8c3af232388a52bbd06dbaaae7f (patch)
tree3d0b9e0d0342ed58b274751e8db269bf9360a840
parent877ad8dcf8d3997f65ffe8ac4f544f6bdd8952e7 (diff)
remap: Add (optional) state to remap struct
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@pmeerw.net>
-rw-r--r--src/pulsecore/remap.h1
-rw-r--r--src/pulsecore/resampler.c9
2 files changed, 10 insertions, 0 deletions
diff --git a/src/pulsecore/remap.h b/src/pulsecore/remap.h
index 157f974e4..66ab7bca3 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 473cbd3c6..1153281ca 100644
--- a/src/pulsecore/resampler.c
+++ b/src/pulsecore/resampler.c
@@ -115,6 +115,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
@@ -477,6 +478,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);
}
@@ -1152,6 +1155,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) {