Rework how targets are managed

Manage them like we do on the client and reuse logic. Make a node
function to safely add and remove a target.

Activate the targets from the process loop when we can be sure that we
can resume them. This avoids incrementing the pending state when we are
not going to be able to resume the nodes (like when the cycle is ongoing
and we have already been scheduled) and avoids glitches and xruns.

When a node is added to the poll loop, it can activate its own targets.
This is mostly for driver so that they have something to schedule and
can then activate the other targets.

Try to resume the target when it is removed and we are supposed to be
scheduled.

Also add targets to the target_list when the node is remote to make sure
the profiler can see the targets as well.

Keep the node in the INACTIVE state as long as the eventfd of the node
is not added to the loop. Skip nodes in the INACTIVE state from going to
the NOT_TRIGGERED status, which avoids scheduling the node.

Make sure we remove any local targets we have in a node when we export
it, we will receive new targets from the server.

This should eliminate any glitches when adding and removing nodes from
the graph.

See #4026, #2468
This commit is contained in:
Wim Taymans 2024-05-28 18:19:51 +02:00
parent ce985def73
commit 46f71b1cd2
6 changed files with 296 additions and 345 deletions

View file

@ -1347,8 +1347,6 @@ void pw_impl_client_node_registered(struct pw_impl_client_node *this, struct pw_
0,
sizeof(struct pw_node_activation));
node_peer_added(impl, node);
if (impl->bind_node_id) {
pw_global_bind(global, client, PW_PERM_ALL,
impl->bind_node_version, impl->bind_node_id);
@ -1707,16 +1705,6 @@ static void node_port_removed(void *data, struct pw_impl_port *port)
clear_port(impl, p);
}
static void node_driver_changed(void *data, struct pw_impl_node *old, struct pw_impl_node *driver)
{
struct impl *impl = data;
pw_log_debug("%p: driver changed %p -> %p", impl, old, driver);
node_peer_removed(data, old);
node_peer_added(data, driver);
}
static const struct pw_impl_node_events node_events = {
PW_VERSION_IMPL_NODE_EVENTS,
.free = node_free,
@ -1726,7 +1714,6 @@ static const struct pw_impl_node_events node_events = {
.port_removed = node_port_removed,
.peer_added = node_peer_added,
.peer_removed = node_peer_removed,
.driver_changed = node_driver_changed,
};
static const struct pw_resource_events resource_events = {