[LAU] Linux audio app design: The nature of xruns

Dominic Sacré dominic.sacre at gmx.de
Mon Dec 28 10:00:04 EST 2009


On Monday 28 of December 2009 13:24:24 lanas wrote:
>   Third, same song w/o xruns.  I terminate jackmix and Qarecord
> and launch Ardour.  I run all outputs into Ardour, and run the
> electric guitar as well.  Add some Freeverb and MultiEQ.  Record.
> No xruns at all in the resulting .wav file.

I don't know about Qarecord, but unfortunately JackMix is an example of 
a JACK app that does not "follow the rules".

>   My question is, is there a guide/HOWTO around that addresses
> the proper design of audio/jack applications or, is - in 2009 -
> the only to know about that is by actually going through the source
> code of successful Linux audio/jack applications ?

The rules are quite simple, but in many cases not exactly easy to 
implement.

Inside the JACK process callback, you may not call anything that might 
block, i.e. that might suspend the calling thread indefinitely. That 
includes:
- memory allocations (and deallocations)
- waiting for mutexes etc.
- file IO, printing to the console, etc.

The main difficulty lies in the fact that these things are often hidden 
deep inside some library code. So you should either verify that a 
function is safe to use in realtime code, or avoid using it in this 
context.

As for common solutions to these problems, the link to the previous 
thread David posted should be a good start.


Dominic



More information about the Linux-audio-user mailing list