node: register ports in the registering event

That way we send registry events in order but only signal global_add
when the node is completely registered.
This commit is contained in:
Wim Taymans 2018-04-24 17:10:17 +02:00
parent 5e89e9421c
commit c4414bc9bc

View file

@ -330,8 +330,22 @@ static void global_destroy(void *data)
pw_node_destroy(this); pw_node_destroy(this);
} }
static void global_registering(void *data)
{
struct pw_node *this = data;
struct pw_port *port;
spa_list_for_each(port, &this->input_ports, link)
pw_port_register(port, this->global->owner, this->global,
pw_properties_copy(port->properties));
spa_list_for_each(port, &this->output_ports, link)
pw_port_register(port, this->global->owner, this->global,
pw_properties_copy(port->properties));
}
static const struct pw_global_events global_events = { static const struct pw_global_events global_events = {
PW_VERSION_GLOBAL_EVENTS, PW_VERSION_GLOBAL_EVENTS,
.registering = global_registering,
.destroy = global_destroy, .destroy = global_destroy,
.bind = global_bind, .bind = global_bind,
}; };
@ -343,7 +357,6 @@ int pw_node_register(struct pw_node *this,
{ {
struct pw_core *core = this->core; struct pw_core *core = this->core;
const char *str; const char *str;
struct pw_port *port;
pw_log_debug("node %p: register", this); pw_log_debug("node %p: register", this);
@ -373,15 +386,8 @@ int pw_node_register(struct pw_node *this,
pw_global_add_listener(this->global, &this->global_listener, &global_events, this); pw_global_add_listener(this->global, &this->global_listener, &global_events, this);
pw_global_register(this->global, owner, parent);
this->info.id = this->global->id; this->info.id = this->global->id;
pw_global_register(this->global, owner, parent);
spa_list_for_each(port, &this->input_ports, link)
pw_port_register(port, owner, this->global,
pw_properties_copy(port->properties));
spa_list_for_each(port, &this->output_ports, link)
pw_port_register(port, owner, this->global,
pw_properties_copy(port->properties));
return pw_node_initialized(this); return pw_node_initialized(this);
} }