diff options
author | wm4 <wm4@nowhere> | 2015-04-07 21:23:23 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-04-07 21:24:22 +0200 |
commit | 579c4dac34546357a5fd1dfd67712df6a5930bf6 (patch) | |
tree | 917ea7531726635db21fb5c327f13acfd8352368 /player/audio.c | |
parent | e98ab5e596b003b68e44e8c94b5e393e52ed6b6b (diff) | |
download | mpv-579c4dac34546357a5fd1dfd67712df6a5930bf6.tar.bz2 mpv-579c4dac34546357a5fd1dfd67712df6a5930bf6.tar.xz |
audio: change a detail about filter insertion
The af_add() function has a problem: if the inserted filter returns
AF_DETACH during init, the function will have a dangling pointer. Until
now this was avoided by making sure none of the used filters actually
return AF_DETACH, but it's getting infeasible.
Solve this by requiring passing an unique label to af_add(), which is
then used instead of the pointer.
Diffstat (limited to 'player/audio.c')
-rw-r--r-- | player/audio.c | 19 |
1 files changed, 1 insertions, 18 deletions
diff --git a/player/audio.c b/player/audio.c index f4c69803a4..6f91f8ee32 100644 --- a/player/audio.c +++ b/player/audio.c @@ -43,23 +43,6 @@ #include "core.h" #include "command.h" -static int try_filter(struct MPContext *mpctx, - char *name, char *label, char **args) -{ - struct dec_audio *d_audio = mpctx->d_audio; - - if (af_find_by_label(d_audio->afilter, label)) - return 0; - - struct af_instance *af = af_add(d_audio->afilter, name, args); - if (!af) - return -1; - - af->label = talloc_strdup(af, label); - - return 1; -} - static int update_playback_speed_filters(struct MPContext *mpctx) { struct MPOpts *opts = mpctx->opts; @@ -90,7 +73,7 @@ static int update_playback_speed_filters(struct MPContext *mpctx) char *filter = method == AF_CONTROL_SET_PLAYBACK_SPEED ? "scaletempo" : "lavrresample"; - if (try_filter(mpctx, filter, "playback-speed", NULL) < 0) + if (af_add(afs, filter, "playback-speed", NULL) < 0) return -1; // Try again. if (!af_control_any_rev(afs, method, &speed)) |