From 983f5efa3c3dfb8d8b36d48249cff11154b17fa3 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 13 Jan 2015 20:16:10 +0100 Subject: audio/filters: use refcounted frames for some in-place filters These are also quite simple, but require requesting write access to the frames. The error handling (for OOM) is a bit annoying. --- audio/filter/af_drc.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'audio/filter/af_drc.c') diff --git a/audio/filter/af_drc.c b/audio/filter/af_drc.c index 94e161130f..2560658f45 100644 --- a/audio/filter/af_drc.c +++ b/audio/filter/af_drc.c @@ -272,10 +272,18 @@ static void method2_float(af_drc_t *s, struct mp_audio *c) s->idx = (s->idx + 1) % NSAMPLES; } -static int filter(struct af_instance* af, struct mp_audio* data, int flags) +static int filter(struct af_instance *af, struct mp_audio *data) { af_drc_t *s = af->priv; + if (!data) + return 0; + + if (af_make_writeable(af, data) < 0) { + talloc_free(data); + return -1; + } + if(af->data->format == (AF_FORMAT_S16)) { if (s->method == 2) @@ -290,6 +298,7 @@ static int filter(struct af_instance* af, struct mp_audio* data, int flags) else method1_float(s, data); } + af_add_output_frame(af, data); return 0; } @@ -297,7 +306,7 @@ static int filter(struct af_instance* af, struct mp_audio* data, int flags) static int af_open(struct af_instance* af){ int i = 0; af->control=control; - af->filter=filter; + af->filter_frame = filter; af_drc_t *priv = af->priv; priv->mul = MUL_INIT; -- cgit v1.2.3