From 87fe7d878843688a0f530fc9ce5a1a0775c77b9e Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 15 Jan 2015 20:10:52 +0100 Subject: audio/filter: switch remaining in-place filters to refcounting Adds about 7 lines of boilerplate per filter. This could be avoided by providing a different entrypoint (something like af->filter_inplace), which would basically mirror the old interface exactly for this kind of filter. But I feel like it would just be a hack to support all those old, useless filters better. (The ideal solution would be using a language that can do closures to provide a compat. wrapper, but whatever.) af_bs2b has terribly repetitious code for setting up filter functions for each format (most of them useless, in addition to bs2b being useless), so I did something terrible with macros. af_sinesuppress had commented code for float filtering (maybe it was broken; it has been commented every since it was added in 2006). Remove this code. --- audio/filter/af_center.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'audio/filter/af_center.c') diff --git a/audio/filter/af_center.c b/audio/filter/af_center.c index 3039e50302..ff2a37dee9 100644 --- a/audio/filter/af_center.c +++ b/audio/filter/af_center.c @@ -58,9 +58,14 @@ static int control(struct af_instance* af, int cmd, void* arg) return AF_UNKNOWN; } -// Filter data through filter -static int filter(struct af_instance* af, struct mp_audio* data, int flags) +static int filter_frame(struct af_instance* af, struct mp_audio* data) { + if (!data) + return 0; + if (af_make_writeable(af, data) < 0) { + talloc_free(data); + return -1; + } struct mp_audio* c = data; // Current working data af_center_t* s = af->priv; // Setup for this instance float* a = c->planes[0]; // Audio data @@ -75,13 +80,14 @@ static int filter(struct af_instance* af, struct mp_audio* data, int flags) a[i+ch] = (a[i]/2) + (a[i+1]/2); } + af_add_output_frame(af, data); return 0; } // Allocate memory and set function pointers static int af_open(struct af_instance* af){ af->control=control; - af->filter=filter; + af->filter_frame = filter_frame; return AF_OK; } -- cgit v1.2.3