summaryrefslogtreecommitdiffstats
path: root/audio/filter/af.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-12-05 00:01:46 +0100
committerwm4 <wm4@nowhere>2013-12-05 00:01:46 +0100
commited024aadb6e7be6c3d910045a64db53a6c95e98f (patch)
treef26724d268e13ee8ec8f327ea829b65ccd6fab19 /audio/filter/af.c
parent2bcfb49a390a928c535cba7cab2b4136f27fceca (diff)
downloadmpv-ed024aadb6e7be6c3d910045a64db53a6c95e98f.tar.bz2
mpv-ed024aadb6e7be6c3d910045a64db53a6c95e98f.tar.xz
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.
Diffstat (limited to 'audio/filter/af.c')
-rw-r--r--audio/filter/af.c22
1 files changed, 12 insertions, 10 deletions
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.