impl-node: improve node activation

Only activate the nodes when it was not-triggered, do this check with an
atomic compare-and-swap so that we only activate a node once.

We might be able to use this later to make sure that we resume the
untriggered peer nodes when we remove a node from the graph.
This commit is contained in:
Wim Taymans 2024-04-04 21:17:51 +02:00
parent 9cb4d820d5
commit 74de723ecc
2 changed files with 29 additions and 24 deletions

View file

@ -1888,13 +1888,16 @@ static inline void signal_sync(struct client *c)
state->pending, state->required);
if (pw_node_activation_state_dec(state)) {
l->activation->status = PW_NODE_ACTIVATION_TRIGGERED;
l->activation->signal_time = nsec;
if (SPA_ATOMIC_CAS(l->activation->status,
PW_NODE_ACTIVATION_NOT_TRIGGERED,
PW_NODE_ACTIVATION_TRIGGERED)) {
l->activation->signal_time = nsec;
pw_log_trace_fp("%p: signal %p %p", c, l, state);
pw_log_trace_fp("%p: signal %p %p", c, l, state);
if (SPA_UNLIKELY(write(l->signalfd, &cmd, sizeof(cmd)) != sizeof(cmd)))
pw_log_warn("%p: write failed %m", c);
if (SPA_UNLIKELY(write(l->signalfd, &cmd, sizeof(cmd)) != sizeof(cmd)))
pw_log_warn("%p: write failed %m", c);
}
}
}
}