impl-node: improve signal_time

For remote nodes, set the signal time before we wake up the server. For
non-remote nodes, ser the signal time in node_ready. This ensures we
take the time to start the graph into account.
This commit is contained in:
Wim Taymans 2023-05-06 18:51:49 +02:00
parent a0a5320280
commit a20d2406c3
2 changed files with 11 additions and 1 deletions

View file

@ -1178,6 +1178,12 @@ static const struct pw_proxy_events proxy_client_node_events = {
.bound_props = client_node_bound_props,
};
static inline uint64_t get_time_ns(struct spa_system *system)
{
struct timespec ts;
spa_system_clock_gettime(system, CLOCK_MONOTONIC, &ts);
return SPA_TIMESPEC_TO_NSEC(&ts);
}
static int node_ready(void *d, int status)
{
struct node_data *data = d;
@ -1195,6 +1201,7 @@ static int node_ready(void *d, int status)
}
a->state[0].status = status;
a->signal_time = get_time_ns(data_system);
if (SPA_UNLIKELY(spa_system_eventfd_write(data_system, data->rtwritefd, 1) < 0))
pw_log_warn("node %p: write failed %m", node);

View file

@ -1719,6 +1719,7 @@ static int node_ready(void *data, int status)
}
node_signal_func(node);
} else {
uint64_t signal_time = a->signal_time;
/* old nodes set the TRIGGERED status on node_ready, patch this
* up here to avoid errors in pw-top */
a->status = PW_NODE_ACTIVATION_FINISHED;
@ -1739,6 +1740,7 @@ static int node_ready(void *data, int status)
pw_context_driver_emit_complete(node->context, node);
a->prev_signal_time = a->signal_time;
a->signal_time = signal_time;
}
/* This update is done too late, the driver should do this
@ -1791,7 +1793,8 @@ again:
}
a->status = PW_NODE_ACTIVATION_TRIGGERED;
a->signal_time = nsec;
if (!node->remote)
a->signal_time = nsec;
impl->prev_signal_time = a->prev_signal_time;
a->prev_signal_time = a->signal_time;