diff --git a/src/modules/module-protocol-pulse/collect.c b/src/modules/module-protocol-pulse/collect.c index 770e211f2..fa3e41d36 100644 --- a/src/modules/module-protocol-pulse/collect.c +++ b/src/modules/module-protocol-pulse/collect.c @@ -35,12 +35,10 @@ void select_best(struct selector *s, struct pw_manager_object *o) { - const char *str; int32_t prio = 0; if (o->props && - (str = pw_properties_get(o->props, PW_KEY_PRIORITY_SESSION)) != NULL) { - prio = pw_properties_parse_int(str); + pw_properties_fetch_int32(o->props, PW_KEY_PRIORITY_SESSION, &prio) == 0) { if (s->best == NULL || prio > s->score) { s->best = o; s->score = prio; @@ -75,19 +73,15 @@ struct pw_manager_object *select_object(struct pw_manager *m, struct selector *s bool collect_is_linked(struct pw_manager *m, uint32_t obj_id, enum pw_direction direction) { struct pw_manager_object *o; - const char *str; uint32_t in_node, out_node; spa_list_for_each(o, &m->object_list, link) { if (o->props == NULL || !pw_manager_object_is_link(o)) continue; - if ((str = pw_properties_get(o->props, PW_KEY_LINK_OUTPUT_NODE)) == NULL) + if (pw_properties_fetch_uint32(o->props, PW_KEY_LINK_OUTPUT_NODE, &out_node) != 0 || + pw_properties_fetch_uint32(o->props, PW_KEY_LINK_INPUT_NODE, &in_node) != 0) continue; - out_node = pw_properties_parse_int(str); - if ((str = pw_properties_get(o->props, PW_KEY_LINK_INPUT_NODE)) == NULL) - continue; - in_node = pw_properties_parse_int(str); if ((direction == PW_DIRECTION_OUTPUT && obj_id == out_node) || (direction == PW_DIRECTION_INPUT && obj_id == in_node)) @@ -99,19 +93,15 @@ bool collect_is_linked(struct pw_manager *m, uint32_t obj_id, enum pw_direction struct pw_manager_object *find_linked(struct pw_manager *m, uint32_t obj_id, enum pw_direction direction) { struct pw_manager_object *o, *p; - const char *str; uint32_t in_node, out_node; spa_list_for_each(o, &m->object_list, link) { if (o->props == NULL || !pw_manager_object_is_link(o)) continue; - if ((str = pw_properties_get(o->props, PW_KEY_LINK_OUTPUT_NODE)) == NULL) + if (pw_properties_fetch_uint32(o->props, PW_KEY_LINK_OUTPUT_NODE, &out_node) != 0 || + pw_properties_fetch_uint32(o->props, PW_KEY_LINK_INPUT_NODE, &in_node) != 0) continue; - out_node = pw_properties_parse_int(str); - if ((str = pw_properties_get(o->props, PW_KEY_LINK_INPUT_NODE)) == NULL) - continue; - in_node = pw_properties_parse_int(str); if (direction == PW_DIRECTION_OUTPUT && obj_id == out_node) { struct selector sel = { .id = in_node, .type = pw_manager_object_is_sink, }; diff --git a/src/modules/module-protocol-pulse/modules/module-tunnel-sink.c b/src/modules/module-protocol-pulse/modules/module-tunnel-sink.c index d60663034..050255c39 100644 --- a/src/modules/module-protocol-pulse/modules/module-tunnel-sink.c +++ b/src/modules/module-protocol-pulse/modules/module-tunnel-sink.c @@ -225,8 +225,7 @@ struct module *create_module_tunnel_sink(struct impl *impl, const char *argument d->module = module; d->stream_props = stream_props; - if ((str = pw_properties_get(props, "latency_msec")) != NULL) - spa_atou32(str, &d->latency_msec, 0); + pw_properties_fetch_uint32(props, "latency_msec", &d->latency_msec); return module; out: diff --git a/src/modules/module-protocol-pulse/modules/module-tunnel-source.c b/src/modules/module-protocol-pulse/modules/module-tunnel-source.c index 6efa226eb..f4944593b 100644 --- a/src/modules/module-protocol-pulse/modules/module-tunnel-source.c +++ b/src/modules/module-protocol-pulse/modules/module-tunnel-source.c @@ -215,8 +215,7 @@ struct module *create_module_tunnel_source(struct impl *impl, const char *argume d->module = module; d->stream_props = stream_props; - if ((str = pw_properties_get(props, "latency_msec")) != NULL) - spa_atou32(str, &d->latency_msec, 0); + pw_properties_fetch_uint32(props, "latency_msec", &d->latency_msec); return module; out: diff --git a/src/modules/module-protocol-pulse/modules/module-zeroconf-publish.c b/src/modules/module-protocol-pulse/modules/module-zeroconf-publish.c index 3c0a01c07..076f1aed2 100644 --- a/src/modules/module-protocol-pulse/modules/module-zeroconf-publish.c +++ b/src/modules/module-protocol-pulse/modules/module-zeroconf-publish.c @@ -638,7 +638,6 @@ struct module *create_module_zeroconf_publish(struct impl *impl, const char *arg struct module *module; struct module_zeroconf_publish_data *d; struct pw_properties *props = NULL; - const char *port; int res; PW_LOG_TOPIC_INIT(mod_topic); @@ -661,11 +660,7 @@ struct module *create_module_zeroconf_publish(struct impl *impl, const char *arg d = module->user_data; d->module = module; - if ((port = pw_properties_get(props, "port")) == NULL) - d->port = PW_PROTOCOL_PULSE_DEFAULT_PORT; - else - d->port = atoi(port); - + d->port = pw_properties_get_uint32(props, "port", PW_PROTOCOL_PULSE_DEFAULT_PORT); return module; out: diff --git a/src/modules/module-protocol-simple.c b/src/modules/module-protocol-simple.c index 6bb3bcca9..f545671c0 100644 --- a/src/modules/module-protocol-simple.c +++ b/src/modules/module-protocol-simple.c @@ -62,7 +62,7 @@ PW_LOG_TOPIC_STATIC(mod_topic, "mod." NAME); #define DEFAULT_FORMAT "S16" #define DEFAULT_RATE "44100" -#define DEFAULT_CHANNELS "2" +#define DEFAULT_CHANNELS 2 #define DEFAULT_POSITION "[ FL FR ]" #define DEFAULT_LATENCY "1024/48000" @@ -74,7 +74,7 @@ PW_LOG_TOPIC_STATIC(mod_topic, "mod." NAME); "[ playback.node= ] " \ "[ audio.rate= ] " \ "[ audio.format= ] " \ - "[ audio.channels= ] " \ + "[ audio.channels= ] " \ "[ audio.position= ] " \ "[ server.address=<[ tcp:[:][,...] ], default:"DEFAULT_SERVER">" \ @@ -722,10 +722,8 @@ static int parse_params(struct impl *impl) struct spa_json it[2]; char value[512]; - if ((str = pw_properties_get(impl->props, "capture")) != NULL) - impl->capture = pw_properties_parse_bool(str); - if ((str = pw_properties_get(impl->props, "playback")) != NULL) - impl->playback = pw_properties_parse_bool(str); + pw_properties_get_bool(impl->props, "capture", &impl->capture); + pw_properties_get_bool(impl->props, "playback", &impl->playback); if (!impl->playback && !impl->capture) { pw_log_error("missing capture or playback param"); return -EINVAL; @@ -745,9 +743,7 @@ static int parse_params(struct impl *impl) pw_log_error("invalid rate '%s'", str); return -EINVAL; } - if ((str = pw_properties_get(impl->props, "audio.channels")) == NULL) - str = DEFAULT_CHANNELS; - impl->info.channels = atoi(str); + impl->info.channels = pw_properties_get_uint32(impl->props, "audio.channels", DEFAULT_CHANNELS); if (impl->info.channels == 0) { pw_log_error("invalid channels '%s'", str); return -EINVAL; diff --git a/src/modules/module-pulse-tunnel.c b/src/modules/module-pulse-tunnel.c index b102fc698..ad165dfab 100644 --- a/src/modules/module-pulse-tunnel.c +++ b/src/modules/module-pulse-tunnel.c @@ -727,10 +727,8 @@ static void parse_audio_info(struct pw_properties *props, struct spa_audio_info_ info->format = id; } - if ((str = pw_properties_get(props, PW_KEY_AUDIO_RATE)) != NULL) - info->rate = atoi(str); - if ((str = pw_properties_get(props, PW_KEY_AUDIO_CHANNELS)) != NULL) - info->channels = atoi(str); + info->rate = pw_properties_get_uint32(props, PW_KEY_AUDIO_RATE, info->rate); + info->channels = pw_properties_get_uint32(props, PW_KEY_AUDIO_CHANNELS, info->channels); if ((str = pw_properties_get(props, SPA_KEY_AUDIO_POSITION)) != NULL) parse_position(info, str, strlen(str)); } @@ -803,9 +801,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args) } } - impl->latency_msec = DEFAULT_LATENCY_MSEC; - if ((str = pw_properties_get(props, "pulse.latency")) != NULL) - spa_atou32(str, &impl->latency_msec, 0); + impl->latency_msec = pw_properties_get_uint32(props, "pulse.latency", DEFAULT_LATENCY_MSEC); if (pw_properties_get(props, PW_KEY_NODE_GROUP) == NULL) pw_properties_set(props, PW_KEY_NODE_GROUP, "pipewire.dummy");