[FFmpeg-devel] [PATCH] libavdevice: JACK demuxer

Olivier Guilyardi list
Fri Feb 27 21:26:40 CET 2009


M?ns Rullg?rd wrote:
> Olivier Guilyardi <list at samalyse.com> writes:
> 
>> The jack process callback, which runs in the JACK realtime thread,
>> reads audio from JACK. It then places this data into a ringbuffer,
>> for the audio_read_packet() callback to fetch it, and return it in a
>> AVPacket. It the ringbuffer is empty at this point,
>> audio_read_packet() sleeps a period, tries again, etc.... It times
>> out after 2 seconds.
> 
> As I said, bad design.  The proper solution is to use a condition
> variable.

It is not just "bad design". In realtime there is a *lot* of traditional IPC
mechanisms, and other system calls (malloc, etc..) that you just can't use,
because they might block, and crash everything.

So, when I work in the process callback, I adopt a conservative
no-mutex-no-semaphore-no-pthread-things-etc approach. However, I've read that a
few of these are realtime safe.

I need to check whether pthread_cond_signal() is realtime safe or not. I'm gonna
ask on jack-devel.

Btw, what's wrong with sleeping? If Jack is still running, it is very likely to
sleep only once before some data gets available.

--
  Olivier




More information about the ffmpeg-devel mailing list