[FFmpeg-devel] [PATCH] ffprobe: do not exit in case the demuxer returns AVERROR(EAGAIN)

Nicolas George george at nsup.org
Wed Nov 18 15:21:15 CET 2015


Le septidi 27 brumaire, an CCXXIV, Stefano Sabatini a écrit :
> Fix demuxing of files for which the demuxer returns AVERROR(EAGAIN) at
> some point. Also returns error code to the caller in case of different
> non EOF error.
> ---
>  ffprobe.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/ffprobe.c b/ffprobe.c
> index c304a6d..481ff0b 100644
> --- a/ffprobe.c
> +++ b/ffprobe.c
> @@ -2027,7 +2027,16 @@ static int read_interval_packets(WriterContext *w, AVFormatContext *fmt_ctx,
>          ret = AVERROR(ENOMEM);
>          goto end;
>      }
> -    while (!av_read_frame(fmt_ctx, &pkt)) {

> +    while (1) {
> +        ret = av_read_frame(fmt_ctx, &pkt);
> +        if (ret == AVERROR(EAGAIN))
> +            continue;

This is a busy wait, this is one of the evilest constructions possible.

For real EAGAIN cases, a sleep would be needed, until we have a real event
loop. Other cases are bugs in the demuxers.

> +        if (ret < 0) {
> +            if (ret == AVERROR_EOF)
> +                ret = 0;
> +            break;
> +        }
> +
>          if (fmt_ctx->nb_streams > nb_streams) {
>              REALLOCZ_ARRAY_STREAM(nb_streams_frames,  nb_streams, fmt_ctx->nb_streams);
>              REALLOCZ_ARRAY_STREAM(nb_streams_packets, nb_streams, fmt_ctx->nb_streams);

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20151118/5976d893/attachment.sig>


More information about the ffmpeg-devel mailing list