test/pcm.c: Fix SND_PCM_FORMAT_S24 support

The program uses snd_pcm_format_width() wrongly to calculate the sample
size.  It must be snd_pcm_format_physical_width() instead.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Takashi Iwai 2008-07-10 18:45:23 +02:00
parent af2c3fbe7d
commit d31fd52e74

View file

@ -62,8 +62,8 @@ static void generate_sine(const snd_pcm_channel_area_t *areas,
/* fill the channel areas */
while (count-- > 0) {
res = sin(phase) * maxval;
ires = res;
tmp = (unsigned char *)(&ires);
ires.i = res;
tmp = ires.c;
for (chn = 0; chn < channels; chn++) {
for (byte = 0; byte < (unsigned int)bps; byte++)
*(samples[chn] + byte) = tmp[byte];
@ -871,7 +871,7 @@ int main(int argc, char *argv[])
if (verbose > 0)
snd_pcm_dump(handle, output);
samples = malloc((period_size * channels * snd_pcm_format_width(format)) / 8);
samples = malloc((period_size * channels * snd_pcm_format_physical_width(format)) / 8);
if (samples == NULL) {
printf("No enough memory\n");
exit(EXIT_FAILURE);
@ -884,8 +884,8 @@ int main(int argc, char *argv[])
}
for (chn = 0; chn < channels; chn++) {
areas[chn].addr = samples;
areas[chn].first = chn * snd_pcm_format_width(format);
areas[chn].step = channels * snd_pcm_format_width(format);
areas[chn].first = chn * snd_pcm_format_physical_width(format);
areas[chn].step = channels * snd_pcm_format_physical_width(format);
}
err = transfer_methods[method].transfer_loop(handle, samples, areas);