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.
This commit is contained in:
Wim Taymans 2024-02-29 14:07:08 +01:00
parent 94d19f2673
commit ccf899a709
4 changed files with 24 additions and 10 deletions

View file

@ -27,6 +27,8 @@ Node status.
- S = SUSPENDED
- I = IDLE
- R = RUNNING
- t = RUNNING + transport starting
- T = RUNNING + transport running
\endparblock
\par ID

View file

@ -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,
};

View file

@ -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,

View file

@ -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),