summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-06-15 14:33:07 +0200
committerwm4 <wm4@nowhere>2015-06-15 14:33:07 +0200
commit74a73752c2c04c700afda58483347efb33f24769 (patch)
tree64cb995f69d2302252e9cdb4ea36fcb0de69db1f
parent5eae20fc0f2387dfffe276e64e1132e7ad8093a9 (diff)
downloadmpv-74a73752c2c04c700afda58483347efb33f24769.tar.bz2
mpv-74a73752c2c04c700afda58483347efb33f24769.tar.xz
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.
-rw-r--r--audio/filter/af.c11
1 files changed, 11 insertions, 0 deletions
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;