If any samples are still buffered when request_frame returns EOF, they
won't be returned currently.
... | ... |
@@ -147,10 +147,14 @@ static int return_audio_frame(AVFilterContext *ctx) |
147 | 147 |
{ |
148 | 148 |
AVFilterLink *link = ctx->outputs[0]; |
149 | 149 |
FifoContext *s = ctx->priv; |
150 |
- AVFrame *head = s->root.next->frame; |
|
150 |
+ AVFrame *head = s->root.next ? s->root.next->frame : NULL; |
|
151 | 151 |
AVFrame *out; |
152 | 152 |
int ret; |
153 | 153 |
|
154 |
+ /* if head is NULL then we're flushing the remaining samples in out */ |
|
155 |
+ if (!head && !s->out) |
|
156 |
+ return AVERROR_EOF; |
|
157 |
+ |
|
154 | 158 |
if (!s->out && |
155 | 159 |
head->nb_samples >= link->request_samples && |
156 | 160 |
calc_ptr_alignment(head) >= 32) { |
... | ... |
@@ -227,8 +231,11 @@ static int request_frame(AVFilterLink *outlink) |
227 | 227 |
int ret = 0; |
228 | 228 |
|
229 | 229 |
if (!fifo->root.next) { |
230 |
- if ((ret = ff_request_frame(outlink->src->inputs[0])) < 0) |
|
230 |
+ if ((ret = ff_request_frame(outlink->src->inputs[0])) < 0) { |
|
231 |
+ if (ret == AVERROR_EOF && outlink->request_samples) |
|
232 |
+ return return_audio_frame(outlink->src); |
|
231 | 233 |
return ret; |
234 |
+ } |
|
232 | 235 |
} |
233 | 236 |
|
234 | 237 |
if (outlink->request_samples) { |