Subject: Re: [linux-audio-dev] buffering, latency, cut-outs
From: Benno Senoner (sbenno_AT_gardena.net)
Date: la tammi 15 2000 - 09:46:49 EST
Hi,
sorry for the late response ,
to get true dropout-free, realtime-response ( <5-10ms latency = BeOS-like
performance) you have to fulfill the following conditions:
- run a low-latency enabled kernel ( meanwhile 2.2.10 + N6B patch is reported to
work best, Ingo will soon release a 2.2.13 and a 2.3.x version)
(meanwhile see my audio page for infos and read the latencytest README
carefully)
- if you have IDE disks they MUST run with DMA enabled
- your realtime app must be designed in a such way that
the audio thread does ONLY audio I/O that means
ie:
while(1)
{
read from /dev/dsp
do computations, read/write from/to shared mem (or use threads to share
memory)
write to /dev/dsp
}
any other syscall is FORBIDDEN ! , no disk I/O inside the audio thread,
no GTK / X11 calls etc.
you may use msgsnd() / msgget() in order to exchange data with the GUI thread.
I would avoid the use of FIFOs pipe() , because the GUI thread could stall and
if the fifo gets full, the audio thread could block = dropout assured.
- ONLY the audio I/O thread and if you do MIDI , the MIDI thread too, MUST run
SCHED_FIFO
without SCHED_FIFO you will not get reliable low-latency
- all other threads should run with normal scheduling policy so that if the
audio/midi thread needs the CPU, it will get the processing power even if you
do heavy disk I/O or heavy CPU work in the background.
- disable apm (boot your kernel with apm=off) , on some of my machines
APM ruins the latencies , during apm polling.
take care when working with mutexes, design the audio realtime thread in a such
way that it will never "wait" on events, use
shared memory and poll flags/messages at each iteration within the audio-loop.
(or alternatively use non-blocking message queues msgsnd() , msgrvc() )
If you meet ALL these conditions , you will get a rock-solid realtime behavior,
where a Windoze user can only dream of.
( for example all latencytest benchmarks were run with a mere 4x128 bytes
buffer, =512bytes total, and NO dropouts occured).
hope this helps,
Benno.
-- Benno Senoner E-Mail: sbenno_AT_gardena.net Linux low-latency audio / scheduling latency benchmarks http://www.gardena.net/benno/linux/audio
This archive was generated by hypermail 2b28 : pe maalis 10 2000 - 07:23:26 EST