modules: switch a few modules to the new property helpers

This commit is contained in:
Peter Hutterer 2021-10-12 14:29:57 +10:00 committed by Wim Taymans
parent d8de1cb255
commit 1d8d7e90ce
6 changed files with 16 additions and 41 deletions

View file

@ -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, };

View file

@ -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:

View file

@ -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:

View file

@ -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: