impl-node: improve debug

Use ATOMIC_LOAD to get status.
Debug the pending state after decrementing so we debug the value we
are actually going to test.
Add node id to debug lines to better track things.
This commit is contained in:
Wim Taymans 2024-08-07 18:37:46 +02:00
parent 8fb05935d3
commit 5afdd54277
2 changed files with 22 additions and 13 deletions

View file

@ -1360,9 +1360,10 @@ static inline void debug_xrun_graph(struct pw_impl_node *driver, uint64_t nsec)
spa_list_for_each(t, &driver->rt.target_list, link) {
struct pw_node_activation *a = t->activation;
struct pw_node_activation_state *state = &a->state[0];
uint32_t status = SPA_ATOMIC_LOAD(a->status);
if (a->status == PW_NODE_ACTIVATION_TRIGGERED ||
a->status == PW_NODE_ACTIVATION_AWAKE) {
if (status == PW_NODE_ACTIVATION_TRIGGERED ||
status == PW_NODE_ACTIVATION_AWAKE) {
pw_log(level, "(%s-%u) xrun state:%p pending:%d/%d s:%"PRIu64" a:%"PRIu64" f:%"PRIu64
" waiting:%"PRIu64" process:%"PRIu64" status:%s",
t->name, t->id, state,
@ -1372,7 +1373,7 @@ static inline void debug_xrun_graph(struct pw_impl_node *driver, uint64_t nsec)
a->finish_time,
a->awake_time - a->signal_time,
a->finish_time - a->awake_time,
str_status(a->status));
str_status(status));
}
}
@ -1393,6 +1394,7 @@ static void debug_sync_timeout(struct pw_impl_node *driver, uint64_t nsec)
spa_list_for_each(t, &driver->rt.target_list, link) {
struct pw_node_activation *a = t->activation;
struct pw_node_activation_state *state = &a->state[0];
uint32_t status = SPA_ATOMIC_LOAD(a->status);
if (!a->pending_sync)
continue;
@ -1406,7 +1408,7 @@ static void debug_sync_timeout(struct pw_impl_node *driver, uint64_t nsec)
a->finish_time,
a->awake_time - a->signal_time,
a->finish_time - a->awake_time,
str_status(a->status));
str_status(status));
}
}
@ -1451,8 +1453,8 @@ static inline int process_node(void *data, uint64_t nsec)
return 0;
a->awake_time = nsec;
pw_log_trace_fp("%p: %s process remote:%u exported:%u %"PRIu64" %"PRIu64,
this, this->name, this->remote, this->exported,
pw_log_trace_fp("%p: %s-%d process remote:%u exported:%u %"PRIu64" %"PRIu64,
this, this->name, this->info.id, this->remote, this->exported,
a->signal_time, nsec);
/* when transport sync is not supported, just clear the flag */
@ -1487,7 +1489,8 @@ static inline int process_node(void *data, uint64_t nsec)
PW_NODE_ACTIVATION_FINISHED);
a->finish_time = nsec;
pw_log_trace_fp("%p: finished status:%d %"PRIu64, this, status, nsec);
pw_log_trace_fp("%p: finished status:%d %"PRIu64" was_awake:%d",
this, status, nsec, was_awake);
/* we don't need to trigger targets when the node was driving the
* graph because that means we finished the graph. */
@ -1538,8 +1541,9 @@ static void node_on_fd_events(struct spa_source *source)
nsec / 1000, 0);
}
pw_log_trace_fp("%p: remote:%u exported:%u %s got process %"PRIu64,
this, this->remote, this->exported, this->name, nsec);
pw_log_trace_fp("%p: remote:%u exported:%u %s-%d got process %"PRIu64,
this, this->remote, this->exported, this->name, this->info.id,
nsec);
process_node(this, nsec);
}

View file

@ -656,17 +656,21 @@ static inline void trigger_target_v1(struct pw_node_target *t, uint64_t nsec)
{
struct pw_node_activation *a = t->activation;
struct pw_node_activation_state *state = &a->state[0];
int32_t pending = SPA_ATOMIC_DEC(state->pending);
pw_log_trace_fp("%p: (%s-%u) state:%p pending:%d/%d", t->node,
t->name, t->id, state, state->pending, state->required);
t->name, t->id, state, pending, state->required);
if (pw_node_activation_state_dec(state)) {
if (pending == 0) {
if (SPA_ATOMIC_CAS(a->status,
PW_NODE_ACTIVATION_NOT_TRIGGERED,
PW_NODE_ACTIVATION_TRIGGERED)) {
a->signal_time = nsec;
if (SPA_UNLIKELY(spa_system_eventfd_write(t->system, t->fd, 1) < 0))
pw_log_warn("%p: write failed %m", t->node);
} else {
pw_log_trace_fp("%p: (%s-%u) not ready %d", t->node,
t->name, t->id, a->status);
}
}
}
@ -675,11 +679,12 @@ static inline void trigger_target_v0(struct pw_node_target *t, uint64_t nsec)
{
struct pw_node_activation *a = t->activation;
struct pw_node_activation_state *state = &a->state[0];
int32_t pending = SPA_ATOMIC_DEC(state->pending);
pw_log_trace_fp("%p: (%s-%u) state:%p pending:%d/%d", t->node,
t->name, t->id, state, state->pending, state->required);
t->name, t->id, state, pending, state->required);
if (pw_node_activation_state_dec(state)) {
if (pending == 0) {
SPA_ATOMIC_STORE(a->status, PW_NODE_ACTIVATION_TRIGGERED);
a->signal_time = nsec;
if (SPA_UNLIKELY(spa_system_eventfd_write(t->system, t->fd, 1) < 0))