Browse code

Merge commit '3799376dd3373ee255651ed542c75b15665801a8'

* commit '3799376dd3373ee255651ed542c75b15665801a8':
lavfi/fifo: fix flushing when using request_samples

Conflicts:
libavfilter/fifo.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2013/08/06 16:35:03
Showing 1 changed files
... ...
@@ -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
         av_assert0(fifo->root.next);
233 236
     }
234 237