client-node: signal graph complete

Use the writefd for waking up the server when the graph completed. Make
this emit the complete event so that the profiler can capture the
data.
This commit is contained in:
Wim Taymans 2023-05-21 15:43:22 +02:00
parent 5c7c12638d
commit 0135a1fc05
2 changed files with 28 additions and 5 deletions

View file

@ -1080,8 +1080,6 @@ static void node_on_data_fd_events(struct spa_source *source)
if (SPA_LIKELY(source->rmask & SPA_IO_IN)) {
uint64_t cmd;
struct pw_impl_node *node = impl->this.node;
struct pw_node_activation *a = node->rt.activation;
int status;
if (SPA_UNLIKELY(spa_system_eventfd_read(impl->data_system,
impl->data_source.fd, &cmd) < 0))
@ -1090,9 +1088,8 @@ static void node_on_data_fd_events(struct spa_source *source)
pw_log_info("(%s-%u) client missed %"PRIu64" wakeups",
node->name, node->info.id, cmd - 1);
status = a->state[0].status;
spa_log_trace_fp(impl->log, "%p: got ready %d", impl, status);
spa_node_call_ready(&impl->callbacks, status);
spa_log_trace_fp(impl->log, "%p: got complete %d", impl, status);
pw_context_driver_emit_complete(node->context, node);
}
}

View file

@ -47,6 +47,7 @@ struct mix {
struct node_data {
struct pw_context *context;
struct spa_hook context_listener;
struct pw_loop *data_loop;
struct spa_system *data_system;
@ -1128,6 +1129,9 @@ static void client_node_removed(void *_data)
spa_hook_remove(&data->proxy_client_node_listener);
spa_hook_remove(&data->client_node_listener);
pw_context_driver_remove_listener(data->context,
&data->context_listener);
if (data->node) {
spa_hook_remove(&data->node_listener);
pw_impl_node_set_state(data->node, PW_NODE_STATE_SUSPENDED);
@ -1164,6 +1168,23 @@ static const struct pw_proxy_events proxy_client_node_events = {
.bound_props = client_node_bound_props,
};
static void context_complete(void *data, struct pw_impl_node *node)
{
struct node_data *d = data;
struct spa_system *data_system = d->data_system;
if (node != d->node || !node->driving)
return;
if (SPA_UNLIKELY(spa_system_eventfd_write(data_system, d->rtwritefd, 1) < 0))
pw_log_warn("node %p: write failed %m", node);
}
static const struct pw_context_driver_events context_events = {
PW_VERSION_CONTEXT_DRIVER_EVENTS,
.complete = context_complete,
};
static inline uint64_t get_time_ns(struct spa_system *system)
{
struct timespec ts;
@ -1225,6 +1246,11 @@ static struct pw_proxy *node_export(struct pw_core *core, void *object, bool do_
&data->client_node_listener,
&client_node_events,
data);
pw_context_driver_add_listener(data->context,
&data->context_listener,
&context_events, data);
do_node_init(data);
return client_node;