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

Nicolas George nicolas.george
Fri Mar 5 17:27:59 CET 2010


Le quintidi 15 vent?se, an CCXVIII, Ramiro Polla a ?crit?:
> CPU usage.

The best way to reduce the CPU usage is to put the device in blocking mode
and let the kernel wake us up just when there is data.

> If we could toggle nonblock after the device has been init'ed, yes
> that would be better.

Ah, I think I see your exact problem. Correct me if I am wrong:

You set AVFMT_FLAG_NONBLOCK when opening the device to get "Device or
resource busy" instead of being stuck, and then you can not set the device
back in blocking mode to actually use it.

Is that it?

In that case, the proper solution would be to separate the blocking status
of the opening from the blocking status of the reading (this sentence is
awful).

I see three solutions to do that:

A. Add AVFMT_FLAG_NONBLOCK_OPEN: if this flag is set, open fails with
   "device busy", if it is not, open blocks.

B. Same as A, but reverse the default: add AVFMT_FLAG_OPEN_WAIT: if this
   flag is set, open blocks, if is not, open fails with "device busy".

C. Same as B, but without the flag: open always fails with "device busy".

And of course, in all three case, once/if the device is successfully opened,
its blocking status is set according to AVFMT_FLAG_NONBLOCK.

I think B is the best option.

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/51fab76d/attachment.pgp>



More information about the ffmpeg-devel mailing list