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,6 +1812,7 @@ int main(int argc, char *argv[])
break; break;
case OPT_VOLUME: case OPT_VOLUME:
if (!spa_atof(optarg, &data.volume))
data.volume = (float)atof(optarg); data.volume = (float)atof(optarg);
break; break;
default: default:

View file

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