From 5e21edd8d5b5c0ac85276e9ab7c63a8fba558d39 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 18 Oct 2017 10:02:55 +0200 Subject: [PATCH] spa-node: parse bool properties Add some more helpers to parse property values --- src/modules/spa/spa-node.c | 16 ++++++++++++---- src/pipewire/properties.h | 8 ++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/modules/spa/spa-node.c b/src/modules/spa/spa-node.c index 3c34eac45..70857ddef 100644 --- a/src/modules/spa/spa-node.c +++ b/src/modules/spa/spa-node.c @@ -181,21 +181,29 @@ setup_props(struct pw_core *core, struct spa_node *spa_node, struct pw_propertie pw_log_info("configure prop %s", key); switch(prop->body.value.type) { + case SPA_POD_TYPE_BOOL: + SPA_POD_VALUE(struct spa_pod_bool, &prop->body.value) = + pw_properties_parse_bool(value); + break; case SPA_POD_TYPE_ID: SPA_POD_VALUE(struct spa_pod_id, &prop->body.value) = spa_type_map_get_id(t->map, value); break; case SPA_POD_TYPE_INT: - SPA_POD_VALUE(struct spa_pod_int, &prop->body.value) = atoi(value); + SPA_POD_VALUE(struct spa_pod_int, &prop->body.value) = + pw_properties_parse_int(value); break; case SPA_POD_TYPE_LONG: - SPA_POD_VALUE(struct spa_pod_long, &prop->body.value) = atoi(value); + SPA_POD_VALUE(struct spa_pod_long, &prop->body.value) = + pw_properties_parse_int64(value); break; case SPA_POD_TYPE_FLOAT: - SPA_POD_VALUE(struct spa_pod_float, &prop->body.value) = atof(value); + SPA_POD_VALUE(struct spa_pod_float, &prop->body.value) = + pw_properties_parse_float(value); break; case SPA_POD_TYPE_DOUBLE: - SPA_POD_VALUE(struct spa_pod_double, &prop->body.value) = atof(value); + SPA_POD_VALUE(struct spa_pod_double, &prop->body.value) = + pw_properties_parse_double(value); break; case SPA_POD_TYPE_STRING: break; diff --git a/src/pipewire/properties.h b/src/pipewire/properties.h index 22faad4b0..9dd8668b5 100644 --- a/src/pipewire/properties.h +++ b/src/pipewire/properties.h @@ -83,6 +83,14 @@ static inline uint64_t pw_properties_parse_uint64(const char *value) { return strtoull(value, NULL, 0); } +static inline float pw_properties_parse_float(const char *value) { + return strtof(value, NULL); +} + +static inline double pw_properties_parse_double(const char *value) { + return strtod(value, NULL); +} + #ifdef __cplusplus } #endif