From c3aa0f24d2dfc33b2feaf2b9ac5012387e7ee968 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 2 Jun 2017 11:04:18 +0200 Subject: [PATCH] node: remove redundant info --- pipewire/client/protocol-native.c | 1 + pipewire/modules/module-autolink.c | 2 +- pipewire/server/core.c | 4 ++-- pipewire/server/link.c | 12 ++++++------ pipewire/server/link.h | 1 - pipewire/server/node.c | 28 +++++++++++----------------- pipewire/server/node.h | 6 ++---- 7 files changed, 23 insertions(+), 31 deletions(-) diff --git a/pipewire/client/protocol-native.c b/pipewire/client/protocol-native.c index 8d73324b6..76456e099 100644 --- a/pipewire/client/protocol-native.c +++ b/pipewire/client/protocol-native.c @@ -869,6 +869,7 @@ static bool link_demarshal_info(void *object, void *data, size_t size) struct pw_link_info info = { 0, }; if (!spa_pod_iter_struct(&it, data, size) || + !pw_pod_remap_data(SPA_POD_TYPE_STRUCT, data, size, &proxy->context->types) || !spa_pod_iter_get(&it, SPA_POD_TYPE_INT, &info.id, SPA_POD_TYPE_LONG, &info.change_mask, diff --git a/pipewire/modules/module-autolink.c b/pipewire/modules/module-autolink.c index 6b17005df..c0772083c 100644 --- a/pipewire/modules/module-autolink.c +++ b/pipewire/modules/module-autolink.c @@ -273,7 +273,7 @@ on_node_added(struct impl *impl, pw_log_debug("module %p: node %p added", impl, node); - if (node->state > PW_NODE_STATE_CREATING) + if (node->info.state > PW_NODE_STATE_CREATING) on_node_created(node, info); } diff --git a/pipewire/server/core.c b/pipewire/server/core.c index 31a8b9a28..0d1eaaf00 100644 --- a/pipewire/server/core.c +++ b/pipewire/server/core.c @@ -688,9 +688,9 @@ struct spa_format *pw_core_find_format(struct pw_core *core, pw_log_debug("core %p: finding best format %d %d", core, out_state, in_state); - if (out_state > PW_PORT_STATE_CONFIGURE && output->node->state == PW_NODE_STATE_IDLE) + if (out_state > PW_PORT_STATE_CONFIGURE && output->node->info.state == PW_NODE_STATE_IDLE) out_state = PW_PORT_STATE_CONFIGURE; - if (in_state > PW_PORT_STATE_CONFIGURE && input->node->state == PW_NODE_STATE_IDLE) + if (in_state > PW_PORT_STATE_CONFIGURE && input->node->info.state == PW_NODE_STATE_IDLE) in_state = PW_PORT_STATE_CONFIGURE; if (in_state == PW_PORT_STATE_CONFIGURE && out_state > PW_PORT_STATE_CONFIGURE) { diff --git a/pipewire/server/link.c b/pipewire/server/link.c index 3616e86de..ca31afa21 100644 --- a/pipewire/server/link.c +++ b/pipewire/server/link.c @@ -120,11 +120,11 @@ static int do_negotiate(struct pw_link *this, uint32_t in_state, uint32_t out_st if (format == NULL) goto error; - if (out_state > PW_PORT_STATE_CONFIGURE && this->output->node->state == PW_NODE_STATE_IDLE) { + if (out_state > PW_PORT_STATE_CONFIGURE && this->output->node->info.state == PW_NODE_STATE_IDLE) { pw_node_set_state(this->output->node, PW_NODE_STATE_SUSPENDED); out_state = PW_PORT_STATE_CONFIGURE; } - if (in_state > PW_PORT_STATE_CONFIGURE && this->input->node->state == PW_NODE_STATE_IDLE) { + if (in_state > PW_PORT_STATE_CONFIGURE && this->input->node->info.state == PW_NODE_STATE_IDLE) { pw_node_set_state(this->input->node, PW_NODE_STATE_SUSPENDED); in_state = PW_PORT_STATE_CONFIGURE; } @@ -683,8 +683,8 @@ static int check_states(struct pw_link *this, void *user_data, int res) if (this->input == NULL || this->output == NULL) return SPA_RESULT_OK; - if (this->input->node->state == PW_NODE_STATE_ERROR || - this->output->node->state == PW_NODE_STATE_ERROR) + if (this->input->node->info.state == PW_NODE_STATE_ERROR || + this->output->node->info.state == PW_NODE_STATE_ERROR) return SPA_RESULT_ERROR; in_state = this->input->state; @@ -959,7 +959,7 @@ do_link_remove_done(struct spa_loop *loop, if (this->input->node->n_used_input_links == 0 && this->input->node->n_used_output_links == 0 && - this->input->node->state > PW_NODE_STATE_IDLE) + this->input->node->info.state > PW_NODE_STATE_IDLE) pw_node_update_state(this->input->node, PW_NODE_STATE_IDLE, NULL); this->input = NULL; @@ -972,7 +972,7 @@ do_link_remove_done(struct spa_loop *loop, if (this->output->node->n_used_input_links == 0 && this->output->node->n_used_output_links == 0 && - this->output->node->state > PW_NODE_STATE_IDLE) + this->output->node->info.state > PW_NODE_STATE_IDLE) pw_node_update_state(this->output->node, PW_NODE_STATE_IDLE, NULL); this->output = NULL; diff --git a/pipewire/server/link.h b/pipewire/server/link.h index 878ddd073..30e7e922b 100644 --- a/pipewire/server/link.h +++ b/pipewire/server/link.h @@ -68,7 +68,6 @@ struct pw_link { struct pw_link *link, struct pw_port *port)); struct { -// uint32_t in_ready; struct pw_port *input; struct pw_port *output; struct spa_list input_link; diff --git a/pipewire/server/node.c b/pipewire/server/node.c index 24350f8c5..149368294 100644 --- a/pipewire/server/node.c +++ b/pipewire/server/node.c @@ -164,7 +164,7 @@ static int pause_node(struct pw_node *this) { int res; - if (this->state <= PW_NODE_STATE_IDLE) + if (this->info.state <= PW_NODE_STATE_IDLE) return SPA_RESULT_OK; pw_log_debug("node %p: pause node", this); @@ -405,7 +405,6 @@ static void update_info(struct pw_node *this) { this->info.id = this->global->id; - this->info.name = this->name; this->info.input_formats = NULL; for (this->info.n_input_formats = 0;; this->info.n_input_formats++) { struct spa_format *fmt; @@ -434,8 +433,6 @@ update_info(struct pw_node *this) sizeof(struct spa_format *) * (this->info.n_output_formats + 1)); this->info.output_formats[this->info.n_output_formats] = spa_format_copy(fmt); } - this->info.state = this->state; - this->info.error = this->error; this->info.props = this->properties ? &this->properties->dict : NULL; } @@ -444,6 +441,7 @@ clear_info(struct pw_node *this) { int i; + free((char*)this->info.name); if (this->info.input_formats) { for (i = 0; i < this->info.n_input_formats; i++) free(this->info.input_formats[i]); @@ -455,6 +453,7 @@ clear_info(struct pw_node *this) free(this->info.output_formats[i]); free(this->info.output_formats); } + free((char*)this->info.error); } @@ -536,7 +535,7 @@ struct pw_node *pw_node_new(struct pw_core *core, impl->work = pw_work_queue_new(this->core->main_loop->loop); - this->name = strdup(name); + this->info.name = strdup(name); this->properties = properties; this->node = node; @@ -558,7 +557,7 @@ struct pw_node *pw_node_new(struct pw_core *core, pw_signal_init(&this->initialized); pw_signal_init(&this->loop_changed); - this->state = PW_NODE_STATE_CREATING; + this->info.state = PW_NODE_STATE_CREATING; spa_list_init(&this->input_ports); spa_list_init(&this->output_ports); @@ -590,7 +589,7 @@ struct pw_node *pw_node_new(struct pw_core *core, return this; no_mem: - free(this->name); + free((char *)this->info.name); free(impl); return NULL; } @@ -620,8 +619,6 @@ do_node_remove_done(struct spa_loop *loop, if (this->output_port_map) free(this->output_port_map); - free(this->name); - free(this->error); if (this->properties) pw_properties_free(this->properties); clear_info(this); @@ -849,24 +846,21 @@ void pw_node_update_state(struct pw_node *node, enum pw_node_state state, char * { enum pw_node_state old; - old = node->state; + old = node->info.state; if (old != state) { struct pw_resource *resource; pw_log_debug("node %p: update state from %s -> %s", node, pw_node_state_as_string(old), pw_node_state_as_string(state)); - if (node->error) - free(node->error); - node->error = error; - node->state = state; + if (node->info.error) + free((char*)node->info.error); + node->info.error = error; + node->info.state = state; pw_signal_emit(&node->state_changed, node, old, state); node->info.change_mask = 1 << 5; - node->info.state = node->state; - node->info.error = node->error; - spa_list_for_each(resource, &node->resource_list, link) { pw_node_notify_info(resource, &node->info); } diff --git a/pipewire/server/node.h b/pipewire/server/node.h index db4cf5813..66eaf08c3 100644 --- a/pipewire/server/node.h +++ b/pipewire/server/node.h @@ -49,12 +49,10 @@ struct pw_node { struct pw_global *global; struct pw_client *owner; - char *name; struct pw_properties *properties; - struct pw_node_info info; - enum pw_node_state state; - char *error; + struct pw_node_info info; + PW_SIGNAL(state_request, (struct pw_listener *listener, struct pw_node *object, enum pw_node_state state)); PW_SIGNAL(state_changed, (struct pw_listener *listener,