context: make sure we clear the visited flag

Do a separate pass to clear the visited flag of the nodes because
collect_nodes might set them after we cleared them.
This commit is contained in:
Wim Taymans 2022-04-20 10:43:57 +02:00
parent d0886a16a2
commit e21efd40bb

View file

@ -1179,39 +1179,37 @@ again:
/* now go through all available nodes. The ones we didn't visit /* now go through all available nodes. The ones we didn't visit
* in collect_nodes() are not linked to any driver. We assign them * in collect_nodes() are not linked to any driver. We assign them
* to either an active driver of the first driver */ * to either an active driver or the first driver */
spa_list_for_each(n, &context->node_list, link) { spa_list_for_each(n, &context->node_list, link) {
if (n->exported) struct pw_impl_node *t;
if (n->exported || n->visited)
continue; continue;
if (!n->visited) { pw_log_debug("%p: unassigned node %p: '%s' active:%d want_driver:%d target:%p",
struct pw_impl_node *t; context, n, n->name, n->active, n->want_driver, target);
pw_log_debug("%p: unassigned node %p: '%s' active:%d want_driver:%d target:%p", t = n->want_driver && n->active ? target : NULL;
context, n, n->name, n->active, n->want_driver, target); if (t != NULL) {
pw_impl_node_set_driver(n, t);
t = n->want_driver && n->active ? target : NULL; /* we configured a driver, move all linked
if (t != NULL) { * nodes to it as well */
pw_impl_node_set_driver(n, t); if (n->always_process)
/* we configured a driver, move all linked t->passive = false;
* nodes to it as well */ collect_nodes(context, n);
if (n->always_process) if (!n->always_process && n->passive)
t->passive = false; /* nothing active and node doesn't need to be
collect_nodes(context, n); * scheduled, remove from driver again and
if (!n->always_process && n->passive) * stop */
/* nothing active and node doesn't need to be t = NULL;
* scheduled, remove from driver again and }
* stop */ if (t == NULL) {
t = NULL; /* no driver, make sure the node stops */
} pw_impl_node_set_driver(n, NULL);
if (t == NULL) { ensure_state(n, false);
/* no driver, make sure the node stops */
pw_impl_node_set_driver(n, NULL);
ensure_state(n, false);
}
} }
n->visited = false;
} }
spa_list_for_each(n, &context->node_list, link)
n->visited = false;
/* assign final quantum and set state for followers and drivers */ /* assign final quantum and set state for followers and drivers */
spa_list_for_each(n, &context->driver_list, driver_link) { spa_list_for_each(n, &context->driver_list, driver_link) {