From ed024aadb6e7be6c3d910045a64db53a6c95e98f Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 5 Dec 2013 00:01:46 +0100 Subject: audio/filter: change filter callback signature The new signature is actually closer to how it actually works, and someone who is not familiar to the API and how it works might make fewer fatal mistakes with the new signature than the old one. Pretty weird. Do this to sneak in a flags parameter, which will later be used to flush remaining data of at least vf_lavfi. --- audio/filter/af.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'audio/filter/af.c') diff --git a/audio/filter/af.c b/audio/filter/af.c index d7a0086d5b..f37081c75a 100644 --- a/audio/filter/af.c +++ b/audio/filter/af.c @@ -165,9 +165,9 @@ static int output_control(struct af_instance* af, int cmd, void* arg) return AF_UNKNOWN; } -static struct mp_audio *dummy_play(struct af_instance* af, struct mp_audio* data) +static int dummy_filter(struct af_instance* af, struct mp_audio* data, int f) { - return data; + return 0; } /* Function for creating a new filter of type name.The name may @@ -592,7 +592,7 @@ struct af_stream *af_new(struct MPOpts *opts) *s->first = (struct af_instance) { .info = &in, .control = input_control, - .play = dummy_play, + .filter = dummy_filter, .priv = s, .data = &s->input, .mul = 1.0, @@ -602,7 +602,7 @@ struct af_stream *af_new(struct MPOpts *opts) *s->last = (struct af_instance) { .info = &out, .control = output_control, - .play = dummy_play, + .filter = dummy_filter, .priv = s, .data = &s->filter_output, .mul = 1.0, @@ -687,20 +687,22 @@ struct af_instance *af_add(struct af_stream *s, char *name, char **args) } /* Filter data chunk through the filters in the list. - * Warning: input (audio data and struct fields) will be overwritten. */ -struct mp_audio *af_play(struct af_stream *s, struct mp_audio *data) + * On success, *data is set to the filtered data/format. + * Warning: input audio data will be overwritten. + */ +int af_filter(struct af_stream *s, struct mp_audio *data, int flags) { struct af_instance *af = s->first; assert(mp_audio_config_equals(af->data, data)); // Iterate through all filters while (af) { - data = af->play(af, data); - if (!data) - return NULL; + int r = af->filter(af, data, flags); + if (r < 0) + return r; assert(mp_audio_config_equals(af->data, data)); af = af->next; } - return data; + return 0; } // Calculate average ratio of filter output samples to input samples. -- cgit v1.2.3