export-spa: implement with core-proxy

This commit is contained in:
Wim Taymans 2019-12-10 17:09:52 +01:00
parent e2ba3dc6e4
commit 42103a8218

View file

@ -40,7 +40,7 @@ struct data {
struct pw_core_proxy *core_proxy; struct pw_core_proxy *core_proxy;
struct spa_hook core_listener; struct spa_hook core_listener;
struct pw_node *node; struct spa_node *node;
const char *library; const char *library;
const char *factory; const char *factory;
const char *path; const char *path;
@ -67,32 +67,33 @@ static const struct pw_node_proxy_events node_events = {
static int make_node(struct data *data) static int make_node(struct data *data)
{ {
struct pw_factory *factory;
struct pw_properties *props; struct pw_properties *props;
struct spa_handle *hndl;
factory = pw_core_find_factory(data->core, "spa-node-factory"); void *iface;
if (factory == NULL) int res;
return -1;
props = pw_properties_new(SPA_KEY_LIBRARY_NAME, data->library, props = pw_properties_new(SPA_KEY_LIBRARY_NAME, data->library,
SPA_KEY_FACTORY_NAME, data->factory, NULL); SPA_KEY_FACTORY_NAME, data->factory,
NULL);
hndl = pw_core_load_spa_handle(data->core, data->factory, &props->dict);
if (hndl == NULL)
return -errno;
if ((res = spa_handle_get_interface(hndl, SPA_TYPE_INTERFACE_Node, &iface)) < 0)
return res;
data->node = iface;
if (data->path) { if (data->path) {
pw_properties_set(props, PW_KEY_NODE_AUTOCONNECT, "1"); pw_properties_set(props, PW_KEY_NODE_AUTOCONNECT, "1");
pw_properties_set(props, PW_KEY_NODE_TARGET, data->path); pw_properties_set(props, PW_KEY_NODE_TARGET, data->path);
} }
data->node = pw_factory_create_object(factory, data->proxy = pw_core_proxy_export(data->core_proxy,
NULL, SPA_TYPE_INTERFACE_Node, props,
PW_TYPE_INTERFACE_Node, data->node, 0);
PW_VERSION_NODE_PROXY,
props, SPA_ID_INVALID);
if (data->node == NULL)
return -errno;
pw_node_set_active(data->node, true);
data->proxy = pw_core_proxy_export(data->core_proxy, PW_TYPE_INTERFACE_Node, NULL, data->node, 0);
if (data->proxy == NULL) if (data->proxy == NULL)
return -errno; return -errno;