[LAD] Some questions about the Jack callback

Paul Davis paul at linuxaudiosystems.com
Sun Sep 21 20:51:26 UTC 2014

On Sun, Sep 21, 2014 at 4:31 PM, Will Godfrey <willgodfrey at musically.me.uk>

> ually...
> This might seem a bit obvious, but am I right in thinking that while jack
> collects the current inputs it is at the same time pushing out the
> *previous*
> bufferful of data - hence latency.

you're wrong. sort of.

the simplest way to think about this is with the double buffered model that
ASIO enforces, which in ALSA is equivalent to 2 periods.

while the audio interface is (playing|capturing) one buffer/period, JACK is
(collecting|delivering) data for the other. when the audio interface is
finished, we flip so that the h/w is now working with the buffer/period's
worth data that JACK just finished with (i.e. either playing it or
refilling the capture part), and meanwhile JACK is again
(collecting|delivering) data to its clients. and on and on it goes.

thus, if JACK is not done (collecting|delivering) data by the time the
audio interface is ready to flip ... xrun.

the latency comes from the fact that in a block-structured handling model
like this, the output played by the audio interface can under NO
circumstances ever be based on anything earlier than the previous
buffer/period. audio data that arrives at the audio interface will get
delivered to JACK at some point in the future, JACK clients will do
something with it (e.g. playing it back as-is) and then 1 buffer/period
after it became available to JACK (and its clients), it is available to the
audio interface to playback again.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxaudio.org/pipermail/linux-audio-dev/attachments/20140921/81e92e6d/attachment.html>

More information about the Linux-audio-dev mailing list