summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2008-07-10 18:45:23 +0200
committerTakashi Iwai <tiwai@suse.de>2008-07-10 18:45:23 +0200
commitd31fd52e74dd5fa9df15648b47cc71d2c28b7ce8 (patch)
tree877a96ed22d3146f883010c22e76fd7f58e1634d
parentaf2c3fbe7d28c2c4555aac75933263eb6e2d2e8a (diff)
downloadalsa-lib-d31fd52e74dd5fa9df15648b47cc71d2c28b7ce8.tar.gz
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>
-rw-r--r--test/pcm.c10
1 files 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);