[alsa-devel] Understanding _snd_pcm_channel_area Struct (PCM Interface)!

Takashi Iwai tiwai at suse.de
Sat Jun 27 09:32:53 CEST 2009


At Fri, 26 Jun 2009 23:56:43 -0300,
Guilherme wrote:
> 
> Takashi...
> 
> The base_address and the step sounds pretty clear to me.... just the 
> offset I could not understand.
> 
> What the difference in being  .first = 0 or .first = 2??? Could you 
> provide please a more in depth explanation. I tried really hard find 
> this but there is nothing related in the documentation.
> 
> area[0].addr = base_address;
> 	addr[0].first = 0;
> 	addr[0].step = 4;
> 	addr[1].addr = base_address;
> 	addr[1].first = 2;
> 	addr[1].step = 4;
> 
> P.S. being a stereo or a mono pipeline I understand... just the way the offset works that is not so clear to me.

Actually, the non-interleaved formats can be represented also with
a single base_address (and is so in the actual implementation).

	addr[0].addr = base_addr;
	addr[0].first = 0;
	addr[0].step = 2;
	addr[1].addr = base_addr;
	addr[1].first = mono_buffer_len;
	addr[1].step = 2;
	addr[2].addr = base_addr;
	addr[2].first = mono_buffer_len * 2;
	addr[2].step = 2;
	...

The "first" is the offset of the first sample.  The address of the
first sample of the channel is simply calculated as addr + first.
This is because just we want to keep the base address same to all
channels as much as possible especially in mmap mode.


Takashi


More information about the Alsa-devel mailing list