tools: try to parse float values better

First try to parse the float value as a JSON number and then fall
back to atof to get the locale dependent variant.

This transparently makes things work with values such as 0.5 and 0,5.

Fixes #4234
This commit is contained in:
Wim Taymans 2024-08-28 16:49:28 +02:00
parent a77a6f3959
commit 0956fc0884
2 changed files with 4 additions and 2 deletions

View file

@ -1812,7 +1812,8 @@ int main(int argc, char *argv[])
break;
case OPT_VOLUME:
data.volume = (float)atof(optarg);
if (!spa_atof(optarg, &data.volume))
data.volume = (float)atof(optarg);
break;
default:
goto error_usage;

View file

@ -163,7 +163,8 @@ int main(int argc, char *argv[])
data.latency = atoi(optarg) * DEFAULT_RATE / SPA_MSEC_PER_SEC;
break;
case 'd':
data.delay = (float)atof(optarg);
if (!spa_atof(optarg, &data.delay))
data.delay = (float)atof(optarg);
break;
case 'C':
pw_properties_set(data.capture_props, PW_KEY_TARGET_OBJECT, optarg);