From ccf899a709140b79547b93d8f5eca6b9e79c5257 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 29 Feb 2024 14:07:08 +0100 Subject: [PATCH] profiler: add transport state in the profile block Add transport state to the profiler clock info and show this in pw-top as t and T states. Update the docs some more. --- doc/dox/programs/pw-top.1.md | 2 ++ spa/include/spa/param/profiler.h | 11 +++++++---- src/modules/module-profiler.c | 4 ++-- src/tools/pw-top.c | 17 +++++++++++++---- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/doc/dox/programs/pw-top.1.md b/doc/dox/programs/pw-top.1.md index 5460581b7..c57c33bc4 100644 --- a/doc/dox/programs/pw-top.1.md +++ b/doc/dox/programs/pw-top.1.md @@ -27,6 +27,8 @@ Node status. - S = SUSPENDED - I = IDLE - R = RUNNING +- t = RUNNING + transport starting +- T = RUNNING + transport running \endparblock \par ID diff --git a/spa/include/spa/param/profiler.h b/spa/include/spa/param/profiler.h index 04fac6b26..5d1c94534 100644 --- a/spa/include/spa/param/profiler.h +++ b/spa/include/spa/param/profiler.h @@ -39,7 +39,8 @@ enum spa_profiler { * Long : clock duration, * Long : clock delay, * Double : clock rate_diff, - * Long : clock next_nsec)) */ + * Long : clock next_nsec, + * Int : transport_state)) */ SPA_PROFILER_driverBlock, /**< generic driver info block * (Struct( * Int : driver_id, @@ -48,8 +49,9 @@ enum spa_profiler { * Long : driver signal, * Long : driver awake, * Long : driver finish, - * Int : driver status), - * Fraction : latency)) */ + * Int : driver status, + * Fraction : latency, + * Int : xrun_count)) */ SPA_PROFILER_START_Follower = 0x20000, /**< follower related profiler properties */ SPA_PROFILER_followerBlock, /**< generic follower info block @@ -61,7 +63,8 @@ enum spa_profiler { * Long : awake, * Long : finish, * Int : status, - * Fraction : latency)) */ + * Fraction : latency, + * Int : xrun_count)) */ SPA_PROFILER_START_CUSTOM = 0x1000000, }; diff --git a/src/modules/module-profiler.c b/src/modules/module-profiler.c index c5a9e2602..d1885ba9b 100644 --- a/src/modules/module-profiler.c +++ b/src/modules/module-profiler.c @@ -199,8 +199,8 @@ static void context_do_profile(void *data) SPA_POD_Long(pos->clock.duration), SPA_POD_Long(pos->clock.delay), SPA_POD_Double(pos->clock.rate_diff), - SPA_POD_Long(pos->clock.next_nsec)); - + SPA_POD_Long(pos->clock.next_nsec), + SPA_POD_Int(pos->state)); spa_pod_builder_prop(&b, SPA_PROFILER_driverBlock, 0); spa_pod_builder_add_struct(&b, diff --git a/src/tools/pw-top.c b/src/tools/pw-top.c index ea88678ba..80f162451 100644 --- a/src/tools/pw-top.c +++ b/src/tools/pw-top.c @@ -29,6 +29,7 @@ struct driver { float cpu_load[3]; struct spa_io_clock clock; uint32_t xrun_count; + uint32_t transport_state; }; struct measurement { @@ -130,7 +131,8 @@ static int process_clock(struct data *d, const struct spa_pod *pod, struct drive SPA_POD_Long(&info->clock.duration), SPA_POD_Long(&info->clock.delay), SPA_POD_Double(&info->clock.rate_diff), - SPA_POD_Long(&info->clock.next_nsec)); + SPA_POD_Long(&info->clock.next_nsec), + SPA_POD_OPT_Int(&info->transport_state)); } static struct node *find_node(struct data *d, uint32_t id) @@ -455,7 +457,7 @@ static const char *print_perc(char *buf, bool active, size_t len, uint64_t val, return buf; } -static const char *state_as_string(enum pw_node_state state) +static const char *state_as_string(enum pw_node_state state, uint32_t transport) { switch (state) { case PW_NODE_STATE_ERROR: @@ -467,7 +469,14 @@ static const char *state_as_string(enum pw_node_state state) case PW_NODE_STATE_IDLE: return "I"; case PW_NODE_STATE_RUNNING: - return "R"; + switch (transport) { + case SPA_IO_POSITION_STATE_STARTING: + return "t"; + case SPA_IO_POSITION_STATE_RUNNING: + return "T"; + default: + return "R"; + } } return "!"; } @@ -512,7 +521,7 @@ static void print_node(struct data *d, struct driver *i, struct node *n, int y) busy = -1; print_mode_dependent(d, y, 0, "%s %4.1u %6.1u %6.1u %s %s %s %s %3.1u %16.16s %s%s", - state_as_string(n->state), + state_as_string(n->state, i->transport_state), n->id, frac.num, frac.denom, print_time(buf1, active, 64, waiting),