[vlc-devel] [PATCH] avcodec: check return of avcodec_send_packet/avcodec_receive_frame

Thomas Guillem thomas at gllm.fr
Wed Sep 7 12:36:00 CEST 2016


Don't treat EAGAIN as an error
---
 modules/codec/avcodec/video.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index f236224..dd35dff 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -833,11 +833,23 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
             p_block->i_dts = VLC_TS_INVALID;
         }
 
-        int not_able_to_send_packet = avcodec_send_packet( p_context, &pkt );
+        int ret = avcodec_send_packet( p_context, &pkt );
         i_used = pkt.size;
         av_packet_unref( &pkt );
 
-        int not_received_frame = avcodec_receive_frame( p_context, frame);
+        if( ret != 0 && ret != AVERROR(EAGAIN) )
+        {
+            p_dec->b_error = true;
+            break;
+        }
+
+        ret = avcodec_receive_frame( p_context, frame);
+        if( ret != 0 && ret != AVERROR(EAGAIN) )
+        {
+            p_dec->b_error = true;
+            break;
+        }
+        int not_received_frame = ret;
 
         wait_mt( p_sys );
 
-- 
2.9.3



More information about the vlc-devel mailing list