diff options
author | wm4 <wm4@nowhere> | 2015-01-15 20:10:52 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-01-15 20:13:12 +0100 |
commit | 87fe7d878843688a0f530fc9ce5a1a0775c77b9e (patch) | |
tree | 185e92cf90cb51604161243f7e02eb977a05ae1d /audio/filter/af_ladspa.c | |
parent | ba0e8b754c4282bae941aa5d30614b2a305f9f5f (diff) | |
download | mpv-87fe7d878843688a0f530fc9ce5a1a0775c77b9e.tar.bz2 mpv-87fe7d878843688a0f530fc9ce5a1a0775c77b9e.tar.xz |
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.
Diffstat (limited to 'audio/filter/af_ladspa.c')
-rw-r--r-- | audio/filter/af_ladspa.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/audio/filter/af_ladspa.c b/audio/filter/af_ladspa.c index ab76c35fe9..6a8cd802f6 100644 --- a/audio/filter/af_ladspa.c +++ b/audio/filter/af_ladspa.c @@ -565,7 +565,10 @@ static void uninit(struct af_instance *af) { * \return Either AF_ERROR or AF_OK */ -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; af_ladspa_t *setup = af->priv; const LADSPA_Descriptor *pdes = setup->plugin_descriptor; float *audio = (float*)data->planes[0]; @@ -574,8 +577,14 @@ static int filter(struct af_instance *af, struct mp_audio *data, int flags) { int rate = data->rate; int i, p; - if (setup->status !=AF_OK) + if (setup->status !=AF_OK) { + talloc_free(data); + return -1; + } + if (af_make_writeable(af, data) < 0) { + talloc_free(data); return -1; + } /* See if it's the first call. If so, setup inbufs/outbufs, instantiate * plugin, connect ports and activate plugin @@ -721,6 +730,7 @@ static int filter(struct af_instance *af, struct mp_audio *data, int flags) { /* done */ + af_add_output_frame(af, data); return 0; } @@ -737,7 +747,7 @@ static int af_open(struct af_instance *af) { af->control=control; af->uninit=uninit; - af->filter=filter; + af->filter_frame = filter_frame; af_ladspa_t *setup = af->priv; |