[alsa-devel] Alsa principles

LCID Fire lcid-fire at gmx.net
Sun Aug 12 22:44:06 CEST 2007

Programming alsa is confusing at the point that there is basicly no
documentation. So since I get more and more confused I hope someone can
help me out here.

First - I didn't find any complete description about interleaved and
non-interleaved transport. What is actually (in a nutshell) the
difference and what the consequences of either approach?

Second - when capturing I do the following:

So this is setting some kind of format!? I mean first off - which format
should one set? There are a few dozens to choose from and the hardware
will most likely not support all of them. So how does one retrieve a
list of the hardware supported formats? And which one should be
considered superior? I assume it does affect the buffer size eventually

This one should IMO output the channels - but for a capture device
(where often there is just a single stereo input) this would normally
just return 2, right?

This is pretty self explanatory - aside from the effect this one has.
Eventually there will be gotten some data via a buffer. Would there be 6
channels (dolby stuff) does a filled buffer look like the following?


This one is also pretty self explanatory - aside from pure digital
devices - which I'm lucky not to have.

And we are at the REAL confusing stuff. Here one can set "periods". But
what is meant by a period? Is it a frame or how would sane people call
this? And there's a count of periods set - what is this count used for?

Ok from the previous periods I can get the size. I assume this is
somewhat usefull to estimate the buffer size but since I don't know
exactly what periods are or do - I dunno.

This one sets the buffer size. I'm kind of confused here because you
have to set the periods AND the buffer size. So are the periods just the
slices for the buffer? So I think the buffer can be calculated as

<periods> * <periodSize> * <formatTypeWTF> * <channels>
So is the buffer size the actual byte size, a frame size the period size
or whatever?

Since the buffer is a void* I assume that the format does affect the
data needed for the buffer. But having a buffer in userspace and a
buffer set in alsa means it does copy at least twice. I fear for direct
copying one has to get in touch with this mmap method nobody wants to
talk about :(

If you read to this point thank you ;)

More information about the Alsa-devel mailing list