From 3d0843e8ce3c2c504f036c8e029b13e9fd66a4f9 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 6 Jul 2009 08:41:00 +0200 Subject: [PATCH] test/pcm.c: Fix S24 format S24 format has different bit width and physical width. For calculating the byte offset for big-endian packing, the latter value has to be used. Signed-off-by: Takashi Iwai --- test/pcm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/pcm.c b/test/pcm.c index 80e1f988..bd7717f8 100644 --- a/test/pcm.c +++ b/test/pcm.c @@ -40,6 +40,7 @@ static void generate_sine(const snd_pcm_channel_area_t *areas, unsigned int maxval = (1 << (snd_pcm_format_width(format) - 1)) - 1; int bps = snd_pcm_format_width(format) / 8; /* bytes per sample */ + int phys_bps = snd_pcm_format_physical_width(format) / 8; /* verify and prepare the contents of areas */ for (chn = 0; chn < channels; chn++) { @@ -63,7 +64,7 @@ static void generate_sine(const snd_pcm_channel_area_t *areas, /* Generate data in native endian format */ for (i = 0; i < bps; i++) { #if (__BYTE_ORDER == __BIG_ENDIAN) - *(samples[chn] + bps - 1 - i) = (res >> i * 8) & 0xff; + *(samples[chn] + phys_bps - 1 - i) = (res >> i * 8) & 0xff; #else *(samples[chn] + i) = (res >> i * 8) & 0xff; -- 2.47.1