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

Attachment: signature.asc
Description: Digital signature

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to