audioconvert: use spa_dtoa to format floats and doubles

The parsing functions expect float values in the default locale so use
the spa_dtoa function to generate such a float.

Fixes setting params with floating point values when the locale is not
the default locale.
This commit is contained in:
Wim Taymans 2022-10-13 10:15:52 +02:00
parent 59e49d31eb
commit 0adc351d36

View file

@ -825,8 +825,11 @@ static int parse_prop_params(struct impl *this, struct spa_pod *params)
if (spa_pod_is_string(pod)) {
spa_pod_copy_string(pod, sizeof(value), value);
} else if (spa_pod_is_float(pod)) {
snprintf(value, sizeof(value), "%f",
spa_dtoa(value, sizeof(value),
SPA_POD_VALUE(struct spa_pod_float, pod));
} else if (spa_pod_is_double(pod)) {
spa_dtoa(value, sizeof(value),
SPA_POD_VALUE(struct spa_pod_double, pod));
} else if (spa_pod_is_int(pod)) {
snprintf(value, sizeof(value), "%d",
SPA_POD_VALUE(struct spa_pod_int, pod));