[FFmpeg-devel] Network IO in FFmpeg (was: abstractable threading api)

Nicolas George george at nsup.org
Thu Apr 10 16:48:25 CEST 2014

L'octidi 18 germinal, an CCXXII, Roger Pack a écrit :
> I did notice that at least these people:
> http://forum.xda-developers.com/showthread.php?t=2654753
> Basically added a call to select in their code, to avoid having to
> cancel the thread.  FWIW :)

That is almost exactly the code as it was before pthread_cancel() was used.
This ugly because the cancellation is passed through a shared flag that is
not integrated into the select() call and therefore must be polled at
regular interval. That means a long latency to actually cancel the thread,
and useless wake-ups.

The wake-ups are bad for battery life on embedded devices. The long latency
can cause actual problems if the application wants to stop a socket and then
start it again on the same port: if the thread is not cancelled yet, it will
fail due to the port being still in use. With regular polling, the race
condition is very likely to trigger.


  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140410/85c6d948/attachment.asc>

More information about the ffmpeg-devel mailing list