[alsa-devel] DMA circular buffers - little help wanted
Petr Kulhavy
brain at jikos.cz
Thu Jan 19 16:45:44 CET 2017
Hi,
I'm trying to write a sound card driver and need a bit of help
understanding the logic behind the DMA circular buffers.
I can understand there is a buffer of runtime->buffer_size frames, with
two pointers: runtime->control->appl_ptr and runtime->status->hw_ptr
pointing into it (they are actually offsets from the buffer start).
One pointer is the producer, the other consumer. So far a standard
circular buffer as I know it. Please correct me if I'm wrong.
But what is runtime->boundary good for? It seems the arithmetics is not
module buffer_size but modulo boundary, which is pretty confusing me.
According to the code and comments some values (like buffer "pointers",
available space, free, space, etc.) are supposed to be within 0 ...
boundary - 1 and some within 0 ... buffer_size - 1. Not clear to me what
is what and why.
Could someone please help me to understand the logic behind?
The other thing I would like to understand, how is the data positioned
in time in terms of synchronisation? I mean where in the buffer,
relative to the hw_ptr, is the frame that is supposed to play "now", for
an arbitrary "now".
Thanks
Petr
More information about the Alsa-devel
mailing list