From a997627906b84e8a8b3bb15216e61f7bc0029539 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 15 Nov 2024 18:06:12 +0100 Subject: [PATCH] impl-node: save all previous timestamps on start When the driver starts, save all previous node timestamps, not just the previous signal time. For async nodes, uses the previous timestamps in the profiler messages so that we get stats with 1 cycle of delay instead of bogus values because the node is still processing. Fixes pw-top for async nodes. --- src/modules/module-profiler.c | 8 ++++---- src/pipewire/impl-node.c | 4 +++- src/pipewire/private.h | 5 ++++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/modules/module-profiler.c b/src/modules/module-profiler.c index 97795b440..75d573248 100644 --- a/src/modules/module-profiler.c +++ b/src/modules/module-profiler.c @@ -285,10 +285,10 @@ static void context_do_profile(void *data) spa_pod_builder_add_struct(&b, SPA_POD_Int(t->id), SPA_POD_String(t->name), - SPA_POD_Long(a->signal_time), - SPA_POD_Long(na->signal_time), - SPA_POD_Long(na->awake_time), - SPA_POD_Long(na->finish_time), + SPA_POD_Long(a->prev_signal_time), + SPA_POD_Long(n->async ? na->prev_signal_time : na->signal_time), + SPA_POD_Long(n->async ? na->prev_awake_time : na->awake_time), + SPA_POD_Long(n->async ? na->prev_finish_time : na->finish_time), SPA_POD_Int(na->status), SPA_POD_Fraction(&latency), SPA_POD_Int(na->xrun_count)); diff --git a/src/pipewire/impl-node.c b/src/pipewire/impl-node.c index cc308ab30..c76953a41 100644 --- a/src/pipewire/impl-node.c +++ b/src/pipewire/impl-node.c @@ -2183,9 +2183,11 @@ retry_status: } else { all_ready &= ta->pending_sync == false; } + ta->prev_signal_time = ta->signal_time; + ta->prev_awake_time = ta->awake_time; + ta->prev_finish_time = ta->finish_time; } - a->prev_signal_time = a->signal_time; node->driver_start = nsec; a->sync_timeout = SPA_MIN(min_timeout, DEFAULT_SYNC_TIMEOUT); diff --git a/src/pipewire/private.h b/src/pipewire/private.h index cffd1e509..89dfc293b 100644 --- a/src/pipewire/private.h +++ b/src/pipewire/private.h @@ -610,7 +610,10 @@ struct pw_node_activation { uint32_t segment_owner[16]; /* id of owners for each segment info struct. * nodes that want to update segment info need to * CAS their node id in this array. */ - uint32_t padding[11]; /* must be 0 */ + uint64_t prev_awake_time; + uint64_t prev_finish_time; + uint32_t padding[7]; /* must be 0 */ + uint32_t client_version; /* verions of client, see above */ uint32_t server_version; /* verions of server, see above */