From patchwork Tue Sep 15 11:10:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricard Wanderlof X-Patchwork-Id: 7183891 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0EBDD9F380 for ; Tue, 15 Sep 2015 11:10:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 51AE3206EF for ; Tue, 15 Sep 2015 11:10:20 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 99599206EB for ; Tue, 15 Sep 2015 11:10:17 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 5C98B261299; Tue, 15 Sep 2015 13:10:16 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 318B02608D4; Tue, 15 Sep 2015 13:10:08 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id B19F7260A5B; Tue, 15 Sep 2015 13:10:06 +0200 (CEST) Received: from bes.se.axis.com (bes.se.axis.com [195.60.68.10]) by alsa0.perex.cz (Postfix) with ESMTP id 84A15260824 for ; Tue, 15 Sep 2015 13:10:01 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by bes.se.axis.com (Postfix) with ESMTP id 31CD12E44A for ; Tue, 15 Sep 2015 13:10:01 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at bes.se.axis.com Received: from bes.se.axis.com ([IPv6:::ffff:127.0.0.1]) by localhost (bes.se.axis.com [::ffff:127.0.0.1]) (amavisd-new, port 10024) with LMTP id BwvCCGlHyDP1 for ; Tue, 15 Sep 2015 13:10:00 +0200 (CEST) Received: from boulder.se.axis.com (boulder.se.axis.com [10.0.2.104]) by bes.se.axis.com (Postfix) with ESMTP id 6F4F52E3B6 for ; Tue, 15 Sep 2015 13:10:00 +0200 (CEST) Received: from boulder.se.axis.com (localhost [127.0.0.1]) by postfix.imss71 (Postfix) with ESMTP id 4FBAB14E8 for ; Tue, 15 Sep 2015 13:10:00 +0200 (CEST) Received: from seth.se.axis.com (seth.se.axis.com [10.0.2.172]) by boulder.se.axis.com (Postfix) with ESMTP id 443D314E5 for ; Tue, 15 Sep 2015 13:10:00 +0200 (CEST) Received: from xmail2.se.axis.com (xmail2.se.axis.com [10.0.5.74]) by seth.se.axis.com (Postfix) with ESMTP id 422BB3E049 for ; Tue, 15 Sep 2015 13:10:00 +0200 (CEST) Received: from lnxricardw1.se.axis.com (10.88.7.2) by xmail2.se.axis.com (10.0.5.74) with Microsoft SMTP Server (TLS) id 8.3.342.0; Tue, 15 Sep 2015 13:10:00 +0200 Date: Tue, 15 Sep 2015 13:10:00 +0200 From: Ricard Wanderlof X-X-Sender: ricardw@lnxricardw1.se.axis.com To: "alsa-devel@alsa-project.org" Message-ID: User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Subject: [alsa-devel] [PATCH utils] aplay: fix VU meter for S24_LE etc formats X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- alsa-utils/aplay/aplay.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/aplay/aplay.c b/aplay/aplay.c index e58e1bc..19b6a92 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;