Commit 1ffb6456 authored by Anton Khirnov's avatar Anton Khirnov

af_resample: fix request_frame() behavior.

Make sure that an output frame has really been produced before returning
0.
parent 6f834293
...@@ -38,6 +38,9 @@ typedef struct ResampleContext { ...@@ -38,6 +38,9 @@ typedef struct ResampleContext {
AVAudioResampleContext *avr; AVAudioResampleContext *avr;
int64_t next_pts; int64_t next_pts;
/* set by filter_samples() to signal an output frame to request_frame() */
int got_output;
} ResampleContext; } ResampleContext;
static av_cold void uninit(AVFilterContext *ctx) static av_cold void uninit(AVFilterContext *ctx)
...@@ -124,7 +127,11 @@ static int request_frame(AVFilterLink *outlink) ...@@ -124,7 +127,11 @@ static int request_frame(AVFilterLink *outlink)
{ {
AVFilterContext *ctx = outlink->src; AVFilterContext *ctx = outlink->src;
ResampleContext *s = ctx->priv; 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 */ /* flush the lavr delay buffer */
if (ret == AVERROR_EOF && s->avr) { if (ret == AVERROR_EOF && s->avr) {
...@@ -203,10 +210,13 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf) ...@@ -203,10 +210,13 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf)
s->next_pts = buf_out->pts + buf_out->audio->nb_samples; s->next_pts = buf_out->pts + buf_out->audio->nb_samples;
ff_filter_samples(outlink, buf_out); ff_filter_samples(outlink, buf_out);
s->got_output = 1;
} }
avfilter_unref_buffer(buf); avfilter_unref_buffer(buf);
} else } else {
ff_filter_samples(outlink, buf); ff_filter_samples(outlink, buf);
s->got_output = 1;
}
} }
AVFilter avfilter_af_resample = { AVFilter avfilter_af_resample = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment