node: remove redundant info

This commit is contained in:
Wim Taymans 2017-06-02 11:04:18 +02:00
parent dbe20c9934
commit c3aa0f24d2
7 changed files with 23 additions and 31 deletions

View file

@ -869,6 +869,7 @@ static bool link_demarshal_info(void *object, void *data, size_t size)
struct pw_link_info info = { 0, }; struct pw_link_info info = { 0, };
if (!spa_pod_iter_struct(&it, data, size) || 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_iter_get(&it,
SPA_POD_TYPE_INT, &info.id, SPA_POD_TYPE_INT, &info.id,
SPA_POD_TYPE_LONG, &info.change_mask, SPA_POD_TYPE_LONG, &info.change_mask,

View file

@ -273,7 +273,7 @@ on_node_added(struct impl *impl,
pw_log_debug("module %p: node %p added", impl, node); 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); on_node_created(node, info);
} }

View file

@ -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); 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; 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; in_state = PW_PORT_STATE_CONFIGURE;
if (in_state == PW_PORT_STATE_CONFIGURE && out_state > PW_PORT_STATE_CONFIGURE) { if (in_state == PW_PORT_STATE_CONFIGURE && out_state > PW_PORT_STATE_CONFIGURE) {

View file

@ -120,11 +120,11 @@ static int do_negotiate(struct pw_link *this, uint32_t in_state, uint32_t out_st
if (format == NULL) if (format == NULL)
goto error; 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); pw_node_set_state(this->output->node, PW_NODE_STATE_SUSPENDED);
out_state = PW_PORT_STATE_CONFIGURE; 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); pw_node_set_state(this->input->node, PW_NODE_STATE_SUSPENDED);
in_state = PW_PORT_STATE_CONFIGURE; 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) if (this->input == NULL || this->output == NULL)
return SPA_RESULT_OK; return SPA_RESULT_OK;
if (this->input->node->state == PW_NODE_STATE_ERROR || if (this->input->node->info.state == PW_NODE_STATE_ERROR ||
this->output->node->state == PW_NODE_STATE_ERROR) this->output->node->info.state == PW_NODE_STATE_ERROR)
return SPA_RESULT_ERROR; return SPA_RESULT_ERROR;
in_state = this->input->state; 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 && if (this->input->node->n_used_input_links == 0 &&
this->input->node->n_used_output_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); pw_node_update_state(this->input->node, PW_NODE_STATE_IDLE, NULL);
this->input = 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 && if (this->output->node->n_used_input_links == 0 &&
this->output->node->n_used_output_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); pw_node_update_state(this->output->node, PW_NODE_STATE_IDLE, NULL);
this->output = NULL; this->output = NULL;

View file

@ -68,7 +68,6 @@ struct pw_link {
struct pw_link *link, struct pw_port *port)); struct pw_link *link, struct pw_port *port));
struct { struct {
// uint32_t in_ready;
struct pw_port *input; struct pw_port *input;
struct pw_port *output; struct pw_port *output;
struct spa_list input_link; struct spa_list input_link;

View file

@ -164,7 +164,7 @@ static int pause_node(struct pw_node *this)
{ {
int res; int res;
if (this->state <= PW_NODE_STATE_IDLE) if (this->info.state <= PW_NODE_STATE_IDLE)
return SPA_RESULT_OK; return SPA_RESULT_OK;
pw_log_debug("node %p: pause node", this); pw_log_debug("node %p: pause node", this);
@ -405,7 +405,6 @@ static void
update_info(struct pw_node *this) update_info(struct pw_node *this)
{ {
this->info.id = this->global->id; this->info.id = this->global->id;
this->info.name = this->name;
this->info.input_formats = NULL; this->info.input_formats = NULL;
for (this->info.n_input_formats = 0;; this->info.n_input_formats++) { for (this->info.n_input_formats = 0;; this->info.n_input_formats++) {
struct spa_format *fmt; struct spa_format *fmt;
@ -434,8 +433,6 @@ update_info(struct pw_node *this)
sizeof(struct spa_format *) * (this->info.n_output_formats + 1)); 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.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; this->info.props = this->properties ? &this->properties->dict : NULL;
} }
@ -444,6 +441,7 @@ clear_info(struct pw_node *this)
{ {
int i; int i;
free((char*)this->info.name);
if (this->info.input_formats) { if (this->info.input_formats) {
for (i = 0; i < this->info.n_input_formats; i++) for (i = 0; i < this->info.n_input_formats; i++)
free(this->info.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[i]);
free(this->info.output_formats); 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); impl->work = pw_work_queue_new(this->core->main_loop->loop);
this->name = strdup(name); this->info.name = strdup(name);
this->properties = properties; this->properties = properties;
this->node = node; 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->initialized);
pw_signal_init(&this->loop_changed); 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->input_ports);
spa_list_init(&this->output_ports); spa_list_init(&this->output_ports);
@ -590,7 +589,7 @@ struct pw_node *pw_node_new(struct pw_core *core,
return this; return this;
no_mem: no_mem:
free(this->name); free((char *)this->info.name);
free(impl); free(impl);
return NULL; return NULL;
} }
@ -620,8 +619,6 @@ do_node_remove_done(struct spa_loop *loop,
if (this->output_port_map) if (this->output_port_map)
free(this->output_port_map); free(this->output_port_map);
free(this->name);
free(this->error);
if (this->properties) if (this->properties)
pw_properties_free(this->properties); pw_properties_free(this->properties);
clear_info(this); 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; enum pw_node_state old;
old = node->state; old = node->info.state;
if (old != state) { if (old != state) {
struct pw_resource *resource; struct pw_resource *resource;
pw_log_debug("node %p: update state from %s -> %s", node, pw_log_debug("node %p: update state from %s -> %s", node,
pw_node_state_as_string(old), pw_node_state_as_string(state)); pw_node_state_as_string(old), pw_node_state_as_string(state));
if (node->error) if (node->info.error)
free(node->error); free((char*)node->info.error);
node->error = error; node->info.error = error;
node->state = state; node->info.state = state;
pw_signal_emit(&node->state_changed, node, old, state); pw_signal_emit(&node->state_changed, node, old, state);
node->info.change_mask = 1 << 5; 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) { spa_list_for_each(resource, &node->resource_list, link) {
pw_node_notify_info(resource, &node->info); pw_node_notify_info(resource, &node->info);
} }

View file

@ -49,12 +49,10 @@ struct pw_node {
struct pw_global *global; struct pw_global *global;
struct pw_client *owner; struct pw_client *owner;
char *name;
struct pw_properties *properties; struct pw_properties *properties;
struct pw_node_info info; struct pw_node_info info;
enum pw_node_state state;
char *error;
PW_SIGNAL(state_request, (struct pw_listener *listener, PW_SIGNAL(state_request, (struct pw_listener *listener,
struct pw_node *object, enum pw_node_state state)); struct pw_node *object, enum pw_node_state state));
PW_SIGNAL(state_changed, (struct pw_listener *listener, PW_SIGNAL(state_changed, (struct pw_listener *listener,