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

Sean McGovern gseanmcg at gmail.com
Wed Sep 7 14:27:35 CEST 2016


On Sep 7, 2016 12:36, "Thomas Guillem" <thomas at gllm.fr> wrote:
>
> 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 );
>

Notwithstanding RĂ©mi's concerns, would this be better written as a while()
loop, on the off chance EAGAIN is returned more than once?

-- Sean McG.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20160907/9a487e42/attachment.html>


More information about the vlc-devel mailing list