context: make a copy of group and link_group

Just strdup the group. There is no need to keep it in a fixed size
array.
This commit is contained in:
Wim Taymans 2023-03-08 13:25:45 +01:00
parent 2c4bd25a89
commit 92a812e0ae
3 changed files with 26 additions and 16 deletions

View file

@ -845,17 +845,17 @@ static int collect_nodes(struct pw_context *context, struct pw_impl_node *node,
}
/* now go through all the nodes that have the same group and
* that are not yet visited */
if (n->group[0] == '\0')
continue;
spa_list_for_each(t, &context->node_list, link) {
if (t->exported || t == n || !t->active || t->visited)
continue;
if (!spa_streq(t->group, n->group))
continue;
pw_log_debug("%p join group %s: '%s'", t, t->group, n->group);
t->visited = true;
spa_list_append(&queue, &t->sort_link);
if (n->group != NULL) {
spa_list_for_each(t, &context->node_list, link) {
if (t->exported || !t->active || t->visited)
continue;
if (!spa_streq(t->group, n->group))
continue;
pw_log_debug("%p: %s join group %s",
t, t->name, t->group);
t->visited = true;
spa_list_append(&queue, &t->sort_link);
}
}
}
return 0;

View file

@ -461,6 +461,8 @@ static int suspend_node(struct pw_impl_node *this)
static void
clear_info(struct pw_impl_node *this)
{
free(this->group);
free(this->link_group);
free(this->name);
free((char*)this->info.error);
}
@ -927,16 +929,23 @@ static void check_properties(struct pw_impl_node *node)
node->rt.activation->state[0].required++;
/* group defines what nodes are scheduled together */
if ((str = pw_properties_get(node->properties, PW_KEY_NODE_GROUP)) == NULL)
str = "";
str = pw_properties_get(node->properties, PW_KEY_NODE_GROUP);
if (!spa_streq(str, node->group)) {
pw_log_info("%p: group '%s'->'%s'", node, node->group, str);
snprintf(node->group, sizeof(node->group), "%s", str);
free(node->group);
node->group = str ? strdup(str) : NULL;
node->freewheel = spa_streq(node->group, "pipewire.freewheel");
recalc_reason = "group changed";
}
/* link group defines what nodes are logically linked together */
str = pw_properties_get(node->properties, PW_KEY_NODE_LINK_GROUP);
if (!spa_streq(str, node->link_group)) {
pw_log_info("%p: link group '%s'->'%s'", node, node->link_group, str);
free(node->link_group);
node->link_group = str ? strdup(str) : NULL;
recalc_reason = "link group changed";
}
node->want_driver = pw_properties_get_bool(node->properties, PW_KEY_NODE_WANT_DRIVER, false);
node->always_process = pw_properties_get_bool(node->properties, PW_KEY_NODE_ALWAYS_PROCESS, false);

View file

@ -672,7 +672,8 @@ struct pw_impl_node {
char *name; /** for debug */
uint32_t priority_driver; /** priority for being driver */
char group[128]; /** group to schedule this node in */
char *group; /** group to schedule this node in */
char *link_group; /** group this node is linked to */
uint64_t spa_flags;
unsigned int registered:1;