[FFmpeg-devel] [PATCH] Yield on AVERROR(EAGAIN).

Nicolas George nicolas.george
Fri Mar 5 14:13:44 CET 2010


Hi.

Le quartidi 14 vent?se, an CCXVIII, Ramiro Polla a ?crit?:
>          ret = av_read_frame_internal(ic, &pkt1);
> -        if(ret == AVERROR(EAGAIN))
> +        if(ret == AVERROR(EAGAIN)) {
> +            ff_yield();
>              continue;
> +        }

What gain do you expect from that code, be it the current or modified
version?

Reading from a source in a non-blocking way makes sense if we do something
else, something useful, when there is no data available. If we just run
around waiting for more data, that is useless, whether it eats CPU or not:
just put the source in blocking mode and be done with it.

Handling non-blocking sources requires a drastic change in the main loop of
a program. Currently, the main loop of ffmpeg decides from what stream it
wants to read and then reads from it. To handle non-blocking sources, it
must be changed to read from whatever stream data is available, and cope
with it.

In the particular case of ffmpeg, this is made more difficult by the fact
that some sources (streams decoded from files and not from devices) always
return data without blocking. The scheduling may become quite complex.

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100305/9d8ad1d3/attachment.pgp>



More information about the ffmpeg-devel mailing list