core: remove parent_id from the global event

Remove the parent_id from the global event. Remove the parent
and owner from the global object.

Use properties instead to mark parents and owners of objects.

Properties are easier to control for client exported objects and
usually a simple parent/child is not enough. For example, a client
exported node has the client as a parent but also the factory that
created the node.
This commit is contained in:
Wim Taymans 2019-08-16 22:11:42 +02:00
parent 32ce5c4deb
commit 8db4a797aa
58 changed files with 482 additions and 464 deletions

View file

@ -38,6 +38,8 @@
#include "modules/spa/spa-node.h"
#include "module-adapter/adapter.h"
#define NAME "adapter"
#define FACTORY_USAGE SPA_KEY_FACTORY_NAME"=<factory-name> " \
"["SPA_KEY_LIBRARY_NAME"=<library-name>] " \
ADAPTER_USAGE
@ -117,6 +119,8 @@ static void *create_object(void *_data,
if (properties == NULL)
goto error_properties;
pw_properties_setf(properties, PW_KEY_FACTORY_ID, "%d", d->this->global->id);
slave = NULL;
str = pw_properties_get(properties, "adapt.slave.node");
if (str != NULL) {
@ -131,8 +135,6 @@ static void *create_object(void *_data,
goto error_properties;
slave = pw_spa_node_load(d->core,
NULL,
pw_factory_get_global(d->this),
factory_name,
PW_SPA_NODE_FLAG_ACTIVATE |
PW_SPA_NODE_FLAG_NO_REGISTER,
@ -164,7 +166,7 @@ static void *create_object(void *_data,
client = resource ? pw_resource_get_client(resource): NULL;
pw_node_register(adapter, client, pw_module_get_global(d->module), NULL);
pw_node_register(adapter, NULL);
if (client) {
struct pw_resource *bound_resource;
@ -231,12 +233,32 @@ static void module_destroy(void *data)
pw_factory_destroy(d->this);
}
static void module_registered(void *data)
{
struct factory_data *d = data;
struct pw_module *module = d->module;
struct pw_factory *factory = d->this;
struct spa_dict_item items[1];
char id[16];
int res;
snprintf(id, sizeof(id), "%d", module->global->id);
items[0] = SPA_DICT_ITEM_INIT(PW_KEY_MODULE_ID, id);
pw_factory_update_properties(factory, &SPA_DICT_INIT(items, 1));
if ((res = pw_factory_register(factory, NULL)) < 0) {
pw_log_error(NAME" %p: can't register factory: %s", factory, spa_strerror(res));
}
}
static const struct pw_module_events module_events = {
PW_VERSION_MODULE_EVENTS,
.destroy = module_destroy,
.registered = module_registered,
};
static int module_init(struct pw_module *module, struct pw_properties *properties)
SPA_EXPORT
int pipewire__module_init(struct pw_module *module, const char *args)
{
struct pw_core *core = pw_module_get_core(module);
struct pw_factory *factory;
@ -265,17 +287,9 @@ static int module_init(struct pw_module *module, struct pw_properties *propertie
&impl_factory,
data);
pw_factory_register(factory, NULL, pw_module_get_global(module), NULL);
pw_module_update_properties(module, &SPA_DICT_INIT_ARRAY(module_props));
pw_module_add_listener(module, &data->module_listener, &module_events, data);
pw_module_update_properties(module, &SPA_DICT_INIT_ARRAY(module_props));
return 0;
}
SPA_EXPORT
int pipewire__module_init(struct pw_module *module, const char *args)
{
return module_init(module, NULL);
}

View file

@ -384,7 +384,7 @@ struct pw_node *pw_adapter_new(struct pw_core *core,
goto error;
}
node = pw_spa_node_load(core, NULL, NULL,
node = pw_spa_node_load(core,
factory_name,
PW_SPA_NODE_FLAG_ACTIVATE | PW_SPA_NODE_FLAG_NO_REGISTER,
pw_properties_copy(props),

View file

@ -33,6 +33,8 @@
#include "module-client-device/client-device.h"
#define NAME "client-device"
static const struct spa_dict_item module_props[] = {
{ PW_KEY_MODULE_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
{ PW_KEY_MODULE_DESCRIPTION, "Allow clients to create and control remote devices" },
@ -47,7 +49,6 @@ struct pw_protocol *pw_protocol_native_ext_client_device_init(struct pw_core *co
struct factory_data {
struct pw_factory *this;
struct pw_properties *properties;
struct pw_module *module;
struct spa_hook module_listener;
@ -64,7 +65,6 @@ static void *create_object(void *_data,
{
void *result;
struct pw_resource *device_resource;
struct pw_global *parent;
struct pw_client *client = pw_resource_get_client(resource);
int res;
@ -74,9 +74,7 @@ static void *create_object(void *_data,
goto error_resource;
}
parent = pw_client_get_global(client);
result = pw_client_device_new(device_resource, parent, properties);
result = pw_client_device_new(device_resource, properties);
if (result == NULL) {
res = -errno;
goto error_device;
@ -111,20 +109,37 @@ static void module_destroy(void *data)
spa_hook_remove(&d->module_listener);
if (d->properties)
pw_properties_free(d->properties);
spa_list_remove(&d->export_spadevice.link);
pw_factory_destroy(d->this);
}
static void module_registered(void *data)
{
struct factory_data *d = data;
struct pw_module *module = d->module;
struct pw_factory *factory = d->this;
struct spa_dict_item items[1];
char id[16];
int res;
snprintf(id, sizeof(id), "%d", pw_global_get_id(pw_module_get_global(module)));
items[0] = SPA_DICT_ITEM_INIT(PW_KEY_MODULE_ID, id);
pw_factory_update_properties(factory, &SPA_DICT_INIT(items, 1));
if ((res = pw_factory_register(factory, NULL)) < 0) {
pw_log_error(NAME" %p: can't register factory: %s", factory, spa_strerror(res));
}
}
static const struct pw_module_events module_events = {
PW_VERSION_MODULE_EVENTS,
.destroy = module_destroy,
.registered = module_registered,
};
static int module_init(struct pw_module *module, struct pw_properties *properties)
SPA_EXPORT
int pipewire__module_init(struct pw_module *module, const char *args)
{
struct pw_core *core = pw_module_get_core(module);
struct pw_factory *factory;
@ -144,7 +159,6 @@ static int module_init(struct pw_module *module, struct pw_properties *propertie
data = pw_factory_get_user_data(factory);
data->this = factory;
data->module = module;
data->properties = properties;
pw_log_debug("module %p: new", module);
@ -154,8 +168,6 @@ static int module_init(struct pw_module *module, struct pw_properties *propertie
pw_protocol_native_ext_client_device_init(core);
pw_factory_register(factory, NULL, pw_module_get_global(module), NULL);
data->export_spadevice.type = SPA_TYPE_INTERFACE_Device;
data->export_spadevice.func = pw_remote_spa_device_export;
pw_core_register_export_type(core, &data->export_spadevice);
@ -166,9 +178,3 @@ static int module_init(struct pw_module *module, struct pw_properties *propertie
return 0;
}
SPA_EXPORT
int pipewire__module_init(struct pw_module *module, const char *args)
{
return module_init(module, NULL);
}

View file

@ -35,7 +35,6 @@ extern "C" {
struct pw_device *
pw_client_device_new(struct pw_resource *resource,
struct pw_global *parent,
struct pw_properties *properties);
#ifdef __cplusplus

View file

@ -48,7 +48,6 @@ struct impl {
struct spa_hook resource_listener;
struct spa_hook object_listener;
struct pw_global *parent;
unsigned int registered:1;
};
@ -56,7 +55,9 @@ static void device_info(void *data, const struct spa_device_info *info)
{
struct impl *impl = data;
if (!impl->registered) {
pw_device_register(impl->device, impl->resource->client, impl->parent, NULL);
pw_device_register(impl->device, NULL);
pw_device_set_implementation(impl->device,
(struct spa_device*)impl->resource);
impl->registered = true;
}
}
@ -103,7 +104,6 @@ static const struct pw_device_events device_events = {
};
struct pw_device *pw_client_device_new(struct pw_resource *resource,
struct pw_global *parent,
struct pw_properties *properties)
{
struct impl *impl;
@ -111,6 +111,13 @@ struct pw_device *pw_client_device_new(struct pw_resource *resource,
struct pw_client *client = pw_resource_get_client(resource);
struct pw_core *core = pw_client_get_core(client);
if (properties == NULL)
properties = pw_properties_new(NULL, NULL);
if (properties == NULL)
return NULL;
pw_properties_setf(properties, PW_KEY_CLIENT_ID, "%d", client->global->id);
device = pw_device_new(core, properties, sizeof(struct impl));
if (device == NULL)
return NULL;
@ -119,13 +126,10 @@ struct pw_device *pw_client_device_new(struct pw_resource *resource,
impl->device = device;
impl->core = core;
impl->resource = resource;
impl->parent = parent;
pw_device_add_listener(impl->device,
&impl->device_listener,
&device_events, impl);
pw_device_set_implementation(device,
(struct spa_device*)resource);
pw_resource_add_listener(impl->resource,
&impl->resource_listener,

View file

@ -33,6 +33,8 @@
#include "module-client-node/client-node.h"
#define NAME "client-node"
static const struct spa_dict_item module_props[] = {
{ PW_KEY_MODULE_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
{ PW_KEY_MODULE_DESCRIPTION, "Allow clients to create and control remote nodes" },
@ -48,7 +50,6 @@ struct pw_protocol *pw_protocol_native_ext_client_node_init(struct pw_core *core
struct factory_data {
struct pw_factory *this;
struct pw_properties *properties;
struct pw_module *module;
struct spa_hook module_listener;
@ -66,7 +67,6 @@ static void *create_object(void *_data,
{
void *result;
struct pw_resource *node_resource;
struct pw_global *parent;
struct pw_client *client = pw_resource_get_client(resource);
int res;
@ -76,9 +76,7 @@ static void *create_object(void *_data,
goto error_resource;
}
parent = pw_client_get_global(client);
result = pw_client_node_new(node_resource, parent, properties, true);
result = pw_client_node_new(node_resource, properties, true);
if (result == NULL) {
res = -errno;
goto error_node;
@ -112,21 +110,38 @@ static void module_destroy(void *data)
spa_hook_remove(&d->module_listener);
if (d->properties)
pw_properties_free(d->properties);
spa_list_remove(&d->export_node.link);
spa_list_remove(&d->export_spanode.link);
pw_factory_destroy(d->this);
}
static void module_registered(void *data)
{
struct factory_data *d = data;
struct pw_module *module = d->module;
struct pw_factory *factory = d->this;
struct spa_dict_item items[1];
char id[16];
int res;
snprintf(id, sizeof(id), "%d", pw_global_get_id(pw_module_get_global(module)));
items[0] = SPA_DICT_ITEM_INIT(PW_KEY_MODULE_ID, id);
pw_factory_update_properties(factory, &SPA_DICT_INIT(items, 1));
if ((res = pw_factory_register(factory, NULL)) < 0) {
pw_log_error(NAME" %p: can't register factory: %s", factory, spa_strerror(res));
}
}
static const struct pw_module_events module_events = {
PW_VERSION_MODULE_EVENTS,
.destroy = module_destroy,
.registered = module_registered,
};
static int module_init(struct pw_module *module, struct pw_properties *properties)
SPA_EXPORT
int pipewire__module_init(struct pw_module *module, const char *args)
{
struct pw_core *core = pw_module_get_core(module);
struct pw_factory *factory;
@ -144,7 +159,6 @@ static int module_init(struct pw_module *module, struct pw_properties *propertie
data = pw_factory_get_user_data(factory);
data->this = factory;
data->module = module;
data->properties = properties;
pw_log_debug("module %p: new", module);
@ -154,8 +168,6 @@ static int module_init(struct pw_module *module, struct pw_properties *propertie
pw_protocol_native_ext_client_node_init(core);
pw_factory_register(factory, NULL, pw_module_get_global(module), NULL);
data->export_node.type = PW_TYPE_INTERFACE_Node;
data->export_node.func = pw_remote_node_export;
pw_core_register_export_type(core, &data->export_node);
@ -170,9 +182,3 @@ static int module_init(struct pw_module *module, struct pw_properties *propertie
return 0;
}
SPA_EXPORT
int pipewire__module_init(struct pw_module *module, const char *args)
{
return module_init(module, NULL);
}

View file

@ -1621,7 +1621,6 @@ static int process_node(void *data)
* \memberof pw_client_node
*/
struct pw_client_node *pw_client_node_new(struct pw_resource *resource,
struct pw_global *parent,
struct pw_properties *properties,
bool do_register)
{
@ -1639,6 +1638,15 @@ struct pw_client_node *pw_client_node_new(struct pw_resource *resource,
goto error_exit_cleanup;
}
if (properties == NULL)
properties = pw_properties_new(NULL, NULL);
if (properties == NULL) {
res = -errno;
goto error_exit_free;
}
pw_properties_setf(properties, PW_KEY_CLIENT_ID, "%d", client->global->id);
this = &impl->this;
impl->core = core;
@ -1655,10 +1663,7 @@ struct pw_client_node *pw_client_node_new(struct pw_resource *resource,
pw_map_init(&impl->io_map, 64, 64);
this->resource = resource;
this->parent = parent;
this->node = pw_spa_node_new(core,
client,
parent,
PW_SPA_NODE_FLAG_ASYNC |
(do_register ? 0 : PW_SPA_NODE_FLAG_NO_REGISTER),
(struct spa_node *)&impl->node.node,

View file

@ -40,13 +40,11 @@ struct pw_client_node {
struct pw_node *node;
struct pw_resource *resource;
struct pw_global *parent;
uint32_t flags;
};
struct pw_client_node *
pw_client_node_new(struct pw_resource *resource,
struct pw_global *parent,
struct pw_properties *properties,
bool do_register);

View file

@ -1146,7 +1146,7 @@ struct pw_proxy *pw_remote_spa_node_export(struct pw_remote *remote,
return NULL;
pw_node_set_implementation(node, (struct spa_node*)object);
pw_node_register(node, NULL, NULL, NULL);
pw_node_register(node, NULL);
pw_node_set_active(node, true);
return node_export(remote, node, true, user_data_size);

View file

@ -32,6 +32,8 @@
#include <pipewire/pipewire.h>
#include "pipewire/private.h"
#define NAME "link-factory"
#define FACTORY_USAGE PW_KEY_LINK_OUTPUT_NODE"=<output-node> " \
"["PW_KEY_LINK_OUTPUT_PORT"=<output-port>] " \
PW_KEY_LINK_INPUT_NODE"=<input-node " \
@ -46,8 +48,8 @@ static const struct spa_dict_item module_props[] = {
};
struct factory_data {
struct pw_module *module;
struct pw_factory *this;
struct pw_properties *properties;
struct spa_list link_list;
@ -217,6 +219,11 @@ static void *create_object(void *_data,
str = pw_properties_get(properties, PW_KEY_OBJECT_LINGER);
linger = str ? pw_properties_parse_bool(str) : false;
pw_properties_setf(properties, PW_KEY_FACTORY_ID, "%d", d->this->global->id);
if (!linger)
pw_properties_setf(properties, PW_KEY_CLIENT_ID, "%d", client->global->id);
link = pw_link_new(core, outport, inport, NULL, properties, sizeof(struct link_data));
properties = NULL;
if (link == NULL) {
@ -230,10 +237,7 @@ static void *create_object(void *_data,
spa_list_append(&d->link_list, &ld->l);
pw_link_add_listener(link, &ld->link_listener, &link_events, ld);
if ((res = pw_link_register(link,
linger ? NULL : client,
linger ? NULL : pw_client_get_global(client),
NULL)) < 0)
if ((res = pw_link_register(link, NULL)) < 0)
goto error_link_register;
ld->global = pw_link_get_global(link);
@ -249,7 +253,6 @@ static void *create_object(void *_data,
res = -ENOENT;
goto error_bind;
}
pw_resource_add_listener(ld->resource, &ld->resource_listener, &resource_events, ld);
}
@ -313,23 +316,39 @@ static void module_destroy(void *data)
spa_list_for_each_safe(ld, t, &d->link_list, l)
pw_link_destroy(ld->link);
if (d->properties)
pw_properties_free(d->properties);
pw_factory_destroy(d->this);
}
static void module_registered(void *data)
{
struct factory_data *d = data;
struct pw_module *module = d->module;
struct pw_factory *factory = d->this;
struct spa_dict_item items[1];
char id[16];
int res;
snprintf(id, sizeof(id), "%d", pw_global_get_id(pw_module_get_global(module)));
items[0] = SPA_DICT_ITEM_INIT(PW_KEY_MODULE_ID, id);
pw_factory_update_properties(factory, &SPA_DICT_INIT(items, 1));
if ((res = pw_factory_register(factory, NULL)) < 0) {
pw_log_error(NAME" %p: can't register factory: %s", factory, spa_strerror(res));
}
}
static const struct pw_module_events module_events = {
PW_VERSION_MODULE_EVENTS,
.destroy = module_destroy,
.registered = module_registered,
};
static int module_init(struct pw_module *module, struct pw_properties *properties)
SPA_EXPORT
int pipewire__module_init(struct pw_module *module, const char *args)
{
struct pw_core *core = pw_module_get_core(module);
struct pw_factory *factory;
struct factory_data *data;
int res;
factory = pw_factory_new(core,
"link-factory",
@ -339,14 +358,12 @@ static int module_init(struct pw_module *module, struct pw_properties *propertie
PW_KEY_FACTORY_USAGE, FACTORY_USAGE,
NULL),
sizeof(*data));
if (factory == NULL) {
res = -errno;
goto error_cleanup;
}
if (factory == NULL)
return -errno;
data = pw_factory_get_user_data(factory);
data->this = factory;
data->properties = properties;
data->module = module;
spa_list_init(&data->link_list);
pw_log_debug("module %p: new", module);
@ -355,25 +372,9 @@ static int module_init(struct pw_module *module, struct pw_properties *propertie
&impl_factory,
data);
if ((res = pw_factory_register(factory, NULL, pw_module_get_global(module), NULL)) < 0)
goto error_register;
pw_module_update_properties(module, &SPA_DICT_INIT_ARRAY(module_props));
pw_module_add_listener(module, &data->module_listener, &module_events, data);
pw_module_update_properties(module, &SPA_DICT_INIT_ARRAY(module_props));
return 0;
error_register:
pw_factory_destroy(factory);
error_cleanup:
if (properties)
pw_properties_free(properties);
return res;
}
SPA_EXPORT
int pipewire__module_init(struct pw_module *module, const char *args)
{
return module_init(module, NULL);
}

View file

@ -72,13 +72,11 @@ struct protocol_data {
struct pw_module *module;
struct spa_hook module_listener;
struct pw_protocol *protocol;
struct pw_properties *properties;
};
struct client {
struct pw_protocol_client this;
struct pw_properties *properties;
struct spa_source *source;
struct pw_protocol_native_connection *connection;
@ -257,12 +255,12 @@ static struct pw_client *client_new(struct server *s, int fd)
struct client_data *this;
struct pw_client *client;
struct pw_protocol *protocol = s->this.protocol;
struct protocol_data *pd = protocol->user_data;
socklen_t len;
struct ucred ucred;
struct pw_core *core = protocol->core;
struct pw_properties *props;
char buffer[1024];
struct protocol_data *d = pw_protocol_get_user_data(protocol);
props = pw_properties_new(PW_KEY_PROTOCOL, "protocol-native", NULL);
if (props == NULL)
@ -284,6 +282,8 @@ static struct pw_client *client_new(struct server *s, int fd)
pw_properties_setf(props, PW_KEY_SEC_LABEL, "%s", buffer);
}
pw_properties_setf(props, PW_KEY_MODULE_ID, "%d", d->module->global->id);
client = pw_client_new(protocol->core,
props,
sizeof(struct client_data));
@ -310,8 +310,7 @@ static struct pw_client *client_new(struct server *s, int fd)
PW_PERM_RWX, PW_VERSION_CORE_PROXY, 0) < 0)
goto cleanup_client;
props = pw_properties_copy(pw_client_get_properties(client));
if (pw_client_register(client, client, pw_module_get_global(pd->module), props) < 0)
if (pw_client_register(client, NULL) < 0)
goto cleanup_client;
if (pw_global_bind(pw_client_get_global(client), client,
@ -664,9 +663,6 @@ static void impl_destroy(struct pw_protocol_client *client)
pw_loop_destroy_source(remote->core->main_loop, impl->flush_event);
if (impl->properties)
pw_properties_free(impl->properties);
spa_list_remove(&client->link);
free(impl);
}
@ -688,8 +684,6 @@ impl_new_client(struct pw_protocol *protocol,
this->protocol = protocol;
this->remote = remote;
impl->properties = properties ? pw_properties_copy(properties) : NULL;
if (properties)
str = pw_properties_get(properties, PW_KEY_REMOTE_INTENTION);
if (str == NULL)
@ -716,8 +710,6 @@ impl_new_client(struct pw_protocol *protocol,
return this;
error_cleanup:
if (impl->properties)
pw_properties_free(impl->properties);
free(impl);
errno = -res;
return NULL;
@ -901,9 +893,6 @@ static void module_destroy(void *data)
spa_hook_remove(&d->module_listener);
if (d->properties)
pw_properties_free(d->properties);
pw_protocol_destroy(d->protocol);
}
@ -912,7 +901,8 @@ static const struct pw_module_events module_events = {
.destroy = module_destroy,
};
static int module_init(struct pw_module *module, struct pw_properties *properties)
SPA_EXPORT
int pipewire__module_init(struct pw_module *module, const char *args)
{
struct pw_core *core = pw_module_get_core(module);
struct pw_protocol *this;
@ -939,13 +929,12 @@ static int module_init(struct pw_module *module, struct pw_properties *propertie
d = pw_protocol_get_user_data(this);
d->protocol = this;
d->module = module;
d->properties = properties;
val = getenv("PIPEWIRE_DAEMON");
if (val == NULL)
val = pw_properties_get(pw_core_get_properties(core), PW_KEY_CORE_DAEMON);
if (val && pw_properties_parse_bool(val)) {
if (impl_add_server(this, core, properties) == NULL) {
if (impl_add_server(this, core, NULL) == NULL) {
res = -errno;
goto error_cleanup;
}
@ -961,9 +950,3 @@ error_cleanup:
pw_protocol_destroy(this);
return res;
}
SPA_EXPORT
int pipewire__module_init(struct pw_module *module, const char *args)
{
return module_init(module, NULL);
}

View file

@ -632,7 +632,7 @@ static int registry_method_marshal_add_listener(void *object,
return 0;
}
static void registry_marshal_global(void *object, uint32_t id, uint32_t parent_id, uint32_t permissions,
static void registry_marshal_global(void *object, uint32_t id, uint32_t permissions,
uint32_t type, uint32_t version, const struct spa_dict *props)
{
struct pw_resource *resource = object;
@ -644,7 +644,6 @@ static void registry_marshal_global(void *object, uint32_t id, uint32_t parent_i
spa_pod_builder_push_struct(b, &f);
spa_pod_builder_add(b,
SPA_POD_Int(id),
SPA_POD_Int(parent_id),
SPA_POD_Int(permissions),
SPA_POD_Id(type),
SPA_POD_Int(version),
@ -1785,14 +1784,13 @@ static int registry_demarshal_global(void *object, const struct pw_protocol_nati
struct pw_proxy *proxy = object;
struct spa_pod_parser prs;
struct spa_pod_frame f[2];
uint32_t id, parent_id, permissions, type, version;
uint32_t id, permissions, type, version;
struct spa_dict props;
spa_pod_parser_init(&prs, msg->data, msg->size);
if (spa_pod_parser_push_struct(&prs, &f[0]) < 0 ||
spa_pod_parser_get(&prs,
SPA_POD_Int(&id),
SPA_POD_Int(&parent_id),
SPA_POD_Int(&permissions),
SPA_POD_Id(&type),
SPA_POD_Int(&version), NULL) < 0)
@ -1808,7 +1806,7 @@ static int registry_demarshal_global(void *object, const struct pw_protocol_nati
return -EINVAL;
return pw_proxy_notify(proxy, struct pw_registry_proxy_events,
global, 0, id, parent_id, permissions, type, version,
global, 0, id, permissions, type, version,
props.n_items > 0 ? &props : NULL);
}

View file

@ -49,7 +49,6 @@ static const struct spa_dict_item module_props[] = {
struct impl {
struct pw_core *core;
struct pw_properties *properties;
struct spa_loop *loop;
struct spa_source source;
@ -414,10 +413,6 @@ static void module_destroy(void *data)
close(impl->source.fd);
impl->source.fd = -1;
}
if (impl->properties)
pw_properties_free(impl->properties);
free(impl);
}
@ -476,7 +471,8 @@ static void idle_func(struct spa_source *source)
pw_rtkit_bus_free(system_bus);
}
static int module_init(struct pw_module *module, struct pw_properties *properties)
SPA_EXPORT
int pipewire__module_init(struct pw_module *module, const char *args)
{
struct pw_core *core = pw_module_get_core(module);
struct impl *impl;
@ -498,7 +494,6 @@ static int module_init(struct pw_module *module, struct pw_properties *propertie
pw_log_debug("module %p: new", impl);
impl->core = core;
impl->properties = properties;
impl->loop = loop;
impl->source.loop = loop;
@ -523,9 +518,3 @@ error:
free(impl);
return res;
}
SPA_EXPORT
int pipewire__module_init(struct pw_module *module, const char *args)
{
return module_init(module, NULL);
}

View file

@ -33,6 +33,8 @@
#include "spa-device.h"
#define NAME "spa-device-factory"
#define FACTORY_USAGE SPA_KEY_FACTORY_NAME"=<factory-name> " \
"["SPA_KEY_LIBRARY_NAME"=<library-name>]"
@ -44,8 +46,8 @@ static const struct spa_dict_item module_props[] = {
struct factory_data {
struct pw_core *core;
struct pw_module *module;
struct pw_factory *this;
struct pw_properties *properties;
struct spa_hook factory_listener;
struct spa_hook module_listener;
@ -93,8 +95,6 @@ static void *create_object(void *_data,
goto error_properties;
device = pw_spa_device_load(core,
NULL,
pw_factory_get_global(data->this),
factory_name,
0,
properties,
@ -148,9 +148,6 @@ static void factory_destroy(void *_data)
spa_list_consume(nd, &data->device_list, link)
pw_device_destroy(nd->device);
if (data->properties)
pw_properties_free(data->properties);
}
static const struct pw_factory_events factory_events = {
@ -164,17 +161,36 @@ static void module_destroy(void *_data)
pw_factory_destroy(data->this);
}
static void module_registered(void *data)
{
struct factory_data *d = data;
struct pw_module *module = d->module;
struct pw_factory *factory = d->this;
struct spa_dict_item items[1];
char id[16];
int res;
snprintf(id, sizeof(id), "%d", pw_global_get_id(pw_module_get_global(module)));
items[0] = SPA_DICT_ITEM_INIT(PW_KEY_MODULE_ID, id);
pw_factory_update_properties(factory, &SPA_DICT_INIT(items, 1));
if ((res = pw_factory_register(factory, NULL)) < 0) {
pw_log_error(NAME" %p: can't register factory: %s", factory, spa_strerror(res));
}
}
static const struct pw_module_events module_events = {
PW_VERSION_MODULE_EVENTS,
.destroy = module_destroy,
.registered = module_registered,
};
static int module_init(struct pw_module *module, struct pw_properties *properties)
SPA_EXPORT
int pipewire__module_init(struct pw_module *module, const char *args)
{
struct pw_core *core = pw_module_get_core(module);
struct pw_factory *factory;
struct factory_data *data;
int res;
factory = pw_factory_new(core,
"spa-device-factory",
@ -187,33 +203,17 @@ static int module_init(struct pw_module *module, struct pw_properties *propertie
data = pw_factory_get_user_data(factory);
data->this = factory;
data->module = module;
data->core = core;
data->properties = properties;
spa_list_init(&data->device_list);
pw_factory_add_listener(factory, &data->factory_listener, &factory_events, data);
pw_factory_set_implementation(factory, &factory_impl, data);
pw_log_debug("module %p: new", module);
pw_module_add_listener(module, &data->module_listener, &module_events, data);
pw_module_update_properties(module, &SPA_DICT_INIT_ARRAY(module_props));
if ((res = pw_factory_register(factory,
NULL,
pw_module_get_global(module),
NULL)) < 0)
goto error_register;
pw_module_add_listener(module, &data->module_listener, &module_events, data);
return 0;
error_register:
pw_factory_destroy(factory);
return res;
}
SPA_EXPORT
int pipewire__module_init(struct pw_module *module, const char *args)
{
return module_init(module, NULL);
}

View file

@ -95,8 +95,6 @@ int pipewire__module_init(struct pw_module *module, const char *args)
}
device = pw_spa_device_load(core,
NULL,
pw_module_get_global(module),
argv[0],
0,
props,

View file

@ -93,7 +93,6 @@ int pipewire__module_init(struct pw_module *module, const char *args)
}
monitor = pw_spa_monitor_load(core,
pw_module_get_global(module),
argv[0], argv[1],
props,
sizeof(struct data));

View file

@ -33,6 +33,8 @@
#include "spa-node.h"
#define NAME "spa-node-factory"
#define FACTORY_USAGE SPA_KEY_FACTORY_NAME"=<factory-name> " \
"["SPA_KEY_LIBRARY_NAME"=<library-name>]"
@ -45,7 +47,7 @@ static const struct spa_dict_item module_props[] = {
struct factory_data {
struct pw_core *core;
struct pw_factory *this;
struct pw_properties *properties;
struct pw_module *module;
struct spa_hook factory_listener;
struct spa_hook module_listener;
@ -110,9 +112,10 @@ static void *create_object(void *_data,
if (factory_name == NULL)
goto error_properties;
pw_properties_setf(properties, PW_KEY_FACTORY_ID, "%d",
pw_global_get_id(pw_factory_get_global(data->this)));
node = pw_spa_node_load(core,
NULL,
pw_factory_get_global(data->this),
factory_name,
PW_SPA_NODE_FLAG_ACTIVATE,
properties,
@ -183,9 +186,6 @@ static void factory_destroy(void *_data)
spa_list_consume(nd, &data->node_list, link)
pw_node_destroy(nd->node);
if (data->properties)
pw_properties_free(data->properties);
}
static const struct pw_factory_events factory_events = {
@ -199,17 +199,36 @@ static void module_destroy(void *_data)
pw_factory_destroy(data->this);
}
static void module_registered(void *data)
{
struct factory_data *d = data;
struct pw_module *module = d->module;
struct pw_factory *factory = d->this;
struct spa_dict_item items[1];
char id[16];
int res;
snprintf(id, sizeof(id), "%d", pw_global_get_id(pw_module_get_global(module)));
items[0] = SPA_DICT_ITEM_INIT(PW_KEY_MODULE_ID, id);
pw_factory_update_properties(factory, &SPA_DICT_INIT(items, 1));
if ((res = pw_factory_register(factory, NULL)) < 0) {
pw_log_error(NAME" %p: can't register factory: %s", factory, spa_strerror(res));
}
}
static const struct pw_module_events module_events = {
PW_VERSION_MODULE_EVENTS,
.destroy = module_destroy,
.registered = module_registered,
};
static int module_init(struct pw_module *module, struct pw_properties *properties)
SPA_EXPORT
int pipewire__module_init(struct pw_module *module, const char *args)
{
struct pw_core *core = pw_module_get_core(module);
struct pw_factory *factory;
struct factory_data *data;
int res;
factory = pw_factory_new(core,
"spa-node-factory",
@ -223,7 +242,7 @@ static int module_init(struct pw_module *module, struct pw_properties *propertie
data = pw_factory_get_user_data(factory);
data->this = factory;
data->core = core;
data->properties = properties;
data->module = module;
spa_list_init(&data->node_list);
pw_factory_add_listener(factory, &data->factory_listener, &factory_events, data);
@ -234,19 +253,5 @@ static int module_init(struct pw_module *module, struct pw_properties *propertie
pw_module_update_properties(module, &SPA_DICT_INIT_ARRAY(module_props));
if ((res = pw_factory_register(factory,
NULL, pw_module_get_global(module), NULL)) < 0)
goto error_register;
return 0;
error_register:
pw_factory_destroy(factory);
return res;
}
SPA_EXPORT
int pipewire__module_init(struct pw_module *module, const char *args)
{
return module_init(module, NULL);
}

View file

@ -95,8 +95,6 @@ int pipewire__module_init(struct pw_module *module, const char *args)
}
node = pw_spa_node_load(core,
NULL,
pw_module_get_global(module),
argv[0],
PW_SPA_NODE_FLAG_ACTIVATE,
props,

View file

@ -44,9 +44,6 @@
struct impl {
struct pw_device *this;
struct pw_client *owner;
struct pw_global *parent;
enum pw_spa_device_flags flags;
void *unload;
@ -77,8 +74,6 @@ static const struct pw_device_events device_events = {
struct pw_device *
pw_spa_device_new(struct pw_core *core,
struct pw_client *owner,
struct pw_global *parent,
enum pw_spa_device_flags flags,
struct spa_device *device,
struct spa_handle *handle,
@ -95,8 +90,6 @@ pw_spa_device_new(struct pw_core *core,
impl = this->user_data;
impl->this = this;
impl->owner = owner;
impl->parent = parent;
impl->device = device;
impl->handle = handle;
impl->flags = flags;
@ -108,7 +101,7 @@ pw_spa_device_new(struct pw_core *core,
pw_device_set_implementation(this, impl->device);
if (!SPA_FLAG_CHECK(impl->flags, PW_SPA_DEVICE_FLAG_NO_REGISTER)) {
if ((res = pw_device_register(this, impl->owner, impl->parent, NULL)) < 0)
if ((res = pw_device_register(this, NULL)) < 0)
goto error_register;
}
return this;
@ -126,8 +119,6 @@ void *pw_spa_device_get_user_data(struct pw_device *device)
}
struct pw_device *pw_spa_device_load(struct pw_core *core,
struct pw_client *owner,
struct pw_global *parent,
const char *factory_name,
enum pw_spa_device_flags flags,
struct pw_properties *properties,
@ -146,7 +137,7 @@ struct pw_device *pw_spa_device_load(struct pw_core *core,
if ((res = spa_handle_get_interface(handle, SPA_TYPE_INTERFACE_Device, &iface)) < 0)
goto error_interface;
this = pw_spa_device_new(core, owner, parent, flags,
this = pw_spa_device_new(core, flags,
iface, handle, properties, user_data_size);
if (this == NULL)
goto error_device;

View file

@ -41,8 +41,6 @@ enum pw_spa_device_flags {
struct pw_device *
pw_spa_device_new(struct pw_core *core,
struct pw_client *owner, /**< optional owner */
struct pw_global *parent, /**< optional parent */
enum pw_spa_device_flags flags,
struct spa_device *device,
struct spa_handle *handle,
@ -51,8 +49,6 @@ pw_spa_device_new(struct pw_core *core,
struct pw_device *
pw_spa_device_load(struct pw_core *core,
struct pw_client *owner, /**< optional owner */
struct pw_global *parent, /**< optional parent */
const char *factory_name,
enum pw_spa_device_flags flags,
struct pw_properties *properties,

View file

@ -62,7 +62,6 @@ struct impl {
struct pw_spa_monitor this;
struct pw_core *core;
struct pw_global *parent;
struct spa_list item_list;
};
@ -139,7 +138,7 @@ static struct monitor_object *add_object(struct pw_spa_monitor *this, uint32_t i
case SPA_TYPE_INTERFACE_Device:
{
struct pw_device *device;
device = pw_spa_device_new(core, NULL, impl->parent,
device = pw_spa_device_new(core,
0, iface, handle, props, 0);
pw_device_add_listener(device, &obj->object_listener,
&device_events, obj);
@ -262,7 +261,6 @@ static const struct spa_monitor_callbacks callbacks = {
};
struct pw_spa_monitor *pw_spa_monitor_load(struct pw_core *core,
struct pw_global *parent,
const char *factory_name,
const char *system_name,
struct pw_properties *properties,
@ -294,7 +292,6 @@ struct pw_spa_monitor *pw_spa_monitor_load(struct pw_core *core,
}
impl->core = core;
impl->parent = parent;
spa_list_init(&impl->item_list);
this = &impl->this;

View file

@ -46,7 +46,6 @@ struct pw_spa_monitor {
struct pw_spa_monitor *
pw_spa_monitor_load(struct pw_core *core,
struct pw_global *parent,
const char *factory_name,
const char *system_name,
struct pw_properties *properties,

View file

@ -46,9 +46,6 @@
struct impl {
struct pw_node *this;
struct pw_client *owner;
struct pw_global *parent;
enum pw_spa_node_flags flags;
struct spa_handle *handle;
@ -86,7 +83,7 @@ static void complete_init(struct impl *impl)
pw_node_set_active(this, true);
if (!SPA_FLAG_CHECK(impl->flags, PW_SPA_NODE_FLAG_NO_REGISTER))
pw_node_register(this, impl->owner, impl->parent, NULL);
pw_node_register(this, NULL);
else
pw_node_initialized(this);
}
@ -110,8 +107,6 @@ static const struct pw_node_events node_events = {
struct pw_node *
pw_spa_node_new(struct pw_core *core,
struct pw_client *owner,
struct pw_global *parent,
enum pw_spa_node_flags flags,
struct spa_node *node,
struct spa_handle *handle,
@ -130,8 +125,6 @@ pw_spa_node_new(struct pw_core *core,
impl = this->user_data;
impl->this = this;
impl->owner = owner;
impl->parent = parent;
impl->node = node;
impl->handle = handle;
impl->flags = flags;
@ -242,8 +235,6 @@ setup_props(struct pw_core *core, struct spa_node *spa_node, struct pw_propertie
struct pw_node *pw_spa_node_load(struct pw_core *core,
struct pw_client *owner,
struct pw_global *parent,
const char *factory_name,
enum pw_spa_node_flags flags,
struct pw_properties *properties,
@ -279,7 +270,7 @@ struct pw_node *pw_spa_node_load(struct pw_core *core,
}
}
this = pw_spa_node_new(core, owner, parent, flags,
this = pw_spa_node_new(core, flags,
spa_node, handle, properties, user_data_size);
if (this == NULL) {
res = -errno;

View file

@ -42,8 +42,6 @@ enum pw_spa_node_flags {
struct pw_node *
pw_spa_node_new(struct pw_core *core,
struct pw_client *owner, /**< optional owner */
struct pw_global *parent, /**< optional parent */
enum pw_spa_node_flags flags,
struct spa_node *node,
struct spa_handle *handle,
@ -52,8 +50,6 @@ pw_spa_node_new(struct pw_core *core,
struct pw_node *
pw_spa_node_load(struct pw_core *core,
struct pw_client *owner, /**< optional owner */
struct pw_global *parent, /**< optional parent */
const char *factory_name,
enum pw_spa_node_flags flags,
struct pw_properties *properties,