[vlc-devel] [PATCH 2/2] avcodec: audio: fix new API usage

Thomas Guillem thomas at gllm.fr
Wed Sep 7 13:28:52 CEST 2016


---
 modules/codec/avcodec/audio.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/modules/codec/avcodec/audio.c b/modules/codec/avcodec/audio.c
index 05d22cf..3d34f22 100644
--- a/modules/codec/avcodec/audio.c
+++ b/modules/codec/avcodec/audio.c
@@ -323,28 +323,25 @@ static block_t *DecodeAudio( decoder_t *p_dec, block_t **pp_block )
         pkt.data = p_block->p_buffer;
         pkt.size = p_block->i_buffer;
 
-        int used = avcodec_send_packet( ctx, &pkt );
-        if( used < 0 )
+        int ret = avcodec_send_packet( ctx, &pkt );
+        if( ret != 0 && ret != AVERROR(EAGAIN) )
         {
             msg_Warn( p_dec, "cannot decode one frame (%zu bytes)",
                       p_block->i_buffer );
             goto end;
         }
-        used = avcodec_receive_frame( ctx, frame );
-        got_frame = used == 0;
-        if( used < 0 )
+
+        ret = avcodec_receive_frame( ctx, frame );
+        if( ret != 0 && ret != AVERROR(EAGAIN) )
         {
             msg_Warn( p_dec, "cannot decode one frame (%zu bytes)",
                       p_block->i_buffer );
             goto end;
         }
+        got_frame = ret == 0;
 
-        assert( p_block->i_buffer >= (unsigned)used );
-        if( (unsigned)used > p_block->i_buffer )
-            used = p_block->i_buffer;
-
-        p_block->p_buffer += used;
-        p_block->i_buffer -= used;
+        p_block->p_buffer += pkt.size;
+        p_block->i_buffer -= pkt.size;
     }
 
     if( ctx->channels <= 0 || ctx->channels > 8 || ctx->sample_rate <= 0 )
-- 
2.9.3



More information about the vlc-devel mailing list