From d679d469cd048d01edfec952c5550aca8fd4b04a Mon Sep 17 00:00:00 2001
From: Simon Svanbom <simochr@axis.com>
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(-)
@@ -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