core: do a bind to a new node

If a create-node creates a new node, do a bind to the global of
the node to make sure the client gets the node-info.
This commit is contained in:
Wim Taymans 2017-09-15 14:59:42 +02:00
parent d9bae8f38b
commit 2f9c57ec01

View file

@ -170,18 +170,22 @@ core_create_node(void *object,
uint32_t new_id) uint32_t new_id)
{ {
struct pw_resource *resource = object; struct pw_resource *resource = object;
struct pw_resource *node_resource; struct pw_resource *node_resource = NULL;
struct pw_client *client = resource->client; struct pw_client *client = resource->client;
struct pw_node_factory *factory; struct pw_node_factory *factory;
struct pw_node *node;
struct pw_properties *properties; struct pw_properties *properties;
int res;
factory = pw_core_find_node_factory(client->core, factory_name); factory = pw_core_find_node_factory(client->core, factory_name);
if (factory == NULL) if (factory == NULL)
goto no_factory; goto no_factory;
node_resource = pw_resource_new(client, new_id, PW_PERM_RWX, type, version, 0); if (type != client->core->type.node) {
if (node_resource == NULL) node_resource = pw_resource_new(client, new_id, PW_PERM_RWX, type, version, 0);
goto no_resource; if (node_resource == NULL)
goto no_resource;
}
if (props) { if (props) {
properties = pw_properties_new_dict(props); properties = pw_properties_new_dict(props);
@ -191,16 +195,25 @@ core_create_node(void *object,
properties = NULL; properties = NULL;
/* error will be posted */ /* error will be posted */
pw_node_factory_create_node(factory, node_resource, name, properties); node = pw_node_factory_create_node(factory, node_resource, name, properties);
if (node == NULL)
goto no_mem;
if (type == client->core->type.node) {
res = pw_global_bind(pw_node_get_global(node), client, PW_PERM_RWX, version, new_id);
if (res < 0)
goto no_bind;
}
properties = NULL; properties = NULL;
done: done:
return; return;
no_factory: no_factory:
pw_log_error("can't find node factory"); pw_log_error("can't find node factory %s", factory_name);
pw_core_resource_error(client->core_resource, pw_core_resource_error(client->core_resource,
resource->id, SPA_RESULT_INVALID_ARGUMENTS, "unknown factory name"); resource->id, SPA_RESULT_INVALID_ARGUMENTS, "unknown factory name %s", factory_name);
goto done; goto done;
no_resource: no_resource:
@ -214,6 +227,10 @@ core_create_node(void *object,
pw_core_resource_error(client->core_resource, pw_core_resource_error(client->core_resource,
resource->id, SPA_RESULT_NO_MEMORY, "no memory"); resource->id, SPA_RESULT_NO_MEMORY, "no memory");
goto done; goto done;
no_bind:
pw_core_resource_error(client->core_resource,
resource->id, res, "can't bind node: %d", res);
goto done;
} }
static void static void