From d31fd52e74dd5fa9df15648b47cc71d2c28b7ce8 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 10 Jul 2008 18:45:23 +0200 Subject: [PATCH] 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 --- test/pcm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/pcm.c b/test/pcm.c index 437d9907..ecd0afab 100644 --- a/test/pcm.c +++ b/test/pcm.c @@ -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); -- 2.11.0