From 1646b13e2987d779f6e1204dff4a4dad2e19c180 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 13 Mar 2019 16:02:50 +0100 Subject: [PATCH] node: improve debug --- src/modules/module-client-node/remote-node.c | 1 - .../module-protocol-native/connection.c | 4 +- src/pipewire/node.c | 39 ++++++++++++------- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/modules/module-client-node/remote-node.c b/src/modules/module-client-node/remote-node.c index d145dc656..2211f1bec 100644 --- a/src/modules/module-client-node/remote-node.c +++ b/src/modules/module-client-node/remote-node.c @@ -1131,7 +1131,6 @@ static void node_free(void *data) if (remote->core_proxy) pw_core_proxy_destroy(remote->core_proxy, proxy); - spa_hook_remove(&d->proxy_listener); } diff --git a/src/modules/module-protocol-native/connection.c b/src/modules/module-protocol-native/connection.c index 8ea64976e..c502d3bf7 100644 --- a/src/modules/module-protocol-native/connection.c +++ b/src/modules/module-protocol-native/connection.c @@ -222,9 +222,9 @@ struct pw_protocol_native_connection *pw_protocol_native_connection_new(struct p this->fd = fd; spa_hook_list_init(&this->listener_list); - impl->out.buffer_data = malloc(MAX_BUFFER_SIZE); + impl->out.buffer_data = calloc(1, MAX_BUFFER_SIZE); impl->out.buffer_maxsize = MAX_BUFFER_SIZE; - impl->in.buffer_data = malloc(MAX_BUFFER_SIZE); + impl->in.buffer_data = calloc(1, MAX_BUFFER_SIZE); impl->in.buffer_maxsize = MAX_BUFFER_SIZE; impl->in.update = true; impl->core = core; diff --git a/src/pipewire/node.c b/src/pipewire/node.c index 263748fbe..825a81fa1 100644 --- a/src/pipewire/node.c +++ b/src/pipewire/node.c @@ -600,9 +600,13 @@ static void dump_states(struct pw_node *driver) spa_list_for_each(t, &driver->rt.target_list, link) { struct pw_node_activation *a = t->activation; - pw_log_warn("node %p: required:%d waiting:%"PRIu64 - " process:%"PRIu64" status:%d", - t->node, a->state[0].required, + pw_log_warn("node %p (%s): required:%d s:%"PRIu64" a:%"PRIu64" f:%"PRIu64 + " waiting:%"PRIu64" process:%"PRIu64" status:%d", + t->node, t->node ? t->node->info.name : "", + a->state[0].required, + a->signal_time, + a->awake_time, + a->finish_time, a->awake_time - a->signal_time, a->finish_time - a->awake_time, t->activation->status); @@ -651,28 +655,30 @@ static inline int process_node(void *data) struct pw_node *this = data; struct timespec ts; struct pw_port *p; - struct pw_node_activation *activation = this->rt.activation; + struct pw_node_activation *a = this->rt.activation; int status; pw_log_trace("node %p: process", this); clock_gettime(CLOCK_MONOTONIC, &ts); - activation->status = AWAKE; - activation->awake_time = SPA_TIMESPEC_TO_NSEC(&ts); + a->status = AWAKE; + a->awake_time = SPA_TIMESPEC_TO_NSEC(&ts); spa_list_for_each(p, &this->rt.input_mix, rt.node_link) spa_node_process(p->mix); status = spa_node_process(this->node); - activation->state[0].status = status; + a->state[0].status = status; if (this == this->driver_node && !this->exported) { clock_gettime(CLOCK_MONOTONIC, &ts); - activation->status = FINISHED; - activation->signal_time = activation->finish_time; - activation->finish_time = SPA_TIMESPEC_TO_NSEC(&ts); - activation->running = false; - pw_log_trace("node %p: graph completed", this); + a->status = FINISHED; + a->signal_time = a->finish_time; + a->finish_time = SPA_TIMESPEC_TO_NSEC(&ts); + a->running = false; + pw_log_trace("node %p: graph completed wait:%"PRIu64" run:%"PRIu64, this, + a->awake_time - a->signal_time, + a->finish_time - a->awake_time); } else if (status == SPA_STATUS_OK) { pw_log_trace("node %p: async continue", this); } else { @@ -710,17 +716,20 @@ struct pw_node *pw_node_new(struct pw_core *core, struct impl *impl; struct pw_node *this; size_t size; + char *n; impl = calloc(1, sizeof(struct impl) + user_data_size); if (impl == NULL) goto error; if (name == NULL) - name = "node"; + asprintf(&n, "node"); + else + n = strdup(name); this = &impl->this; this->core = core; - pw_log_debug("node %p: new \"%s\"", this, name); + pw_log_debug("node %p: new \"%s\"", this, n); if (user_data_size > 0) this->user_data = SPA_MEMBER(impl, sizeof(struct impl), void); @@ -755,7 +764,7 @@ struct pw_node *pw_node_new(struct pw_core *core, if (impl->work == NULL) goto clean_impl; - this->info.name = strdup(name); + this->info.name = n; this->data_loop = core->data_loop;