]> git.alsa-project.org Git - alsa-utils.git/commitdiff
aplay: fix VU meter for S24_LE etc formats
authorRicard Wanderlof <ricard.wanderlof@axis.com>
Tue, 15 Sep 2015 11:10:00 +0000 (13:10 +0200)
committerTakashi Iwai <tiwai@suse.de>
Wed, 23 Sep 2015 14:28:33 +0000 (16:28 +0200)
When recording or playing back audio in a format where the number of
significant bits is less than the physical width (e.g. S24_LE), the VU
meter code needs to consider the number of significant bits in the samples
rather than the physical sample width (e.g. 24 vs 32 bits). Otherwise the
resulting VU meter display will be far too low and it will just indicate
0% all the time.

Tested with a device supporting the S24_LE format.

Signed-off-by: Ricard Wanderlof <ricardw@axis.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
aplay/aplay.c

index 1b2cdfc527cabb9299e8c827a267a75e52c3ef57..7eacee3ca2741292e43c06d3c92805aa5a6c8d9a 100644 (file)
@@ -124,7 +124,7 @@ static int fatal_errors = 0;
 static int verbose = 0;
 static int vumeter = VUMETER_NONE;
 static int buffer_pos = 0;
-static size_t bits_per_sample, bits_per_frame;
+static size_t significant_bits_per_sample, bits_per_sample, bits_per_frame;
 static size_t chunk_bytes;
 static int test_position = 0;
 static int test_coef = 8;
@@ -1344,6 +1344,7 @@ static void set_params(void)
                snd_pcm_dump(handle, log);
 
        bits_per_sample = snd_pcm_format_physical_width(hwparams.format);
+       significant_bits_per_sample = snd_pcm_format_width(hwparams.format);
        bits_per_frame = bits_per_sample * hwparams.channels;
        chunk_bytes = chunk_size * bits_per_frame / 8;
        audiobuf = realloc(audiobuf, chunk_bytes);
@@ -1745,7 +1746,7 @@ static void compute_max_peak(u_char *data, size_t count)
                }
                return;
        }
-       max = 1 << (bits_per_sample-1);
+       max = 1 << (significant_bits_per_sample-1);
        if (max <= 0)
                max = 0x7fffffff;