From 33afa186212555fafb20d1ef9a11960ff3bca4ab Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 15 Mar 2019 20:28:42 +0100 Subject: [PATCH] client-node: don't make add_listener async It is not really async, the init is async. --- src/modules/module-client-node/client-node.c | 13 +++++-------- src/modules/module-client-node/client-stream.c | 3 ++- src/modules/spa/spa-node.c | 5 ++++- src/modules/spa/spa-node.h | 1 + src/pipewire/interfaces.h | 3 ++- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/modules/module-client-node/client-node.c b/src/modules/module-client-node/client-node.c index b00eb7f6a..629c29b9f 100644 --- a/src/modules/module-client-node/client-node.c +++ b/src/modules/module-client-node/client-node.c @@ -490,7 +490,6 @@ static int impl_node_add_listener(struct spa_node *node, struct node *this; struct spa_hook_list save; uint32_t i; - int res = 0; spa_return_val_if_fail(node != NULL, -EINVAL); @@ -505,12 +504,9 @@ static int impl_node_add_listener(struct spa_node *node, if (this->out_ports[i]) emit_port_info(this, this->out_ports[i]); } - if (this->resource) - res = pw_resource_ping(this->resource, 0); - spa_hook_list_join(&this->hooks, &save); - return res; + return 0; } static int @@ -1003,7 +999,7 @@ client_node_update(void *data, if (change_mask & PW_CLIENT_NODE_UPDATE_PARAMS) { uint32_t i; - spa_log_debug(this->log, "node %p: update %d params", this, n_params); + pw_log_debug("node %p: update %d params", this, n_params); for (i = 0; i < this->n_params; i++) free(this->params[i]); @@ -1016,7 +1012,7 @@ client_node_update(void *data, if (change_mask & PW_CLIENT_NODE_UPDATE_INFO) { spa_node_emit_info(&this->hooks, info); } - spa_log_debug(this->log, "node %p: got node update", this); + pw_log_debug("node %p: got node update", this); return 0; } @@ -1165,7 +1161,7 @@ node_init(struct node *this, this->data_source.mask = SPA_IO_IN | SPA_IO_ERR | SPA_IO_HUP; this->data_source.rmask = 0; - return 0; + return SPA_RESULT_RETURN_ASYNC(0); } static int node_clear(struct node *this) @@ -1653,6 +1649,7 @@ struct pw_client_node *pw_client_node_new(struct pw_resource *resource, pw_resource_get_client(this->resource), parent, name, + PW_SPA_NODE_FLAG_ASYNC | (do_register ? 0 : PW_SPA_NODE_FLAG_NO_REGISTER), &impl->node.node, NULL, diff --git a/src/modules/module-client-node/client-stream.c b/src/modules/module-client-node/client-stream.c index b95388429..c6a16196e 100644 --- a/src/modules/module-client-node/client-stream.c +++ b/src/modules/module-client-node/client-stream.c @@ -361,7 +361,7 @@ static int impl_node_add_listener(struct spa_node *node, spa_hook_list_join(&this->hooks, &save); - return spa_node_sync(impl->cnode, 0); + return 0; } static int @@ -1302,6 +1302,7 @@ struct pw_client_stream *pw_client_stream_new(struct pw_resource *resource, client, parent, name, + PW_SPA_NODE_FLAG_ASYNC | PW_SPA_NODE_FLAG_ACTIVATE, &impl->node.node, NULL, diff --git a/src/modules/spa/spa-node.c b/src/modules/spa/spa-node.c index 4aa5fbc0e..f0a0aba93 100644 --- a/src/modules/spa/spa-node.c +++ b/src/modules/spa/spa-node.c @@ -151,7 +151,7 @@ pw_spa_node_new(struct pw_core *core, if (res < 0) goto clean_node; - if (SPA_RESULT_IS_ASYNC(res)) { + if (flags & PW_SPA_NODE_FLAG_ASYNC) { impl->init_pending = spa_node_sync(impl->node, res); } else { complete_init(impl); @@ -308,6 +308,9 @@ struct pw_node *pw_spa_node_load(struct pw_core *core, goto init_failed; } + if (SPA_RESULT_IS_ASYNC(res)) + flags |= PW_SPA_NODE_FLAG_ASYNC; + if ((res = spa_handle_get_interface(handle, SPA_TYPE_INTERFACE_Node, &iface)) < 0) { pw_log_error("can't get node interface %d", res); goto interface_failed; diff --git a/src/modules/spa/spa-node.h b/src/modules/spa/spa-node.h index 92a122d77..caa188132 100644 --- a/src/modules/spa/spa-node.h +++ b/src/modules/spa/spa-node.h @@ -38,6 +38,7 @@ enum pw_spa_node_flags { PW_SPA_NODE_FLAG_DISABLE = (1 << 0), PW_SPA_NODE_FLAG_ACTIVATE = (1 << 1), PW_SPA_NODE_FLAG_NO_REGISTER = (1 << 2), + PW_SPA_NODE_FLAG_ASYNC = (1 << 3), }; struct pw_node * diff --git a/src/pipewire/interfaces.h b/src/pipewire/interfaces.h index 9320c455d..7ad0a94ac 100644 --- a/src/pipewire/interfaces.h +++ b/src/pipewire/interfaces.h @@ -428,7 +428,8 @@ pw_registry_proxy_bind(struct pw_registry_proxy *registry, { struct pw_proxy *reg = (struct pw_proxy*)registry; struct pw_proxy *p = pw_proxy_new(reg, type, user_data_size); - pw_proxy_do(reg, struct pw_registry_proxy_methods, bind, id, type, version, pw_proxy_get_id(p)); + pw_proxy_do(reg, struct pw_registry_proxy_methods, bind, + id, type, version, pw_proxy_get_id(p)); return p; }