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>
This commit is contained in:
Peter Meerwald 2014-04-16 15:00:45 +02:00 committed by Peter Meerwald
parent 877ad8dcf8
commit e92e8b11f1
2 changed files with 10 additions and 0 deletions

View file

@ -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) {