modules: place floats in properties in JSON format

Using %f will result in a locale dependent format and might not parse
with JSON parsers or even our own spa_atof() function.
This commit is contained in:
Wim Taymans 2023-12-14 11:50:30 +01:00
parent c386c96ff0
commit 5e750f6fb8
4 changed files with 21 additions and 10 deletions

View file

@ -253,6 +253,7 @@ struct vban_stream *vban_stream_new(struct pw_core *core,
{
struct impl *impl;
const char *str;
char tmp[64];
uint8_t buffer[1024];
struct spa_pod_builder b;
uint32_t n_params, min_samples, max_samples;
@ -370,8 +371,9 @@ struct vban_stream *vban_stream_new(struct pw_core *core,
impl->psamples = impl->mtu / impl->stride;
impl->psamples = SPA_CLAMP(impl->psamples, min_samples, max_samples);
if (direction == PW_DIRECTION_OUTPUT)
pw_properties_setf(props, "vban.ptime", "%f",
impl->psamples * 1000.0 / impl->rate);
pw_properties_set(props, "vban.ptime",
spa_dtoa(tmp, sizeof(tmp),
impl->psamples * 1000.0 / impl->rate));
}
latency_msec = pw_properties_get_uint32(props,
"sess.latency.msec", DEFAULT_SESS_LATENCY);