diff options
author | wm4 <wm4@nowhere> | 2013-11-18 14:18:37 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-11-18 14:21:01 +0100 |
commit | d5bc4ee79864404423ddf2786d8e8089fc46eeca (patch) | |
tree | e884a45b31ef0700af7c9bf85af72a322f4ae77c /audio/filter/af_lavrresample.c | |
parent | 5594718b6bda3a230e2e2c3cb06d2837c5a02688 (diff) | |
download | mpv-d5bc4ee79864404423ddf2786d8e8089fc46eeca.tar.bz2 mpv-d5bc4ee79864404423ddf2786d8e8089fc46eeca.tar.xz |
audio: drop buffered filter data when seeking
This could lead to (barely) audible artifacts with --af=scaletempo and
modified playback speed.
Diffstat (limited to 'audio/filter/af_lavrresample.c')
-rw-r--r-- | audio/filter/af_lavrresample.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/audio/filter/af_lavrresample.c b/audio/filter/af_lavrresample.c index f659511f82..95a5547ab5 100644 --- a/audio/filter/af_lavrresample.c +++ b/audio/filter/af_lavrresample.c @@ -93,11 +93,19 @@ static int get_delay(struct af_resample *s) { return avresample_get_delay(s->avrctx); } +static void drop_all_output(struct af_resample *s) +{ + while (avresample_read(s->avrctx, NULL, 1000) > 0) {} +} #else static int get_delay(struct af_resample *s) { return swr_get_delay(s->avrctx, s->ctx.in_rate); } +static void drop_all_output(struct af_resample *s) +{ + while (swr_drop_output(s->avrctx, 1000) > 0) {} +} #endif static double af_resample_default_cutoff(int filter_size) @@ -273,6 +281,9 @@ static int control(struct af_instance *af, int cmd, void *arg) case AF_CONTROL_SET_RESAMPLE_RATE: out->rate = *(int *)arg; return AF_OK; + case AF_CONTROL_RESET: + drop_all_output(s); + return AF_OK; } return AF_UNKNOWN; } |