lavfi: fix EOF case

This was dumb. Could make it burn 100% CPU and not exit at the end.
(Because it would retry as instructed, instead of terminating playback.)

It also needs to consider EOF as waiting for input. lavfi_process() will
decide if it's really EOF, or if further input might come in the future.
Without this, it'd would think that it does not need to wait for input,
i.e. that new input will be available immediately.

(Not so fond of the duplication of subtle logic.)
This commit is contained in:
wm4 2016-02-06 18:47:43 +01:00
parent a0d3ce4819
commit 563b4785da
1 changed files with 4 additions and 3 deletions

View File

@ -508,8 +508,9 @@ static void feed_input_pads(struct lavfi *c)
MP_FATAL(c, "could not pass frame to filter\n");
av_frame_free(&frame);
pad->input_waiting = pad->input_again = false;
pad->input_again = false;
pad->input_eof = eof;
pad->input_waiting = eof; // input _might_ come again in the future
}
}
@ -533,7 +534,7 @@ static void read_output_pads(struct lavfi *c)
assert(pad->buffer);
assert(!pad->pending_v && !pad->pending_a);
int r = AVERROR(EAGAIN);
int r = AVERROR_EOF;
if (!pad->buffer_is_eof)
r = av_buffersink_get_frame(pad->buffer, pad->tmp_frame);
if (r >= 0) {
@ -690,7 +691,7 @@ void lavfi_send_status(struct lavfi_pad *pad, int status)
assert(status != DATA_OK);
assert(!pad->pending_v && !pad->pending_a);
pad->input_waiting = status == DATA_WAIT;
pad->input_waiting = status == DATA_WAIT || status == DATA_EOF;
pad->input_again = status == DATA_AGAIN;
pad->input_eof = status == DATA_EOF;
}