summaryrefslogtreecommitdiffstats
path: root/audio/filter/af_hrtf.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-11-10 23:20:06 +0100
committerwm4 <wm4@nowhere>2013-11-12 23:27:03 +0100
commitd115fb3b0eed9145817a20bc0070590f7428bddd (patch)
tree00aab1420c5ab64f77b777214b92ba51793ea589 /audio/filter/af_hrtf.c
parente763d528e2b9370521b1e28450f48e65af33ca7f (diff)
downloadmpv-d115fb3b0eed9145817a20bc0070590f7428bddd.tar.bz2
mpv-d115fb3b0eed9145817a20bc0070590f7428bddd.tar.xz
af: don't require filters to allocate af_instance->data, redo buffers
Allocate af_instance->data in generic code before filter initialization. Every filter needs af->data (since it contains the output configuration), so there's no reason why every filter should allocate and free it. Remove RESIZE_LOCAL_BUFFER(), and replace it with mp_audio_realloc_min(). Interestingly, most code becomes simpler, because the new function takes the size in samples, and not in bytes. There are larger change in af_scaletempo.c and af_lavcac3enc.c, because these had copied and modified versions of the RESIZE_LOCAL_BUFFER macro/function.
Diffstat (limited to 'audio/filter/af_hrtf.c')
-rw-r--r--audio/filter/af_hrtf.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/audio/filter/af_hrtf.c b/audio/filter/af_hrtf.c
index 01148dc6a6..a0dbb12675 100644
--- a/audio/filter/af_hrtf.c
+++ b/audio/filter/af_hrtf.c
@@ -366,9 +366,6 @@ static void uninit(struct af_instance *af)
free(s->fwrbuf_rr);
free(af->setup);
}
- if(af->data)
- free(af->data->planes[0]);
- free(af->data);
}
/* Filter data through filter
@@ -391,8 +388,7 @@ static struct mp_audio* play(struct af_instance *af, struct mp_audio *data)
float common, left, right, diff, left_b, right_b;
const int dblen = s->dlbuflen, hlen = s->hrflen, blen = s->basslen;
- if(AF_OK != RESIZE_LOCAL_BUFFER(af, data))
- return NULL;
+ mp_audio_realloc_min(af->data, data->samples);
if(s->print_flag) {
s->print_flag = 0;
@@ -603,9 +599,8 @@ static int af_open(struct af_instance* af)
af->uninit = uninit;
af->play = play;
af->mul = 1;
- af->data = calloc(1, sizeof(struct mp_audio));
af->setup = calloc(1, sizeof(af_hrtf_t));
- if((af->data == NULL) || (af->setup == NULL))
+ if(af->setup == NULL)
return AF_ERROR;
s = af->setup;