ALSA: conf: Save SND_CONFIG_TYPE_REAL with at least one decimal
PATCH 1/1 ALSA: conf: Save SND_CONFIG_TYPE_REAL with at least one decimal
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 <[email protected]>
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(-)
src/conf.c +6 -1
@@ -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);
Signature · 1 line
2.20.1
Quoted 2 lines · Simon Svanbom
Hi,
patch for savingSND_CONFIG_TYPE_REALwith at least one decimal as to not misinterpret the value as an integer insnd_config_get_real. Example would be the sofvol configuration propertymin_dBandmax_dB, that are required to have at least one decimal.
Thanks. I pushed this fix to repo using the snd_config_get_ireal() function in the configuration parsing code:
https://github.com/alsa-project/alsa-lib/commit/9f2c68cef716aa45942b502a42d94b84289f23bc
Jaroslav
Signature · 2 lines
Jaroslav Kysela <[email protected]> Linux Sound Maintainer; ALSA Project; Red Hat, Inc.