[alsa-devel] Understanding _snd_pcm_channel_area Struct (PCM Interface)!
Guilherme
grlongo.ireland at gmail.com
Tue Jun 30 17:01:53 CEST 2009
Hum...
so .. the code
if ((areas[chn].step % 16) !=0 )
is because a 16bits format's been used.
If I wanted a 32bits sample format I should change that for
if ((areas[chn].step % 32) !=0 ) ??
and the offset for the first doen's need any changes, is it?
Just a opinion about all this, I think that alsa developers should design graphs for these things, as has in gstreamer documentation.
It is a lot easer to understand that way.
It is because I dont understand very well yet, but as I am going to work with sound stuff especially in linux environment, Ill be very soon offering help for this!
;o)
Tks!
-------------------
Guilherme Longo
Dept. Eng. da Computação
Unaerp
Linux User - #484927
*Before Asking
http://www.istf.com.br/?page=perguntas
!- I'd rather die on my feet than live on my knees -!
Takashi Iwai wrote:
> At Tue, 30 Jun 2009 11:40:20 -0300,
> Guilherme wrote:
>
>> Tks takashi....
>>
>> The doubt comes from this block of code:
>>
>> for (chn = 0; chn < channels; chn++) {
>> if ((areas[chn].first % 8) != 0) {
>> printf("areas[%i].first == %i, abortando...\n", chn,
>> areas[chn].first);
>> exit(EXIT_FAILURE);
>> }
>> //pega endereço e offset da area
>> samples[chn] = /*(signed short *)*/(((unsigned char
>> *)areas[chn].addr) + (areas[chn].first / 8));
>>
>> if ((areas[chn].step % 16) != 0) {
>> printf("areas[%i].step == %i, aborting...\n", chn,
>> areas[chn].step);
>> exit(EXIT_FAILURE);
>> }
>>
>> steps[chn] = areas[chn].step / 8;
>> samples[chn] += offset * steps[chn];
>> }
>>
>> first:
>>
>> areas[chn].first % 8 ( I am using chn = 1). So for the only area that
>> I have, if I get the value of the parameter 'first' isn't divisible by
>> 8, the program exits.
>> The same doubt happens with "areas[chn].step % 16" and
>> "areas[chn].step / 8".
>>
>> This is the parameter I am using:
>>
>> static snd_pcm_format_t format = SND_PCM_FORMAT_S16; //sample format
>> unsigned 16 bit endian
>>
>> Perhaps with this practical example I can understand better.
>>
>
> Oops, I wrote wrongly. The first and step fields are not in bytes but
> bits. That's why 8 and 16 appear there, corresponding to 1 byte and 2
> bytes.
>
>
> Takashi
>
>
More information about the Alsa-devel
mailing list