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

Olivier Guilyardi list
Fri Feb 27 20:43:33 CET 2009

M?ns Rullg?rd wrote:
> Olivier Guilyardi <list at samalyse.com> writes:
>> Reimar D?ffinger wrote:
>>> On Fri, Feb 27, 2009 at 06:58:55PM +0100, Olivier Guilyardi wrote:
>>>> +jack_demuxer_extralibs="-ljack -lpthread -lrt"
>>> just -ljack works just fine for MPlayer...
>> Okay, corrected.
>>>> +#define _BSD_SOURCE 1
>>> what exactly is that one needed for?
>> It's for usleep() from unistd.h. For some reason, it doesn't work if
>> I add it right above #include <unistd.h>
> What do you need usleep() for?  Sleeping in an input handler smells of
> bad design.

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.

This emulates a blocking read. Both the oss and alsa demuxers perform blocking
reads AFAICS, but there's no such thing in JACK. It has to be emulated.

Or should I return an empty packet if the ringbuffer is empty ? I did that at
first, but changed it for some reason I can't remember. I just remember that
audio_read_packet() was called a lot, and thus returned a lot of empty packets.


More information about the ffmpeg-devel mailing list