From patchwork Tue Dec 13 07:55:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Svanbom X-Patchwork-Id: 13071770 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7953EC4332F for ; Tue, 13 Dec 2022 07:56:53 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id E92A218AA; Tue, 13 Dec 2022 08:56:00 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E92A218AA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1670918211; bh=+Fjp4NTmrhG4YFx7jFd8xJDppuXs2EWKHX6VF+TC/SE=; h=From:To:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:Cc:From; b=CUJOf3IhgCbm1s9T2hZbQD87k7r7B78Hy/vBnksFiSVRFg1A/BLnxmlocn9FTavmo 7z7owQyW6M3nkAX1qOXpxr/V/LeitxZ7c7K9Y/OKS7DKYhpfI6LRfeyVfx0Vcflf7B fQ5mzMppnsOsecYQjp4l378DsaAYlJUVb9YOuj2c= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 9F64EF8047D; Tue, 13 Dec 2022 08:56:00 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 50B40F80431; Tue, 13 Dec 2022 08:55:59 +0100 (CET) Received: from smtp2.axis.com (smtp2.axis.com [195.60.68.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 5D4CEF80431 for ; Tue, 13 Dec 2022 08:55:56 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5D4CEF80431 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=axis.com header.i=@axis.com header.a=rsa-sha256 header.s=axis-central1 header.b=A14lTsfa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1670918159; x=1702454159; h=from:to:cc:subject:date:message-id:mime-version; bh=hDvAhm2qY0FyFX7cJlbF4u5kIskI/PQsLuV5FiRkqMg=; b=A14lTsfa6SXoQzKJNCKODbX2xLux06pbHvTtzR8uFi9NHPzSsv/GEJFW iWPj/OUkJOnfpLy+0xbsXgQOyks5tvAMBey8T9Ibe69ZHP8Oh4+9LfX7t tYx9+XcVhs32oYJZrG3uG7skXMrR2Ap9INBTtj3EGXgqSBN64CPt0iYYI kS9uP8tdJuon8Mu0PILarcRIyMCP+A0unYwBjC5LVA1d8yFql8YFqJGvF auGVmaOx4aATMtZ+UigrpE/b86nNLaCt+mZBCm0tErQp85P/DeoCCFFVv uhMMZjrTh9PKIxtNxmiOk0b0SzMaSYQiNmU2DL8VRlXkEcX7hH+PSlPSX Q==; From: Simon Svanbom To: "alsa-devel@alsa-project.org" Subject: [PATCH] ALSA: conf: Save SND_CONFIG_TYPE_REAL with at least one decimal Thread-Topic: [PATCH] ALSA: conf: Save SND_CONFIG_TYPE_REAL with at least one decimal Thread-Index: AQHZDsdHOsnY5fSCk0ykhYvc8iAaLw== Date: Tue, 13 Dec 2022 07:55:55 +0000 Message-ID: Accept-Language: sv-SE, en-US Content-Language: sv-SE X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-originating-ip: [10.0.5.60] MIME-Version: 1.0 X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 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: , Cc: "tiwai@suse.de" Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Hi, patch for saving SND_CONFIG_TYPE_REAL with at least one decimal as to not misinterpret the value as an integer in snd_config_get_real. Example would be the sofvol configuration property min_dB and max_dB, that are required to have at least one decimal. All the best // Simon From d679d469cd048d01edfec952c5550aca8fd4b04a Mon Sep 17 00:00:00 2001 From: Simon Svanbom Date: Tue, 13 Dec 2022 08:23:53 +0100 Subject: [PATCH] conf: Save SND_CONFIG_TYPE_REAL with at least one decimal Save node values of type SND_CONFIG_TYPE_REAL with at least one decimal in order not to misinterpret the value as an integer in snd_config_get_real. Change-Id: I5897ba8ea6be3217f40dd382a98e17ffca3d56be --- src/conf.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/conf.c b/src/conf.c index 65f2e1a7..de051283 100644 --- a/src/conf.c +++ b/src/conf.c @@ -1634,7 +1634,12 @@ int _snd_config_save_node_value(snd_config_t *n, snd_output_t *out, snd_output_printf(out, "%lld", n->u.integer64); break; case SND_CONFIG_TYPE_REAL: - snd_output_printf(out, "%-16g", n->u.real); + /* If no decimals provided, print at least one */ + if (n->u.real == (int)n->u.real) { + snd_output_printf(out, "%-.1f", n->u.real); + } else { + snd_output_printf(out, "%-16g", n->u.real); + } break; case SND_CONFIG_TYPE_STRING: string_print(n->u.string, 0, out); -- 2.20.1