diff options
Diffstat (limited to 'audio/filter')
-rw-r--r-- | audio/filter/af.c | 17 | ||||
-rw-r--r-- | audio/filter/af.h | 3 |
2 files changed, 12 insertions, 8 deletions
diff --git a/audio/filter/af.c b/audio/filter/af.c index 2889e87bb7..48f6d58868 100644 --- a/audio/filter/af.c +++ b/audio/filter/af.c @@ -689,8 +689,14 @@ int af_init(struct af_stream *s) to the stream s. The filter will be inserted somewhere nice in the list of filters. The return value is a pointer to the new filter, If the filter couldn't be added the return value is NULL. */ -struct af_instance *af_add(struct af_stream *s, char *name, char **args) +struct af_instance *af_add(struct af_stream *s, char *name, char *label, + char **args) { + assert(label); + + if (af_find_by_label(s, label)) + return NULL; + struct af_instance *new; // Insert the filter somewhere nice if (af_is_conversion_filter(s->first->next)) @@ -699,17 +705,14 @@ struct af_instance *af_add(struct af_stream *s, char *name, char **args) new = af_prepend(s, s->first->next, name, args); if (!new) return NULL; + new->label = talloc_strdup(new, label); // Reinitalize the filter list if (af_reinit(s) != AF_OK) { - af_remove(s, new); - if (af_reinit(s) != AF_OK) { - af_uninit(s); - af_init(s); - } + af_remove_by_label(s, label); return NULL; } - return new; + return af_find_by_label(s, label); } struct af_instance *af_find_by_label(struct af_stream *s, char *label) diff --git a/audio/filter/af.h b/audio/filter/af.h index 4c67208123..65a30f7dd1 100644 --- a/audio/filter/af.h +++ b/audio/filter/af.h @@ -141,7 +141,8 @@ struct af_stream *af_new(struct mpv_global *global); void af_destroy(struct af_stream *s); int af_init(struct af_stream *s); void af_uninit(struct af_stream *s); -struct af_instance *af_add(struct af_stream *s, char *name, char **args); +struct af_instance *af_add(struct af_stream *s, char *name, char *label, + char **args); int af_remove_by_label(struct af_stream *s, char *label); struct af_instance *af_find_by_label(struct af_stream *s, char *label); struct af_instance *af_control_any_rev(struct af_stream *s, int cmd, void *arg); |