mmaldec: correct package buffering accounting
authorwm4 <nfxjfg@googlemail.com>
Thu, 14 Apr 2016 10:21:21 +0000 (12:21 +0200)
committerAnton Khirnov <anton@khirnov.net>
Sat, 30 Apr 2016 06:19:58 +0000 (08:19 +0200)
The assert in ffmmal_stop_decoder() could trigger sometimes. The
packets_buffered counter was indeed not correctly maintained, and
packets were not subtracted from it if they were still in the waiting
queue.

For some reason, this happened especially with VC-1.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
libavcodec/mmaldec.c

index 6015e54..77838dc 100644 (file)
@@ -161,6 +161,9 @@ static void ffmmal_stop_decoder(AVCodecContext *avctx)
 
         ctx->waiting_buffers = buffer->next;
 
+        if (buffer->flags & MMAL_BUFFER_HEADER_FLAG_FRAME_END)
+            avpriv_atomic_int_add_and_fetch(&ctx->packets_buffered, -1);
+
         av_buffer_unref(&buffer->ref);
         av_free(buffer);
     }