client-node: don't make add_listener async

It is not really async, the init is async.
This commit is contained in:
Wim Taymans 2019-03-15 20:28:42 +01:00
parent 1ab00fae6d
commit 33afa18621
5 changed files with 14 additions and 11 deletions

View file

@ -490,7 +490,6 @@ static int impl_node_add_listener(struct spa_node *node,
struct node *this; struct node *this;
struct spa_hook_list save; struct spa_hook_list save;
uint32_t i; uint32_t i;
int res = 0;
spa_return_val_if_fail(node != NULL, -EINVAL); 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]) if (this->out_ports[i])
emit_port_info(this, 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); spa_hook_list_join(&this->hooks, &save);
return res; return 0;
} }
static int static int
@ -1003,7 +999,7 @@ client_node_update(void *data,
if (change_mask & PW_CLIENT_NODE_UPDATE_PARAMS) { if (change_mask & PW_CLIENT_NODE_UPDATE_PARAMS) {
uint32_t i; 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++) for (i = 0; i < this->n_params; i++)
free(this->params[i]); free(this->params[i]);
@ -1016,7 +1012,7 @@ client_node_update(void *data,
if (change_mask & PW_CLIENT_NODE_UPDATE_INFO) { if (change_mask & PW_CLIENT_NODE_UPDATE_INFO) {
spa_node_emit_info(&this->hooks, 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; 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.mask = SPA_IO_IN | SPA_IO_ERR | SPA_IO_HUP;
this->data_source.rmask = 0; this->data_source.rmask = 0;
return 0; return SPA_RESULT_RETURN_ASYNC(0);
} }
static int node_clear(struct node *this) 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), pw_resource_get_client(this->resource),
parent, parent,
name, name,
PW_SPA_NODE_FLAG_ASYNC |
(do_register ? 0 : PW_SPA_NODE_FLAG_NO_REGISTER), (do_register ? 0 : PW_SPA_NODE_FLAG_NO_REGISTER),
&impl->node.node, &impl->node.node,
NULL, NULL,

View file

@ -361,7 +361,7 @@ static int impl_node_add_listener(struct spa_node *node,
spa_hook_list_join(&this->hooks, &save); spa_hook_list_join(&this->hooks, &save);
return spa_node_sync(impl->cnode, 0); return 0;
} }
static int static int
@ -1302,6 +1302,7 @@ struct pw_client_stream *pw_client_stream_new(struct pw_resource *resource,
client, client,
parent, parent,
name, name,
PW_SPA_NODE_FLAG_ASYNC |
PW_SPA_NODE_FLAG_ACTIVATE, PW_SPA_NODE_FLAG_ACTIVATE,
&impl->node.node, &impl->node.node,
NULL, NULL,

View file

@ -151,7 +151,7 @@ pw_spa_node_new(struct pw_core *core,
if (res < 0) if (res < 0)
goto clean_node; 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); impl->init_pending = spa_node_sync(impl->node, res);
} else { } else {
complete_init(impl); complete_init(impl);
@ -308,6 +308,9 @@ struct pw_node *pw_spa_node_load(struct pw_core *core,
goto init_failed; 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) { if ((res = spa_handle_get_interface(handle, SPA_TYPE_INTERFACE_Node, &iface)) < 0) {
pw_log_error("can't get node interface %d", res); pw_log_error("can't get node interface %d", res);
goto interface_failed; goto interface_failed;

View file

@ -38,6 +38,7 @@ enum pw_spa_node_flags {
PW_SPA_NODE_FLAG_DISABLE = (1 << 0), PW_SPA_NODE_FLAG_DISABLE = (1 << 0),
PW_SPA_NODE_FLAG_ACTIVATE = (1 << 1), PW_SPA_NODE_FLAG_ACTIVATE = (1 << 1),
PW_SPA_NODE_FLAG_NO_REGISTER = (1 << 2), PW_SPA_NODE_FLAG_NO_REGISTER = (1 << 2),
PW_SPA_NODE_FLAG_ASYNC = (1 << 3),
}; };
struct pw_node * struct pw_node *

View file

@ -428,7 +428,8 @@ pw_registry_proxy_bind(struct pw_registry_proxy *registry,
{ {
struct pw_proxy *reg = (struct pw_proxy*)registry; struct pw_proxy *reg = (struct pw_proxy*)registry;
struct pw_proxy *p = pw_proxy_new(reg, type, user_data_size); 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; return p;
} }