From 74a73752c2c04c700afda58483347efb33f24769 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 15 Jun 2015 14:33:07 +0200 Subject: af: fix an aspect of filter chain flushing Even if we flush the current filter, we have to read the remaining output from the frame we previously fed to the filter. --- audio/filter/af.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'audio/filter') diff --git a/audio/filter/af.c b/audio/filter/af.c index 21cf866ca3..67083c493b 100644 --- a/audio/filter/af.c +++ b/audio/filter/af.c @@ -832,6 +832,16 @@ static struct mp_audio *af_dequeue_output_frame(struct af_instance *af) return res; } +static void read_remaining(struct af_instance *af) +{ + int num_frames; + do { + num_frames = af->num_out_queued; + if (!af->filter_out || af->filter_out(af) < 0) + break; + } while (num_frames != af->num_out_queued); +} + static int af_do_filter(struct af_instance *af, struct mp_audio *frame) { if (frame) @@ -871,6 +881,7 @@ int af_output_frame(struct af_stream *s, bool eof) // Flush remaining frames on EOF, but do that only if the previous // filters have been flushed (i.e. they have no more output). if (eof && !last) { + read_remaining(cur); int r = af_do_filter(cur, NULL); if (r < 0) return r; -- cgit v1.2.3