lavfi/af_amix: make sure the output does not depend on input ordering

Signed-off-by: Anton Khirnov <anton@khirnov.net>
release/7.0
Paul B Mahol 1 year ago committed by Anton Khirnov
parent de85815bfa
commit 7282137f48
  1. 13
      libavfilter/af_amix.c

@ -394,6 +394,8 @@ static int request_samples(AVFilterContext *ctx, int min_samples)
int i;
av_assert0(s->nb_inputs > 1);
if (min_samples == 1 && s->duration_mode == DURATION_FIRST)
min_samples = av_audio_fifo_size(s->fifos[0]);
for (i = 1; i < s->nb_inputs; i++) {
if (!(s->input_state[i] & INPUT_ON) ||
@ -402,6 +404,7 @@ static int request_samples(AVFilterContext *ctx, int min_samples)
if (av_audio_fifo_size(s->fifos[i]) >= min_samples)
continue;
ff_inlink_request_frame(ctx->inputs[i]);
return 0;
}
return output_frame(ctx->outputs[0]);
}
@ -471,17 +474,13 @@ static int activate(AVFilterContext *ctx)
if (ff_inlink_acknowledge_status(ctx->inputs[i], &status, &pts)) {
if (status == AVERROR_EOF) {
if (i == 0) {
s->input_state[i] = 0;
s->input_state[i] |= INPUT_EOF;
if (av_audio_fifo_size(s->fifos[i]) == 0) {
s->input_state[i] &= ~INPUT_ON;
if (s->nb_inputs == 1) {
ff_outlink_set_status(outlink, status, pts);
return 0;
}
} else {
s->input_state[i] |= INPUT_EOF;
if (av_audio_fifo_size(s->fifos[i]) == 0) {
s->input_state[i] = 0;
}
}
}
}

Loading…
Cancel
Save