[alsa-devel] Asynchronous ALSA - callback and latency questions

Bram Bos bos3 at upcmail.nl
Mon Sep 8 18:03:13 CEST 2014


Hello all,

I’m using ALSA for building a performance musical instrument, so I’m after
 low-latency audio output.
I have some questions (since I'm fairly new to ALSA and to Linux they may  be a
big n00by, so please bear with me)…

1. I’m using asynchronous audio output (i.e. using a callback). Sometimes the
system simply stops calling the callback function without giving an error. In
case of an xrun I would expect there to be an underrun message (which I
sometimes also get) so I can handle it properly. So I guess something else is
causing the issue? Any pointers?

2. What does “File descriptor is in a bad state” mean, when it is returned by
snd_pcm_writei? I notice that I can often avoid getting it by increasing the
size of my buffer but the message doesn't make sense to me.

3. Occasionally my application grinds to a halt with a “I/O is possible” message
– presumably this is triggered by the ALSA callback mechanism?

4. My last question is a bit more conceptual: what determines the playback
latency of my audio stream? The period size? The total ring buffer size? I
assume it should be the difference between the hardware playback pointer and the
software write pointer, but I can’t figure out how they are determined.

Thanks for any help.



System info: Raspberry Pi B+ (non-overclocked), Raspbian Wheezy, USB PnP CM108
audio device


More information about the Alsa-devel mailing list