{
AVFilterLink *link = ctx->outputs[0];
FifoContext *s = ctx->priv;
- AVFrame *head = s->root.next->frame;
+ AVFrame *head = s->root.next ? s->root.next->frame : NULL;
AVFrame *out;
int ret;
+ /* if head is NULL then we're flushing the remaining samples in out */
+ if (!head && !s->out)
+ return AVERROR_EOF;
+
if (!s->out &&
head->nb_samples >= link->request_samples &&
calc_ptr_alignment(head) >= 32) {
int ret = 0;
if (!fifo->root.next) {
- if ((ret = ff_request_frame(outlink->src->inputs[0])) < 0)
+ if ((ret = ff_request_frame(outlink->src->inputs[0])) < 0) {
+ if (ret == AVERROR_EOF && outlink->request_samples)
+ return return_audio_frame(outlink->src);
return ret;
+ }
}
if (outlink->request_samples) {