jack: report cpu load

Find the driver activation and use it to get stats.
This commit is contained in:
Wim Taymans 2019-08-22 10:59:16 +02:00
parent 2c25b8c216
commit 33cac9932c

View file

@ -276,6 +276,8 @@ struct client {
struct spa_list free_ports[2]; struct spa_list free_ports[2];
struct pw_array links; struct pw_array links;
uint32_t driver_id;
struct pw_node_activation *driver_activation;
struct pw_memmap *mem; struct pw_memmap *mem;
struct pw_node_activation *activation; struct pw_node_activation *activation;
@ -284,6 +286,7 @@ struct client {
int status; int status;
jack_position_t jack_position; jack_position_t jack_position;
}; };
static void init_port_pool(struct client *c, enum spa_direction direction) static void init_port_pool(struct client *c, enum spa_direction direction)
@ -851,6 +854,17 @@ static int client_node_set_param(void *object,
return -ENOTSUP; return -ENOTSUP;
} }
static int update_driver_activation(struct client *c)
{
struct link *link;
pw_log_debug(NAME" %p: driver %d", c, c->driver_id);
link = find_activation(&c->links, c->driver_id);
c->driver_activation = link ? link->activation : NULL;
return 0;
}
static int client_node_set_io(void *object, static int client_node_set_io(void *object,
uint32_t id, uint32_t id,
uint32_t mem_id, uint32_t mem_id,
@ -884,6 +898,8 @@ static int client_node_set_io(void *object,
switch (id) { switch (id) {
case SPA_IO_Position: case SPA_IO_Position:
c->position = ptr; c->position = ptr;
c->driver_id = ptr ? c->position->clock.id : SPA_ID_INVALID;
update_driver_activation(c);
break; break;
default: default:
break; break;
@ -1409,6 +1425,9 @@ static int client_node_set_activation(void *object,
clear_link(c, link); clear_link(c, link);
} }
if (c->driver_id == node_id)
update_driver_activation(c);
exit: exit:
if (res < 0) if (res < 0)
pw_proxy_error((struct pw_proxy*)c->node_proxy, res, spa_strerror(res)); pw_proxy_error((struct pw_proxy*)c->node_proxy, res, spa_strerror(res));
@ -2217,8 +2236,14 @@ int jack_engine_takeover_timebase (jack_client_t *client)
SPA_EXPORT SPA_EXPORT
float jack_cpu_load (jack_client_t *client) float jack_cpu_load (jack_client_t *client)
{ {
pw_log_warn(NAME" %p: not implemented", client); struct client *c = (struct client *) client;
return 0.0; float res = 0.0f;
if (c->driver_activation)
res = c->driver_activation->cpu_load[2];
pw_log_trace(NAME" %p: cpu load %f", client, res);
return res;
} }
SPA_EXPORT SPA_EXPORT