[PATCH] ALSA: conf: Save SND_CONFIG_TYPE_REAL with at least one decimal

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <simochr@xxxxxxxx>
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


[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux