forked from pool/alsa-utils
3932cd7abe
- Backport upstream fixes: particularly fixing the inconsistent mixer state after service reload (bnc#929619): 0010-speaker-test-fix-option-ordering.patch 0011-arecord-Remove-only-regular-files.patch 0012-aplay-fix-VU-meter-for-S24_LE-etc-formats.patch 0013-alsactl-Manage-both-save-and-restore-in-a-single-uni.patch OBS-URL: https://build.opensuse.org/request/show/335880 OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/alsa-utils?expand=0&rev=124
54 lines
1.9 KiB
Diff
54 lines
1.9 KiB
Diff
From cd1bb5f4a72c7364b2756db357d752a73baefc9b Mon Sep 17 00:00:00 2001
|
|
From: Ricard Wanderlof <ricard.wanderlof@axis.com>
|
|
Date: Tue, 15 Sep 2015 13:10:00 +0200
|
|
Subject: [PATCH] aplay: fix VU meter for S24_LE etc formats
|
|
|
|
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 | 5 +++--
|
|
1 file changed, 3 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/aplay/aplay.c b/aplay/aplay.c
|
|
index 1b2cdfc527ca..7eacee3ca274 100644
|
|
--- a/aplay/aplay.c
|
|
+++ b/aplay/aplay.c
|
|
@@ -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;
|
|
|
|
--
|
|
2.5.3
|
|
|