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

Thomas Guillem thomas at gllm.fr
Wed Sep 7 15:51:26 CEST 2016




On Wed, Sep 7, 2016, at 14:27, Sean McGovern wrote:
>
>
> 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?

We are already in a while loop,  I think this is well handled.

>
> -- Sean McG.
>
> _________________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20160907/1272861d/attachment.html>


More information about the vlc-devel mailing list