node: set node io after registering

So that we have the right node_id in the position.clock field.
This commit is contained in:
Wim Taymans 2020-07-10 12:45:44 +02:00
parent 8a0a9c8094
commit ff8aaf9e62

View file

@ -576,6 +576,28 @@ static inline void insert_driver(struct pw_context *context, struct pw_impl_node
spa_list_append(&n->driver_link, &node->driver_link);
}
static void update_io(struct pw_impl_node *node)
{
pw_log_debug(NAME" %p: id:%d", node, node->info.id);
if (spa_node_set_io(node->node,
SPA_IO_Position,
&node->rt.activation->position,
sizeof(struct spa_io_position)) >= 0) {
pw_log_debug(NAME" %p: set position %p", node, &node->rt.activation->position);
node->rt.position = &node->rt.activation->position;
} else if (node->driver) {
pw_log_warn(NAME" %p: can't set position on driver", node);
}
if (spa_node_set_io(node->node,
SPA_IO_Clock,
&node->rt.activation->position.clock,
sizeof(struct spa_io_clock)) >= 0) {
pw_log_debug(NAME" %p: set clock %p", node, &node->rt.activation->position.clock);
node->rt.clock = &node->rt.activation->position.clock;
}
}
SPA_EXPORT
int pw_impl_node_register(struct pw_impl_node *this,
struct pw_properties *properties)
@ -638,6 +660,9 @@ int pw_impl_node_register(struct pw_impl_node *this,
pw_global_add_listener(this->global, &this->global_listener, &global_events, this);
pw_global_register(this->global);
if (this->node)
update_io(this);
spa_list_for_each(port, &this->input_ports, link)
pw_impl_port_register(port, NULL);
spa_list_for_each(port, &this->output_ports, link)
@ -1516,22 +1541,9 @@ int pw_impl_node_set_implementation(struct pw_impl_node *node,
spa_node_set_callbacks(node->node, &node_callbacks, node);
res = spa_node_add_listener(node->node, &node->listener, &node_events, node);
if (spa_node_set_io(node->node,
SPA_IO_Position,
&node->rt.activation->position,
sizeof(struct spa_io_position)) >= 0) {
pw_log_debug(NAME" %p: set position %p", node, &node->rt.activation->position);
node->rt.position = &node->rt.activation->position;
} else if (node->driver) {
pw_log_warn(NAME" %p: can't set position on driver", node);
}
if (spa_node_set_io(node->node,
SPA_IO_Clock,
&node->rt.activation->position.clock,
sizeof(struct spa_io_clock)) >= 0) {
pw_log_debug(NAME" %p: set clock %p", node, &node->rt.activation->position.clock);
node->rt.clock = &node->rt.activation->position.clock;
}
if (node->registered)
update_io(node);
return res;
}