diff options
author | Anton Khirnov <anton@khirnov.net> | 2012-07-04 16:46:17 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2012-07-09 08:21:37 +0200 |
commit | 1ffb6456629314e992e2b55dd0649f0fb975b6fa (patch) | |
tree | 6889e22916e448ca3426864cdfee49d2bf28fad2 | |
parent | 6f834293d3023153ec5d09c232ac49c3afc57baa (diff) | |
download | ffmpeg-1ffb6456629314e992e2b55dd0649f0fb975b6fa.tar.gz |
af_resample: fix request_frame() behavior.
Make sure that an output frame has really been produced before returning
0.
-rw-r--r-- | libavfilter/af_resample.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/libavfilter/af_resample.c b/libavfilter/af_resample.c index b62a374fd6..8fbe60b2cf 100644 --- a/libavfilter/af_resample.c +++ b/libavfilter/af_resample.c @@ -38,6 +38,9 @@ typedef struct ResampleContext { AVAudioResampleContext *avr; int64_t next_pts; + + /* set by filter_samples() to signal an output frame to request_frame() */ + int got_output; } ResampleContext; static av_cold void uninit(AVFilterContext *ctx) @@ -124,7 +127,11 @@ static int request_frame(AVFilterLink *outlink) { AVFilterContext *ctx = outlink->src; ResampleContext *s = ctx->priv; - int ret = ff_request_frame(ctx->inputs[0]); + int ret = 0; + + s->got_output = 0; + while (ret >= 0 && !s->got_output) + ret = ff_request_frame(ctx->inputs[0]); /* flush the lavr delay buffer */ if (ret == AVERROR_EOF && s->avr) { @@ -203,10 +210,13 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf) s->next_pts = buf_out->pts + buf_out->audio->nb_samples; ff_filter_samples(outlink, buf_out); + s->got_output = 1; } avfilter_unref_buffer(buf); - } else + } else { ff_filter_samples(outlink, buf); + s->got_output = 1; + } } AVFilter avfilter_af_resample = { |