From: Takashi Iwai Subject: Re: Understanding _snd_pcm_channel_area Struct (PCM Interface)! Date: Tue, 30 Jun 2009 16:42:42 +0200 Message-ID: References: <4A3DEAF9.80508@free.fr> <4A406AD3.2050002@gmail.com> <4A458A6B.2070305@gmail.com> <4A4A23D4.4090505@gmail.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 7EF9A243C2 for ; Tue, 30 Jun 2009 16:42:42 +0200 (CEST) In-Reply-To: <4A4A23D4.4090505@gmail.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: Guilherme Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org At Tue, 30 Jun 2009 11:40:20 -0300, Guilherme wrote: > = > Tks takashi.... > = > The doubt comes from this block of code: > = > for (chn =3D 0; chn < channels; chn++) { > if ((areas[chn].first % 8) !=3D 0) { > printf("areas[%i].first =3D=3D %i, abortando...\n", c= hn, = > areas[chn].first); > exit(EXIT_FAILURE); > } > //pega endere=E7o e offset da area > samples[chn] =3D /*(signed short *)*/(((unsigned char = > *)areas[chn].addr) + (areas[chn].first / 8)); > = > if ((areas[chn].step % 16) !=3D 0) { > printf("areas[%i].step =3D=3D %i, aborting...\n", chn, = > areas[chn].step); > exit(EXIT_FAILURE); > } > = > steps[chn] =3D areas[chn].step / 8; > samples[chn] +=3D offset * steps[chn]; > } > = > first: > = > areas[chn].first % 8 ( I am using chn =3D 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 =3D 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