From ff8aaf9e621afc2663775a30dfdb873f6d20037e Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 10 Jul 2020 12:45:44 +0200 Subject: [PATCH] node: set node io after registering So that we have the right node_id in the position.clock field. --- src/pipewire/impl-node.c | 44 +++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/src/pipewire/impl-node.c b/src/pipewire/impl-node.c index 1ebb9060c..14c025c81 100644 --- a/src/pipewire/impl-node.c +++ b/src/pipewire/impl-node.c @@ -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; }