diff options
author | Wim Taymans <wtaymans@redhat.com> | 2019-08-16 22:11:42 +0200 |
---|---|---|
committer | Wim Taymans <wtaymans@redhat.com> | 2019-08-16 22:11:42 +0200 |
commit | 8db4a797aaf11c0db2e447195f2700701df5a366 (patch) | |
tree | 614c0f3c8112ba5abb2892e5cedc621395048026 | |
parent | 32ce5c4deb78deb0890e3d0b6988306074e2903e (diff) |
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.
58 files changed, 490 insertions, 474 deletions
diff --git a/pipewire-jack b/pipewire-jack -Subproject 2d6f9950a5e036f908953727e61e3b3fb02eacf +Subproject a560e8b92f550268e3e697cfe03bd517664b727 diff --git a/pipewire-pulseaudio b/pipewire-pulseaudio -Subproject f9fce3cb3042486d8015925bf794acd5c4117ba +Subproject 2308318b39bd769b5059213958193448a4edea2 diff --git a/src/daemon/command.c b/src/daemon/command.c index 9081c9a9..91fe9d49 100644 --- a/src/daemon/command.c +++ b/src/daemon/command.c @@ -180,7 +180,7 @@ execute_command_module_load(struct pw_command *command, struct pw_core *core, ch { struct pw_module *module; - module = pw_module_load(core, command->args[1], command->args[2], NULL, NULL, NULL); + module = pw_module_load(core, command->args[1], command->args[2], NULL); if (module == NULL) { asprintf(err, "could not load module \"%s\": %m", command->args[1]); return -errno; diff --git a/src/examples/alsa-monitor.c b/src/examples/alsa-monitor.c index 37149301..14fb6c14 100644 --- a/src/examples/alsa-monitor.c +++ b/src/examples/alsa-monitor.c @@ -58,6 +58,7 @@ struct alsa_object { struct monitor *monitor; struct spa_list link; uint32_t id; + uint32_t device_id; struct pw_properties *props; @@ -111,8 +112,10 @@ static struct alsa_node *alsa_create_node(struct alsa_object *obj, uint32_t id, node->props = pw_properties_new_dict(info->props); - str = pw_properties_get(obj->props, SPA_KEY_DEVICE_NICK); - if (str) + if (obj->device_id != 0) + pw_properties_setf(node->props, PW_KEY_DEVICE_ID, "%d", obj->device_id); + + if ((str = pw_properties_get(obj->props, SPA_KEY_DEVICE_NICK)) != NULL) pw_properties_set(node->props, PW_KEY_NODE_NICK, str); str = pw_properties_get(obj->props, SPA_KEY_DEVICE_NAME); @@ -169,7 +172,13 @@ static void alsa_remove_node(struct alsa_object *obj, struct alsa_node *node) static void alsa_device_info(void *data, const struct spa_device_info *info) { struct alsa_object *obj = data; + const char *str; + pw_properties_update(obj->props, info->props); + + if ((str = pw_properties_get(obj->props, PW_KEY_DEVICE_ID)) != NULL) + obj->device_id = pw_properties_parse_int(str); + spa_debug_dict(0, info->props); } diff --git a/src/examples/bluez-session.c b/src/examples/bluez-session.c index 55d5906a..66898f6a 100644 --- a/src/examples/bluez-session.c +++ b/src/examples/bluez-session.c @@ -386,7 +386,7 @@ int main(int argc, char *argv[]) pw_core_add_spa_lib(impl.core, "api.bluez5.*", "bluez5/libspa-bluez5"); - pw_module_load(impl.core, "libpipewire-module-client-device", NULL, NULL, NULL, NULL); + pw_module_load(impl.core, "libpipewire-module-client-device", NULL, NULL); clock_gettime(CLOCK_MONOTONIC, &impl.now); diff --git a/src/examples/export-spa-device.c b/src/examples/export-spa-device.c index 418a707f..cc14a318 100644 --- a/src/examples/export-spa-device.c +++ b/src/examples/export-spa-device.c @@ -127,8 +127,8 @@ int main(int argc, char *argv[]) data.library = argv[1]; data.factory = argv[2]; - pw_module_load(data.core, "libpipewire-module-spa-device-factory", NULL, NULL, NULL, NULL); - pw_module_load(data.core, "libpipewire-module-client-device", NULL, NULL, NULL, NULL); + pw_module_load(data.core, "libpipewire-module-spa-device-factory", NULL, NULL); + pw_module_load(data.core, "libpipewire-module-client-device", NULL, NULL); pw_remote_add_listener(data.remote, &data.remote_listener, &remote_events, &data); diff --git a/src/examples/export-spa.c b/src/examples/export-spa.c index 6dd7ecb4..1141c0a3 100644 --- a/src/examples/export-spa.c +++ b/src/examples/export-spa.c @@ -135,7 +135,7 @@ int main(int argc, char *argv[]) if (argc > 3) data.path = argv[3]; - pw_module_load(data.core, "libpipewire-module-spa-node-factory", NULL, NULL, NULL, NULL); + pw_module_load(data.core, "libpipewire-module-spa-node-factory", NULL, NULL); pw_remote_add_listener(data.remote, &data.remote_listener, &remote_events, &data); diff --git a/src/examples/local-v4l2.c b/src/examples/local-v4l2.c index a4ae9b46..4a8dac5c 100644 --- a/src/examples/local-v4l2.c +++ b/src/examples/local-v4l2.c @@ -346,7 +346,7 @@ static int make_nodes(struct data *data) &impl_node, data); pw_node_set_implementation(data->node, &data->impl_node); - pw_node_register(data->node, NULL, NULL, NULL); + pw_node_register(data->node, NULL); factory = pw_core_find_factory(data->core, "spa-node-factory"); props = pw_properties_new(SPA_KEY_LIBRARY_NAME, "v4l2/libspa-v4l2", @@ -366,7 +366,7 @@ static int make_nodes(struct data *data) NULL, NULL, 0); - pw_link_register(data->link, NULL, NULL, NULL); + pw_link_register(data->link, NULL); pw_node_set_active(data->node, true); pw_node_set_active(data->v4l2, true); @@ -385,7 +385,7 @@ int main(int argc, char *argv[]) spa_hook_list_init(&data.hooks); - pw_module_load(data.core, "libpipewire-module-spa-node-factory", NULL, NULL, NULL, NULL); + pw_module_load(data.core, "libpipewire-module-spa-node-factory", NULL, NULL); if (SDL_Init(SDL_INIT_VIDEO) < 0) { printf("can't initialize SDL: %s\n", SDL_GetError()); diff --git a/src/examples/media-session.c b/src/examples/media-session.c index b35d4d6e..3db9b011 100644 --- a/src/examples/media-session.c +++ b/src/examples/media-session.c @@ -89,7 +89,6 @@ struct impl { struct object { struct impl *impl; uint32_t id; - uint32_t parent_id; uint32_t type; struct pw_proxy *proxy; struct spa_hook listener; @@ -112,6 +111,8 @@ struct node { struct spa_hook listener; struct pw_node_info *info; + uint32_t client_id; + struct spa_list session_link; struct session *session; @@ -401,7 +402,7 @@ static const struct pw_proxy_events node_proxy_events = { }; static int -handle_node(struct impl *impl, uint32_t id, uint32_t parent_id, +handle_node(struct impl *impl, uint32_t id, uint32_t type, const struct spa_dict *props) { const char *str, *media_class; @@ -409,8 +410,10 @@ handle_node(struct impl *impl, uint32_t id, uint32_t parent_id, enum pw_direction direction; struct pw_proxy *p; struct node *node; + uint32_t client_id = SPA_ID_INVALID; - media_class = props ? spa_dict_lookup(props, PW_KEY_MEDIA_CLASS) : NULL; + if (props && (str = spa_dict_lookup(props, PW_KEY_CLIENT_ID)) != NULL) + client_id = atoi(str); p = pw_registry_proxy_bind(impl->registry_proxy, id, type, PW_VERSION_NODE_PROXY, @@ -419,9 +422,9 @@ handle_node(struct impl *impl, uint32_t id, uint32_t parent_id, node = pw_proxy_get_user_data(p); node->obj.impl = impl; node->obj.id = id; - node->obj.parent_id = parent_id; node->obj.type = type; node->obj.proxy = p; + node->client_id = client_id; spa_list_init(&node->port_list); pw_proxy_add_listener(p, &node->obj.listener, &node_proxy_events, node); pw_proxy_add_object_listener(p, &node->listener, &node_events, node); @@ -429,6 +432,8 @@ handle_node(struct impl *impl, uint32_t id, uint32_t parent_id, spa_list_append(&impl->node_list, &node->l); node->type = NODE_TYPE_UNKNOWN; + media_class = props ? spa_dict_lookup(props, PW_KEY_MEDIA_CLASS) : NULL; + pw_log_debug(NAME" %p: node "PW_KEY_MEDIA_CLASS" %s", impl, media_class); if (media_class == NULL) @@ -571,15 +576,21 @@ static const struct pw_proxy_events port_proxy_events = { }; static int -handle_port(struct impl *impl, uint32_t id, uint32_t parent_id, uint32_t type, +handle_port(struct impl *impl, uint32_t id, uint32_t type, const struct spa_dict *props) { struct port *port; struct pw_proxy *p; struct node *node; const char *str; + uint32_t node_id; + + if (props == NULL || (str = spa_dict_lookup(props, PW_KEY_NODE_ID)) == NULL) + return -EINVAL; + + node_id = atoi(str); - if ((node = find_object(impl, parent_id)) == NULL) + if ((node = find_object(impl, node_id)) == NULL) return -ESRCH; if (props == NULL || (str = spa_dict_lookup(props, PW_KEY_PORT_DIRECTION)) == NULL) @@ -592,7 +603,6 @@ handle_port(struct impl *impl, uint32_t id, uint32_t parent_id, uint32_t type, port = pw_proxy_get_user_data(p); port->obj.impl = impl; port->obj.id = id; - port->obj.parent_id = parent_id; port->obj.type = type; port->obj.proxy = p; port->node = node; @@ -607,7 +617,7 @@ handle_port(struct impl *impl, uint32_t id, uint32_t parent_id, uint32_t type, spa_list_append(&node->port_list, &port->l); - pw_log_debug(NAME" %p: new port %d for node %d type %d %08x", impl, id, parent_id, + pw_log_debug(NAME" %p: new port %d for node %d type %d %08x", impl, id, node_id, node->type, port->flags); if (node->type == NODE_TYPE_DEVICE) { @@ -655,7 +665,7 @@ static const struct pw_proxy_events client_proxy_events = { }; static int -handle_client(struct impl *impl, uint32_t id, uint32_t parent_id, +handle_client(struct impl *impl, uint32_t id, uint32_t type, const struct spa_dict *props) { struct pw_proxy *p; @@ -670,7 +680,6 @@ handle_client(struct impl *impl, uint32_t id, uint32_t parent_id, client = pw_proxy_get_user_data(p); client->obj.impl = impl; client->obj.id = id; - client->obj.parent_id = parent_id; client->obj.type = type; client->obj.proxy = p; @@ -695,7 +704,7 @@ handle_client(struct impl *impl, uint32_t id, uint32_t parent_id, } static void -registry_global(void *data,uint32_t id, uint32_t parent_id, +registry_global(void *data,uint32_t id, uint32_t permissions, uint32_t type, uint32_t version, const struct spa_dict *props) { @@ -706,15 +715,15 @@ registry_global(void *data,uint32_t id, uint32_t parent_id, switch (type) { case PW_TYPE_INTERFACE_Client: - res = handle_client(impl, id, parent_id, type, props); + res = handle_client(impl, id, type, props); break; case PW_TYPE_INTERFACE_Node: - res = handle_node(impl, id, parent_id, type, props); + res = handle_node(impl, id, type, props); break; case PW_TYPE_INTERFACE_Port: - res = handle_port(impl, id, parent_id, type, props); + res = handle_port(impl, id, type, props); break; default: @@ -1053,7 +1062,7 @@ static int rescan_node(struct impl *impl, struct node *node) pw_log_warn(NAME " %p: no session found for %d", impl, node->obj.id); - client = find_object(impl, node->obj.parent_id); + client = find_object(impl, node->client_id); if (client && client->obj.type == PW_TYPE_INTERFACE_Client) { pw_client_proxy_error((struct pw_client_proxy*)client->obj.proxy, node->obj.id, -ENOENT, "no session available"); @@ -1256,8 +1265,8 @@ int main(int argc, char *argv[]) pw_core_add_spa_lib(impl.core, "api.alsa.*", "alsa/libspa-alsa"); pw_core_add_spa_lib(impl.core, "api.v4l2.*", "v4l2/libspa-v4l2"); - pw_module_load(impl.core, "libpipewire-module-client-device", NULL, NULL, NULL, NULL); - pw_module_load(impl.core, "libpipewire-module-adapter", NULL, NULL, NULL, NULL); + pw_module_load(impl.core, "libpipewire-module-client-device", NULL, NULL); + pw_module_load(impl.core, "libpipewire-module-adapter", NULL, NULL); clock_gettime(CLOCK_MONOTONIC, &impl.now); diff --git a/src/gst/gstpipewiredeviceprovider.c b/src/gst/gstpipewiredeviceprovider.c index 70446854..8283a805 100644 --- a/src/gst/gstpipewiredeviceprovider.c +++ b/src/gst/gstpipewiredeviceprovider.c @@ -183,7 +183,6 @@ struct node_data { struct pw_node_proxy *proxy; struct spa_hook proxy_listener; uint32_t id; - uint32_t parent_id; struct spa_hook node_listener; struct pw_node_info *info; GstCaps *caps; @@ -453,7 +452,7 @@ static const struct pw_proxy_events proxy_port_events = { .destroy = destroy_port_proxy, }; -static void registry_event_global(void *data, uint32_t id, uint32_t parent_id, uint32_t permissions, +static void registry_event_global(void *data, uint32_t id, uint32_t permissions, uint32_t type, uint32_t version, const struct spa_dict *props) { @@ -474,7 +473,6 @@ static void registry_event_global(void *data, uint32_t id, uint32_t parent_id, u nd->self = self; nd->proxy = node; nd->id = id; - nd->parent_id = parent_id; nd->caps = gst_caps_new_empty (); spa_list_append(&rd->nodes, &nd->link); pw_node_proxy_add_listener(node, &nd->node_listener, &node_events, nd); @@ -484,8 +482,12 @@ static void registry_event_global(void *data, uint32_t id, uint32_t parent_id, u else if (type == PW_TYPE_INTERFACE_Port) { struct pw_port_proxy *port; struct port_data *pd; + const char *str; - if ((nd = find_node_data(rd, parent_id)) == NULL) + if ((str = spa_dict_lookup(props, PW_KEY_NODE_ID)) == NULL) + return; + + if ((nd = find_node_data(rd, atoi(str))) == NULL) return; port = pw_registry_proxy_bind(rd->registry, diff --git a/src/modules/module-adapter.c b/src/modules/module-adapter.c index d46cd9b1..687848df 100644 --- a/src/modules/module-adapter.c +++ b/src/modules/module-adapter.c @@ -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); -} diff --git a/src/modules/module-adapter/adapter.c b/src/modules/module-adapter/adapter.c index eab1ecf3..956e5d08 100644 --- a/src/modules/module-adapter/adapter.c +++ b/src/modules/module-adapter/adapter.c @@ -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), diff --git a/src/modules/module-client-device.c b/src/modules/module-client-device.c index 8817bec7..c710fc1f 100644 --- a/src/modules/module-client-device.c +++ b/src/modules/module-client-device.c @@ -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); -} diff --git a/src/modules/module-client-device/client-device.h b/src/modules/module-client-device/client-device.h index 818c5c46..9fd8bac6 100644 --- a/src/modules/module-client-device/client-device.h +++ b/src/modules/module-client-device/client-device.h @@ -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 diff --git a/src/modules/module-client-device/resource-device.c b/src/modules/module-client-device/resource-device.c index 0c482ba6..460f8d70 100644 --- a/src/modules/module-client-device/resource-device.c +++ b/src/modules/module-client-device/resource-device.c @@ -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, diff --git a/src/modules/module-client-node.c b/src/modules/module-client-node.c index cd37874c..30f03a26 100644 --- a/src/modules/module-client-node.c +++ b/src/modules/module-client-node.c @@ -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); -} diff --git a/src/modules/module-client-node/client-node.c b/src/modules/module-client-node/client-node.c index 36adeb51..11c42b18 100644 --- a/src/modules/module-client-node/client-node.c +++ b/src/modules/module-client-node/client-node.c @@ -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, diff --git a/src/modules/module-client-node/client-node.h b/src/modules/module-client-node/client-node.h index 6a3b99ba..1492c32f 100644 --- a/src/modules/module-client-node/client-node.h +++ b/src/modules/module-client-node/client-node.h @@ -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); diff --git a/src/modules/module-client-node/remote-node.c b/src/modules/module-client-node/remote-node.c index 1e18fcfa..44b6426f 100644 --- a/src/modules/module-client-node/remote-node.c +++ b/src/modules/module-client-node/remote-node.c @@ -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); diff --git a/src/modules/module-link-factory.c b/src/modules/module-link-factory.c index 1fbb1fca..e0233aa0 100644 --- a/src/modules/module-link-factory.c +++ b/src/modules/module-link-factory.c @@ -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); } diff --git a/src/modules/module-protocol-native.c b/src/modules/module-protocol-native.c index af6a4c23..8bba3abc 100644 --- a/src/modules/module-protocol-native.c +++ b/src/modules/module-protocol-native.c @@ -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); -} diff --git a/src/modules/module-protocol-native/protocol-native.c b/src/modules/module-protocol-native/protocol-native.c index d6af94e0..6ede164c 100644 --- a/src/modules/module-protocol-native/protocol-native.c +++ b/src/modules/module-protocol-native/protocol-native.c @@ -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); } diff --git a/src/modules/module-rtkit.c b/src/modules/module-rtkit.c index ae57e867..0375db14 100644 --- a/src/modules/module-rtkit.c +++ b/src/modules/module-rtkit.c @@ -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); -} diff --git a/src/modules/spa/module-device-factory.c b/src/modules/spa/module-device-factory.c index 148b41f1..2eb0c455 100644 --- a/src/modules/spa/module-device-factory.c +++ b/src/modules/spa/module-device-factory.c @@ -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); } diff --git a/src/modules/spa/module-device.c b/src/modules/spa/module-device.c index e7f04c9b..684419a0 100644 --- a/src/modules/spa/module-device.c +++ b/src/modules/spa/module-device.c @@ -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, diff --git a/src/modules/spa/module-monitor.c b/src/modules/spa/module-monitor.c index b79a9f53..8c7228be 100644 --- a/src/modules/spa/module-monitor.c +++ b/src/modules/spa/module-monitor.c @@ -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)); diff --git a/src/modules/spa/module-node-factory.c b/src/modules/spa/module-node-factory.c index c6d8b8bb..5f111fff 100644 --- a/src/modules/spa/module-node-factory.c +++ b/src/modules/spa/module-node-factory.c @@ -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); } diff --git a/src/modules/spa/module-node.c b/src/modules/spa/module-node.c index ff102650..d4828c25 100644 --- a/src/modules/spa/module-node.c +++ b/src/modules/spa/module-node.c @@ -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, diff --git a/src/modules/spa/spa-device.c b/src/modules/spa/spa-device.c index d4e00488..4e720089 100644 --- a/src/modules/spa/spa-device.c +++ b/src/modules/spa/spa-device.c @@ -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; diff --git a/src/modules/spa/spa-device.h b/src/modules/spa/spa-device.h index 4a34c0f7..df8b1443 100644 --- a/src/modules/spa/spa-device.h +++ b/src/modules/spa/spa-device.h @@ -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, diff --git a/src/modules/spa/spa-monitor.c b/src/modules/spa/spa-monitor.c index 03880c7b..deff494b 100644 --- a/src/modules/spa/spa-monitor.c +++ b/src/modules/spa/spa-monitor.c @@ -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; diff --git a/src/modules/spa/spa-monitor.h b/src/modules/spa/spa-monitor.h index a55b36f7..6bea028b 100644 --- a/src/modules/spa/spa-monitor.h +++ b/src/modules/spa/spa-monitor.h @@ -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, diff --git a/src/modules/spa/spa-node.c b/src/modules/spa/spa-node.c index d1babaaa..4b1e0539 100644 --- a/src/modules/spa/spa-node.c +++ b/src/modules/spa/spa-node.c @@ -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; diff --git a/src/modules/spa/spa-node.h b/src/modules/spa/spa-node.h index ecc290aa..241d2789 100644 --- a/src/modules/spa/spa-node.h +++ b/src/modules/spa/spa-node.h @@ -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, diff --git a/src/pipewire/client.c b/src/pipewire/client.c index aa190a87..b37acbf3 100644 --- a/src/pipewire/client.c +++ b/src/pipewire/client.c @@ -30,6 +30,7 @@ #include "pipewire/private.h" #include "pipewire/resource.h" #include "pipewire/type.h" +#include "pipewire/keys.h" #define NAME "client" @@ -370,16 +371,30 @@ static const struct pw_global_events global_events = { SPA_EXPORT int pw_client_register(struct pw_client *client, - struct pw_client *owner, - struct pw_global *parent, struct pw_properties *properties) { struct pw_core *core = client->core; + const char *keys[] = { + PW_KEY_MODULE_ID, + PW_KEY_PROTOCOL, + PW_KEY_SEC_PID, + PW_KEY_SEC_UID, + PW_KEY_SEC_GID, + PW_KEY_SEC_LABEL, + NULL + }; if (client->registered) goto error_existed; - pw_log_debug(NAME" %p: register parent %d", client, parent ? parent->id : SPA_ID_INVALID); + pw_log_debug(NAME" %p: register", client); + + if (properties == NULL) + properties = pw_properties_new(NULL, NULL); + if (properties == NULL) + return -errno; + + pw_properties_copy_keys(client->properties, properties, keys); client->global = pw_global_new(core, PW_TYPE_INTERFACE_Client, @@ -393,9 +408,12 @@ int pw_client_register(struct pw_client *client, spa_list_append(&core->client_list, &client->link); client->registered = true; - pw_global_add_listener(client->global, &client->global_listener, &global_events, client); - pw_global_register(client->global, owner, parent); client->info.id = client->global->id; + pw_properties_setf(client->properties, PW_KEY_CLIENT_ID, "%d", client->info.id); + client->info.props = &client->properties->dict; + + pw_global_add_listener(client->global, &client->global_listener, &global_events, client); + pw_global_register(client->global); return 0; @@ -520,6 +538,7 @@ int pw_client_update_properties(struct pw_client *client, const struct spa_dict int changed; changed = pw_properties_update(client->properties, dict); + client->info.props = &client->properties->dict; pw_log_debug(NAME" %p: updated %d properties", client, changed); @@ -527,7 +546,6 @@ int pw_client_update_properties(struct pw_client *client, const struct spa_dict return 0; client->info.change_mask |= PW_CLIENT_CHANGE_MASK_PROPS; - client->info.props = &client->properties->dict; pw_client_emit_info_changed(client, &client->info); diff --git a/src/pipewire/client.h b/src/pipewire/client.h index 222b4d6e..7de80127 100644 --- a/src/pipewire/client.h +++ b/src/pipewire/client.h @@ -117,8 +117,6 @@ void pw_client_destroy(struct pw_client *client); /** Finish configuration and register a client */ int pw_client_register(struct pw_client *client, /**< the client to register */ - struct pw_client *owner, /**< optional owner */ - struct pw_global *parent, /**< the client parent */ struct pw_properties *properties/**< extra properties */); /** Get the client user data */ diff --git a/src/pipewire/core.c b/src/pipewire/core.c index 8c67c6f2..cdae50c0 100644 --- a/src/pipewire/core.c +++ b/src/pipewire/core.c @@ -270,12 +270,10 @@ static struct pw_registry_proxy * core_get_registry(void *object, uint32_t versi if (PW_PERM_IS_R(permissions)) { pw_registry_resource_global(registry_resource, global->id, - global->parent->id, permissions, global->type, global->version, - global->properties ? - &global->properties->dict : NULL); + &global->properties->dict); } } @@ -572,7 +570,6 @@ struct pw_core *pw_core_new(struct pw_loop *main_loop, this->info.version = pw_get_library_version(); srandom(time(NULL)); this->info.cookie = random(); - this->info.props = &properties->dict; this->info.name = name; this->sc_pagesize = sysconf(_SC_PAGESIZE); @@ -592,11 +589,12 @@ struct pw_core *pw_core_new(struct pw_loop *main_loop, res = -errno; goto error_free_loop; } + this->info.id = this->global->id; + pw_properties_setf(this->properties, PW_KEY_CORE_ID, "%d", this->info.id); + this->info.props = &this->properties->dict; pw_global_add_listener(this->global, &this->global_listener, &global_events, this); - pw_global_register(this->global, NULL, NULL); - - this->info.id = this->global->id; + pw_global_register(this->global); return this; @@ -737,6 +735,7 @@ int pw_core_update_properties(struct pw_core *core, const struct spa_dict *dict) int changed; changed = pw_properties_update(core->properties, dict); + core->info.props = &core->properties->dict; pw_log_debug(NAME" %p: updated %d properties", core, changed); @@ -744,7 +743,6 @@ int pw_core_update_properties(struct pw_core *core, const struct spa_dict *dict) return 0; core->info.change_mask = PW_CORE_CHANGE_MASK_PROPS; - core->info.props = &core->properties->dict; pw_core_emit_info_changed(core, &core->info); diff --git a/src/pipewire/device.c b/src/pipewire/device.c index b9c5151a..f1b5f567 100644 --- a/src/pipewire/device.c +++ b/src/pipewire/device.c @@ -363,13 +363,19 @@ static const struct pw_global_events global_events = { SPA_EXPORT int pw_device_register(struct pw_device *device, - struct pw_client *owner, - struct pw_global *parent, struct pw_properties *properties) { struct pw_core *core = device->core; struct node_data *nd; - const char *str; + const char *keys[] = { + PW_KEY_MODULE_ID, + PW_KEY_CLIENT_ID, + PW_KEY_DEVICE_DESCRIPTION, + PW_KEY_DEVICE_NAME, + PW_KEY_DEVICE_NICK, + PW_KEY_MEDIA_CLASS, + NULL + }; if (device->registered) goto error_existed; @@ -379,17 +385,11 @@ int pw_device_register(struct pw_device *device, if (properties == NULL) return -errno; - if ((str = pw_properties_get(device->properties, PW_KEY_DEVICE_DESCRIPTION)) != NULL) - pw_properties_set(properties, PW_KEY_DEVICE_DESCRIPTION, str); - if ((str = pw_properties_get(device->properties, PW_KEY_DEVICE_NAME)) != NULL) - pw_properties_set(properties, PW_KEY_DEVICE_NAME, str); - if ((str = pw_properties_get(device->properties, PW_KEY_DEVICE_NICK)) != NULL) - pw_properties_set(properties, PW_KEY_DEVICE_NICK, str); - if ((str = pw_properties_get(device->properties, PW_KEY_MEDIA_CLASS)) != NULL) - pw_properties_set(properties, PW_KEY_MEDIA_CLASS, str); + pw_properties_copy_keys(device->properties, properties, keys); device->global = pw_global_new(core, - PW_TYPE_INTERFACE_Device, PW_VERSION_DEVICE_PROXY, + PW_TYPE_INTERFACE_Device, + PW_VERSION_DEVICE_PROXY, properties, global_bind, device); @@ -400,11 +400,14 @@ int pw_device_register(struct pw_device *device, device->registered = true; device->info.id = device->global->id; + pw_properties_setf(device->properties, PW_KEY_DEVICE_ID, "%d", device->info.id); + device->info.props = &device->properties->dict; + pw_global_add_listener(device->global, &device->global_listener, &global_events, device); - pw_global_register(device->global, owner, parent); + pw_global_register(device->global); spa_list_for_each(nd, &device->node_list, link) { - pw_node_register(nd->node, NULL, device->global, NULL); + pw_node_register(nd->node, NULL); pw_node_set_active(nd->node, true); } return 0; @@ -451,13 +454,13 @@ static int update_properties(struct pw_device *device, const struct spa_dict *di int changed; changed = pw_properties_update(device->properties, dict); + device->info.props = &device->properties->dict; pw_log_debug(NAME" %p: updated %d properties", device, changed); if (!changed) return 0; - device->info.props = &device->properties->dict; device->info.change_mask |= PW_DEVICE_CHANGE_MASK_PROPS; return changed; @@ -529,7 +532,7 @@ static void device_add(struct pw_device *device, uint32_t id, pw_node_set_implementation(node, iface); if (device->global) { - pw_node_register(node, NULL, device->global, NULL); + pw_node_register(node, NULL); pw_node_set_active(node, true); } return; diff --git a/src/pipewire/device.h b/src/pipewire/device.h index c7fad1ce..73a286a1 100644 --- a/src/pipewire/device.h +++ b/src/pipewire/device.h @@ -68,8 +68,6 @@ struct pw_device *pw_device_new(struct pw_core *core, size_t user_data_size); int pw_device_register(struct pw_device *device, - struct pw_client *owner, - struct pw_global *parent, struct pw_properties *properties); void pw_device_destroy(struct pw_device *device); diff --git a/src/pipewire/factory.c b/src/pipewire/factory.c index 921d0010..5fbff04c 100644 --- a/src/pipewire/factory.c +++ b/src/pipewire/factory.c @@ -49,18 +49,26 @@ struct pw_factory *pw_factory_new(struct pw_core *core, size_t user_data_size) { struct pw_factory *this; + int res; - this = calloc(1, sizeof(*this) + user_data_size); - if (this == NULL) + if (properties == NULL) + properties = pw_properties_new(NULL, NULL); + if (properties == NULL) return NULL; + this = calloc(1, sizeof(*this) + user_data_size); + if (this == NULL) { + res = -errno; + goto error_exit; + }; + this->core = core; this->properties = properties; this->info.name = strdup(name); this->info.type = type; this->info.version = version; - this->info.props = properties ? &properties->dict : NULL; + this->info.props = &properties->dict; spa_hook_list_init(&this->listener_list); if (user_data_size > 0) @@ -69,6 +77,12 @@ struct pw_factory *pw_factory_new(struct pw_core *core, pw_log_debug(NAME" %p: new %s", this, name); return this; + +error_exit: + if (properties) + pw_properties_free(properties); + errno = -res; + return NULL; } SPA_EXPORT @@ -87,8 +101,8 @@ void pw_factory_destroy(struct pw_factory *factory) pw_log_debug(NAME" %p: free", factory); free((char *)factory->info.name); - if (factory->properties) - pw_properties_free(factory->properties); + + pw_properties_free(factory->properties); free(factory); } @@ -149,12 +163,43 @@ static const struct pw_global_events global_events = { }; SPA_EXPORT +const struct pw_properties *pw_factory_get_properties(struct pw_factory *factory) +{ + return factory->properties; +} + +SPA_EXPORT +int pw_factory_update_properties(struct pw_factory *factory, const struct spa_dict *dict) +{ + struct pw_resource *resource; + int changed; + + changed = pw_properties_update(factory->properties, dict); + factory->info.props = &factory->properties->dict; + + pw_log_debug(NAME" %p: updated %d properties", factory, changed); + + if (!changed) + return 0; + + factory->info.change_mask |= PW_FACTORY_CHANGE_MASK_PROPS; + if (factory->global) + spa_list_for_each(resource, &factory->global->resource_list, link) + pw_factory_resource_info(resource, &factory->info); + factory->info.change_mask = 0; + + return changed; +} + +SPA_EXPORT int pw_factory_register(struct pw_factory *factory, - struct pw_client *owner, - struct pw_global *parent, struct pw_properties *properties) { struct pw_core *core = factory->core; + const char *keys[] = { + PW_KEY_MODULE_ID, + NULL + }; if (factory->registered) goto error_existed; @@ -164,6 +209,8 @@ int pw_factory_register(struct pw_factory *factory, if (properties == NULL) return -errno; + pw_properties_copy_keys(factory->properties, properties, keys); + pw_properties_set(properties, PW_KEY_FACTORY_NAME, factory->info.name); pw_properties_setf(properties, PW_KEY_FACTORY_TYPE_NAME, "%s", spa_debug_type_find_name(pw_type_info(), factory->info.type)); @@ -181,9 +228,12 @@ int pw_factory_register(struct pw_factory *factory, spa_list_append(&core->factory_list, &factory->link); factory->registered = true; - pw_global_add_listener(factory->global, &factory->global_listener, &global_events, factory); - pw_global_register(factory->global, owner, parent); factory->info.id = factory->global->id; + pw_properties_setf(factory->properties, PW_KEY_FACTORY_ID, "%d", factory->info.id); + factory->info.props = &factory->properties->dict; + + pw_global_add_listener(factory->global, &factory->global_listener, &global_events, factory); + pw_global_register(factory->global); return 0; diff --git a/src/pipewire/factory.h b/src/pipewire/factory.h index d583606c..a4a07c01 100644 --- a/src/pipewire/factory.h +++ b/src/pipewire/factory.h @@ -72,9 +72,13 @@ struct pw_factory *pw_factory_new(struct pw_core *core, struct pw_properties *properties, size_t user_data_size); +/** Get the factory properties */ +const struct pw_properties *pw_factory_get_properties(struct pw_factory *factory); + +/** Update the factory properties */ +int pw_factory_update_properties(struct pw_factory *factory, const struct spa_dict *dict); + int pw_factory_register(struct pw_factory *factory, - struct pw_client *owner, - struct pw_global *parent, struct pw_properties *properties); void pw_factory_destroy(struct pw_factory *factory); diff --git a/src/pipewire/global.c b/src/pipewire/global.c index cb2f5e6c..52831e45 100644 --- a/src/pipewire/global.c +++ b/src/pipewire/global.c @@ -77,6 +77,11 @@ pw_global_new(struct pw_core *core, struct pw_global *this; int res; + if (properties == NULL) + properties = pw_properties_new(NULL, NULL); + if (properties == NULL) + return NULL; + impl = calloc(1, sizeof(struct impl)); if (impl == NULL) { res = -errno; @@ -98,7 +103,6 @@ pw_global_new(struct pw_core *core, goto error_free; } - spa_list_init(&this->child_list); spa_list_init(&this->resource_list); spa_hook_list_init(&this->listener_list); @@ -120,17 +124,12 @@ error_cleanup: /** register a global to the core registry * * \param global a global to add - * \param owner an optional owner client of the global - * \param parent an optional parent of the global * \return 0 on success < 0 errno value on failure * * \memberof pw_global */ SPA_EXPORT -int -pw_global_register(struct pw_global *global, - struct pw_client *owner, - struct pw_global *parent) +int pw_global_register(struct pw_global *global) { struct impl *impl = SPA_CONTAINER_OF(global, struct impl, this); struct pw_resource *registry; @@ -139,16 +138,6 @@ pw_global_register(struct pw_global *global, if (impl->registered) return -EEXIST; - global->owner = owner; - if (owner && parent == NULL) - parent = owner->global; - if (parent == NULL) - parent = core->global; - if (parent == NULL) - parent = global; - global->parent = parent; - spa_list_append(&parent->child_list, &global->child_link); - spa_list_append(&core->global_list, &global->link); impl->registered = true; @@ -158,15 +147,13 @@ pw_global_register(struct pw_global *global, if (PW_PERM_IS_R(permissions)) pw_registry_resource_global(registry, global->id, - global->parent->id, permissions, global->type, global->version, - global->properties ? - &global->properties->dict : NULL); + &global->properties->dict); } - pw_log_debug(NAME" %p: registered %u owner %p parent %p", global, global->id, owner, parent); + pw_log_debug(NAME" %p: registered %u", global, global->id); pw_core_emit_global_added(core, global); return 0; @@ -177,17 +164,10 @@ static int global_unregister(struct pw_global *global) struct impl *impl = SPA_CONTAINER_OF(global, struct impl, this); struct pw_core *core = global->core; struct pw_resource *resource; - struct pw_global *g; if (!impl->registered) return 0; - spa_list_consume(g, &global->child_list, child_link) { - if (g == global) - break; - global_unregister(g); - } - spa_list_for_each(resource, &core->registry_resource_list, link) { uint32_t permissions = pw_global_get_permissions(global, resource->client); pw_log_debug("registry %p: global %d %08x", resource, global->id, permissions); @@ -195,8 +175,6 @@ static int global_unregister(struct pw_global *global) pw_registry_resource_global_remove(resource, global->id); } - global->parent = NULL; - spa_list_remove(&global->child_link); spa_list_remove(&global->link); pw_map_remove(&core->globals, global->id); impl->registered = false; @@ -214,18 +192,6 @@ struct pw_core *pw_global_get_core(struct pw_global *global) } SPA_EXPORT -struct pw_client *pw_global_get_owner(struct pw_global *global) -{ - return global->owner; -} - -SPA_EXPORT -struct pw_global *pw_global_get_parent(struct pw_global *global) -{ - return global->parent; -} - -SPA_EXPORT uint32_t pw_global_get_type(struct pw_global *global) { return global->type; @@ -340,12 +306,10 @@ int pw_global_update_permissions(struct pw_global *global, struct pw_client *cli client, resource, global->id); pw_registry_resource_global(resource, global->id, - global->parent->id, new_permissions, global->type, global->version, - global->properties ? - &global->properties->dict : NULL); + &global->properties->dict); } } @@ -384,8 +348,7 @@ void pw_global_destroy(struct pw_global *global) pw_log_debug(NAME" %p: free", global); pw_global_emit_free(global); - if (global->properties) - pw_properties_free(global->properties); + pw_properties_free(global->properties); free(global); } diff --git a/src/pipewire/global.h b/src/pipewire/global.h index bbaa9fa6..2c63c9b5 100644 --- a/src/pipewire/global.h +++ b/src/pipewire/global.h @@ -41,9 +41,6 @@ extern "C" { * * A client can bind to a global to send methods or receive events from * the global. - * - * Global objects are arranged in a hierarchy where each global has a parent - * global. The core global is the top parent in the hierarchy. */ /** \class pw_global * @@ -92,9 +89,7 @@ pw_global_new(struct pw_core *core, /**< the core */ void *object /**< global object */); /** Register a global object to the core registry */ -int pw_global_register(struct pw_global *global, - struct pw_client *owner, - struct pw_global *parent); +int pw_global_register(struct pw_global *global); /** Add an event listener on the global */ void pw_global_add_listener(struct pw_global *global, @@ -108,12 +103,6 @@ uint32_t pw_global_get_permissions(struct pw_global *global, struct pw_client *c /** Get the core object of this global */ struct pw_core *pw_global_get_core(struct pw_global *global); -/** Get the owner of the global. This can be NULL when the core is owner */ -struct pw_client *pw_global_get_owner(struct pw_global *global); - -/** Get the parent of a global */ -struct pw_global *pw_global_get_parent(struct pw_global *global); - /** Get the global type */ uint32_t pw_global_get_type(struct pw_global *global); diff --git a/src/pipewire/interfaces.h b/src/pipewire/interfaces.h index 3836017e..448275b0 100644 --- a/src/pipewire/interfaces.h +++ b/src/pipewire/interfaces.h @@ -396,13 +396,12 @@ struct pw_registry_proxy_events { * available. * * \param id the global object id - * \param parent_id the parent global id * \param permissions the permissions of the object * \param type the type of the interface * \param version the version of the interface * \param props extra properties of the global */ - void (*global) (void *object, uint32_t id, uint32_t parent_id, + void (*global) (void *object, uint32_t id, uint32_t permissions, uint32_t type, uint32_t version, const struct spa_dict *props); /** diff --git a/src/pipewire/keys.h b/src/pipewire/keys.h index 818261d1..d5864d90 100644 --- a/src/pipewire/keys.h +++ b/src/pipewire/keys.h @@ -36,7 +36,8 @@ extern "C" { * read-only. They are usually used for security sensitive information that * needs to be fixed. * - * Properties from the parent can also appear on children. + * Properties from other objects can also appear. This usually suggests some + * sort of parent/child or owner/owned relationship. */ /* Peroperties usually set on the core object */ @@ -65,6 +66,7 @@ extern "C" { #define PW_KEY_LIBRARY_NAME_LOOP "library.name.loop" /**< name of the loop library to use */ #define PW_KEY_LIBRARY_NAME_DBUS "library.name.dbus" /**< name of the dbus library to use */ +#define PW_KEY_CORE_ID "core.id" /**< the core id */ #define PW_KEY_CORE_MONITORS "core.monitors" /**< the apis monitored by core. */ /* remote keys */ @@ -97,6 +99,7 @@ extern "C" { #define PW_KEY_WINDOW_X11_DISPLAY "window.x11.display" /**< the X11 display string. Ex. ":0.0" */ /** Client properties */ +#define PW_KEY_CLIENT_ID "client.id" /**< a client id */ #define PW_KEY_CLIENT_NAME "client.name" /**< the client name */ #define PW_KEY_CLIENT_API "client.api" /**< the client api used to access * PipeWire */ @@ -135,6 +138,7 @@ extern "C" { #define PW_KEY_PORT_MONITOR "port.monitor" /**< if this port is a monitor port */ /** link properties */ +#define PW_KEY_LINK_ID "link.id" /**< a link id */ #define PW_KEY_LINK_INPUT_NODE "link.input.node" /**< input node id of a link */ #define PW_KEY_LINK_INPUT_PORT "link.input.port" /**< input port id of a link */ #define PW_KEY_LINK_OUTPUT_NODE "link.output.node" /**< output node id of a link */ @@ -181,6 +185,7 @@ extern "C" { * latency, quality or form factor. */ /** module properties */ +#define PW_KEY_MODULE_ID "module.id" /**< the module id */ #define PW_KEY_MODULE_NAME "module.name" /**< the name of the module */ #define PW_KEY_MODULE_AUTHOR "module.author" /**< the author's name */ #define PW_KEY_MODULE_DESCRIPTION "module.description" /**< a human readable one-line description @@ -190,6 +195,7 @@ extern "C" { #define PW_KEY_MODULE_VERSION "module.version" /**< a version string for the module. */ /** Factory properties */ +#define PW_KEY_FACTORY_ID "factory.id" /**< the factory id */ #define PW_KEY_FACTORY_NAME "factory.name" /**< the name of the factory */ #define PW_KEY_FACTORY_USAGE "factory.usage" /**< the usage of the factory */ #define PW_KEY_FACTORY_TYPE_NAME "factory.type.name" /**< the name of the type created by a factory */ diff --git a/src/pipewire/link.c b/src/pipewire/link.c index d7fe2145..3f6fb825 100644 --- a/src/pipewire/link.c +++ b/src/pipewire/link.c @@ -1200,16 +1200,6 @@ check_permission(struct pw_core *core, struct pw_port *input, struct pw_properties *properties) { - struct pw_client *client; - - if ((client = output->global->owner) != NULL && - !PW_PERM_IS_R(pw_global_get_permissions(input->global, client))) - return -EACCES; - - if ((client = input->global->owner) != NULL && - !PW_PERM_IS_R(pw_global_get_permissions(output->global, client))) - return -EACCES; - return 0; } @@ -1265,6 +1255,7 @@ struct pw_link *pw_link_new(struct pw_core *core, struct impl *impl; struct pw_link *this; struct pw_node *input_node, *output_node; + const char *str; int res; if (output == input) @@ -1283,6 +1274,11 @@ struct pw_link *pw_link_new(struct pw_core *core, output_node = output->node; input_node = input->node; + if (properties == NULL) + properties = pw_properties_new(NULL, NULL); + if (properties == NULL) + goto error_no_mem; + impl = calloc(1, sizeof(struct impl) + user_data_size); if (impl == NULL) goto error_no_mem; @@ -1303,11 +1299,10 @@ struct pw_link *pw_link_new(struct pw_core *core, this->output = output; this->input = input; - if (properties) { - const char *str = pw_properties_get(properties, PW_KEY_LINK_PASSIVE); - if (str && pw_properties_parse_bool(str)) - impl->passive = true; - } + /* passive means that this link does not make the nodes active */ + if ((str = pw_properties_get(properties, PW_KEY_LINK_PASSIVE)) != NULL) + impl->passive = pw_properties_parse_bool(str); + spa_hook_list_init(&this->listener_list); impl->format_filter = format_filter; @@ -1328,7 +1323,7 @@ struct pw_link *pw_link_new(struct pw_core *core, spa_list_append(&input->links, &this->input_link); this->info.format = NULL; - this->info.props = this->properties ? &this->properties->dict : NULL; + this->info.props = &this->properties->dict; impl->io.buffer_id = SPA_ID_INVALID; impl->io.status = SPA_STATUS_NEED_BUFFER; @@ -1413,12 +1408,15 @@ static const struct pw_global_events global_events = { SPA_EXPORT int pw_link_register(struct pw_link *link, - struct pw_client *owner, - struct pw_global *parent, struct pw_properties *properties) { struct pw_core *core = link->core; struct pw_node *output_node, *input_node; + const char *keys[] = { + PW_KEY_FACTORY_ID, + PW_KEY_CLIENT_ID, + NULL + }; if (link->registered) goto error_existed; @@ -1436,6 +1434,8 @@ int pw_link_register(struct pw_link *link, link->info.input_node_id = input_node->global->id; link->info.input_port_id = link->input->global->id; + pw_properties_copy_keys(link->properties, properties, keys); + pw_properties_setf(properties, PW_KEY_LINK_OUTPUT_PORT, "%d", link->info.output_port_id); pw_properties_setf(properties, PW_KEY_LINK_INPUT_PORT, "%d", link->info.input_port_id); @@ -1452,8 +1452,11 @@ int pw_link_register(struct pw_link *link, link->registered = true; link->info.id = link->global->id; + pw_properties_setf(link->properties, PW_KEY_LINK_ID, "%d", link->info.id); + link->info.props = &link->properties->dict; + pw_global_add_listener(link->global, &link->global_listener, &global_events, link); - pw_global_register(link->global, owner, parent); + pw_global_register(link->global); debug_link(link); @@ -1500,8 +1503,7 @@ void pw_link_destroy(struct pw_link *link) pw_work_queue_destroy(impl->work); - if (link->properties) - pw_properties_free(link->properties); + pw_properties_free(link->properties); pw_core_recalc_graph(link->core); diff --git a/src/pipewire/link.h b/src/pipewire/link.h index a1c9c57d..0d3decc7 100644 --- a/src/pipewire/link.h +++ b/src/pipewire/link.h @@ -95,8 +95,6 @@ void pw_link_add_listener(struct pw_link *link, /** Finish link configuration and register */ int pw_link_register(struct pw_link *link, /**< the link to register */ - struct pw_client *owner, /**< optional link owner */ - struct pw_global *parent, /**< parent global */ struct pw_properties *properties /**< extra properties */); /** Get the core of a link */ diff --git a/src/pipewire/module.c b/src/pipewire/module.c index a56c56fd..a36107ac 100644 --- a/src/pipewire/module.c +++ b/src/pipewire/module.c @@ -178,8 +178,6 @@ SPA_EXPORT struct pw_module * pw_module_load(struct pw_core *core, const char *name, const char *args, - struct pw_client *owner, - struct pw_global *parent, struct pw_properties *properties) { struct pw_module *this; @@ -247,7 +245,6 @@ pw_module_load(struct pw_core *core, this->info.filename = filename; filename = NULL; this->info.args = args ? strdup(args) : NULL; - this->info.props = &this->properties->dict; this->global = pw_global_new(core, PW_TYPE_INTERFACE_Module, @@ -262,13 +259,19 @@ pw_module_load(struct pw_core *core, goto error_no_global; spa_list_append(&core->module_list, &this->link); - pw_global_add_listener(this->global, &this->global_listener, &global_events, this); + this->info.id = this->global->id; + pw_properties_setf(this->properties, PW_KEY_MODULE_ID, "%d", this->info.id); + this->info.props = &this->properties->dict; + + pw_global_add_listener(this->global, &this->global_listener, &global_events, this); if ((res = init_func(this, args)) < 0) goto error_init_failed; - pw_global_register(this->global, owner, parent); + pw_global_register(this->global); + + pw_module_emit_registered(this); pw_log_debug(NAME" %p: loaded module: %s", this, this->info.name); @@ -369,14 +372,13 @@ int pw_module_update_properties(struct pw_module *module, const struct spa_dict int changed; changed = pw_properties_update(module->properties, dict); + module->info.props = &module->properties->dict; pw_log_debug(NAME" %p: updated %d properties", module, changed); if (!changed) return 0; - module->info.props = &module->properties->dict; - module->info.change_mask |= PW_MODULE_CHANGE_MASK_PROPS; if (module->global) spa_list_for_each(resource, &module->global->resource_list, link) diff --git a/src/pipewire/module.h b/src/pipewire/module.h index af18cef1..0a3e7e65 100644 --- a/src/pipewire/module.h +++ b/src/pipewire/module.h @@ -63,14 +63,16 @@ struct pw_module_events { /** The module is destroyed */ void (*destroy) (void *data); + + /** The module is registered. This is a good time to register + * objectes created from the module. */ + void (*registered) (void *data); }; struct pw_module * pw_module_load(struct pw_core *core, const char *name, /**< name of the module */ const char *args /**< arguments of the module */, - struct pw_client *owner, /**< optional owner */ - struct pw_global *parent, /**< parent global */ struct pw_properties *properties /**< extra global properties */); /** Get the core of a module */ diff --git a/src/pipewire/node.c b/src/pipewire/node.c index 523fd144..c439b4f0 100644 --- a/src/pipewire/node.c +++ b/src/pipewire/node.c @@ -544,13 +544,21 @@ static const struct pw_global_events global_events = { SPA_EXPORT int pw_node_register(struct pw_node *this, - struct pw_client *owner, - struct pw_global *parent, struct pw_properties *properties) { struct pw_core *core = this->core; struct pw_port *port; - const char *str; + const char *keys[] = { + PW_KEY_CLIENT_ID, + PW_KEY_DEVICE_ID, + PW_KEY_NODE_DESCRIPTION, + PW_KEY_NODE_NAME, + PW_KEY_NODE_NICK, + PW_KEY_NODE_SESSION, + PW_KEY_MEDIA_CLASS, + PW_KEY_MEDIA_ROLE, + NULL + }; pw_log_debug(NAME" %p: register", this); @@ -562,18 +570,7 @@ int pw_node_register(struct pw_node *this, if (properties == NULL) return -errno; - if ((str = pw_properties_get(this->properties, PW_KEY_NODE_DESCRIPTION)) != NULL) - pw_properties_set(properties, PW_KEY_NODE_DESCRIPTION, str); - if ((str = pw_properties_get(this->properties, PW_KEY_NODE_NAME)) != NULL) - pw_properties_set(properties, PW_KEY_NODE_NAME, str); - if ((str = pw_properties_get(this->properties, PW_KEY_NODE_NICK)) != NULL) - pw_properties_set(properties, PW_KEY_NODE_NICK, str); - if ((str = pw_properties_get(this->properties, PW_KEY_MEDIA_CLASS)) != NULL) - pw_properties_set(properties, PW_KEY_MEDIA_CLASS, str); - if ((str = pw_properties_get(this->properties, PW_KEY_MEDIA_ROLE)) != NULL) - pw_properties_set(properties, PW_KEY_MEDIA_ROLE, str); - if ((str = pw_properties_get(this->properties, PW_KEY_NODE_SESSION)) != NULL) - pw_properties_set(properties, PW_KEY_NODE_SESSION, str); + pw_properties_copy_keys(this->properties, properties, keys); this->global = pw_global_new(core, PW_TYPE_INTERFACE_Node, @@ -592,18 +589,17 @@ int pw_node_register(struct pw_node *this, this->info.id = this->global->id; this->rt.activation->position.clock.id = this->info.id; pw_properties_setf(this->properties, PW_KEY_NODE_ID, "%d", this->info.id); + this->info.props = &this->properties->dict; pw_node_initialized(this); pw_global_add_listener(this->global, &this->global_listener, &global_events, this); - pw_global_register(this->global, owner, parent); + pw_global_register(this->global); spa_list_for_each(port, &this->input_ports, link) - pw_port_register(port, this->global->owner, this->global, - pw_properties_copy(port->properties)); + pw_port_register(port, NULL); spa_list_for_each(port, &this->output_ports, link) - pw_port_register(port, this->global->owner, this->global, - pw_properties_copy(port->properties)); + pw_port_register(port, NULL); return 0; @@ -997,12 +993,12 @@ static int update_properties(struct pw_node *node, const struct spa_dict *dict) int changed; changed = pw_properties_update(node->properties, dict); + node->info.props = &node->properties->dict; pw_log_debug(NAME" %p: updated %d properties", node, changed); if (changed) { check_properties(node); - node->info.props = &node->properties->dict; node->info.change_mask |= PW_NODE_CHANGE_MASK_PROPS; } return changed; diff --git a/src/pipewire/node.h b/src/pipewire/node.h index e3005329..1d6c2eca 100644 --- a/src/pipewire/node.h +++ b/src/pipewire/node.h @@ -107,8 +107,6 @@ pw_node_new(struct pw_core *core, /**< the core */ /** Complete initialization of the node and register */ int pw_node_register(struct pw_node *node, /**< node to register */ - struct pw_client *owner, /**< optional owner */ - struct pw_global *parent, /**< optional parent */ struct pw_properties *properties /**< extra properties */); /** Destroy a node */ diff --git a/src/pipewire/port.c b/src/pipewire/port.c index e1ea3fdb..8485a8e0 100644 --- a/src/pipewire/port.c +++ b/src/pipewire/port.c @@ -256,10 +256,10 @@ static int update_properties(struct pw_port *port, const struct spa_dict *dict) int changed; changed = pw_properties_update(port->properties, dict); + port->info.props = &port->properties->dict; if (changed) { pw_log_debug(NAME" %p: updated %d properties", port, changed); - port->info.props = &port->properties->dict; port->info.change_mask |= PW_PORT_CHANGE_MASK_PROPS; } return changed; @@ -675,15 +675,32 @@ static const struct pw_global_events global_events = { }; int pw_port_register(struct pw_port *port, - struct pw_client *owner, - struct pw_global *parent, struct pw_properties *properties) { struct pw_node *node = port->node; + const char *keys[] = { + PW_KEY_FORMAT_DSP, + PW_KEY_PORT_NAME, + PW_KEY_PORT_DIRECTION, + PW_KEY_PORT_PHYSICAL, + PW_KEY_PORT_TERMINAL, + PW_KEY_PORT_CONTROL, + PW_KEY_PORT_ALIAS1, + PW_KEY_PORT_ALIAS2, + NULL + }; - if (node == NULL) + if (node == NULL || node->global == NULL) return -EIO; + if (properties == NULL) + properties = pw_properties_new(NULL, NULL); + if (properties == NULL) + return -errno; + + pw_properties_setf(properties, PW_KEY_NODE_ID, "%d", node->global->id); + pw_properties_copy_keys(port->properties, properties, keys); + port->global = pw_global_new(node->core, PW_TYPE_INTERFACE_Port, PW_VERSION_PORT_PROXY, @@ -695,7 +712,12 @@ int pw_port_register(struct pw_port *port, pw_global_add_listener(port->global, &port->global_listener, &global_events, port); - return pw_global_register(port->global, owner, parent); + port->info.id = port->global->id; + pw_properties_setf(port->properties, PW_KEY_NODE_ID, "%d", node->global->id); + pw_properties_setf(port->properties, PW_KEY_PORT_ID, "%d", port->info.id); + port->info.props = &port->properties->dict; + + return pw_global_register(port->global); } SPA_EXPORT @@ -752,6 +774,7 @@ int pw_port_add(struct pw_port *port, struct pw_node *node) pw_properties_setf(port->properties, PW_KEY_PORT_NAME, "%s_%d", dir, port->port_id); } } + port->info.props = &port->properties->dict; if (control) { pw_log_debug(NAME" %p: setting node control", port); @@ -781,8 +804,7 @@ int pw_port_add(struct pw_port *port, struct pw_node *node) } if (node->global) - pw_port_register(port, node->global->owner, node->global, - pw_properties_copy(port->properties)); + pw_port_register(port, NULL); pw_loop_invoke(node->data_loop, do_add_port, SPA_ID_INVALID, NULL, 0, false, port); diff --git a/src/pipewire/private.h b/src/pipewire/private.h index 675235ce..282d183c 100644 --- a/src/pipewire/private.h +++ b/src/pipewire/private.h @@ -129,14 +129,9 @@ struct pw_client { struct pw_global { struct pw_core *core; /**< the core */ - struct pw_client *owner; /**< the owner of this object, NULL when the - * PipeWire server is the owner */ struct spa_list link; /**< link in core list of globals */ uint32_t id; /**< server id of the object */ - struct pw_global *parent; /**< parent global */ - struct spa_list child_link; /**< link in parent child list of globals */ - struct spa_list child_list; /**< The list of child globals */ struct pw_properties *properties; /**< properties of the global */ @@ -316,6 +311,7 @@ struct pw_device { #define pw_module_emit(o,m,v,...) spa_hook_list_call(&o->listener_list, struct pw_module_events, m, v, ##__VA_ARGS__) #define pw_module_emit_destroy(m) pw_module_emit(m, destroy, 0) +#define pw_module_emit_registered(m) pw_module_emit(m, registered, 0) struct pw_module { struct pw_core *core; /**< the core object */ @@ -709,8 +705,8 @@ struct pw_remote { struct pw_stream { - struct pw_remote *remote; /**< the owner remote */ - struct spa_list link; /**< link in the remote */ + struct pw_remote *remote; /**< the owner remote */ + struct spa_list link; /**< link in the remote */ char *name; /**< the name of the stream */ struct pw_properties *properties; /**< properties of the stream */ @@ -813,8 +809,6 @@ pw_port_new(enum pw_direction direction, void pw_port_update_info(struct pw_port *port, const struct spa_port_info *info); int pw_port_register(struct pw_port *port, - struct pw_client *owner, - struct pw_global *parent, struct pw_properties *properties); /** Get the user data of a port, the size of the memory was given \ref in pw_port_new */ diff --git a/src/pipewire/remote.c b/src/pipewire/remote.c index fc06f93e..168c1420 100644 --- a/src/pipewire/remote.c +++ b/src/pipewire/remote.c @@ -221,7 +221,7 @@ struct pw_remote *pw_remote_new(struct pw_core *core, if ((protocol_name = pw_properties_get(properties, PW_KEY_PROTOCOL)) == NULL) { if (pw_module_load(core, "libpipewire-module-protocol-native", - NULL, NULL, NULL, NULL) == NULL) { + NULL, NULL) == NULL) { res = -errno; goto error_protocol; } @@ -239,9 +239,9 @@ struct pw_remote *pw_remote_new(struct pw_core *core, if (this->conn == NULL) goto error_connection; - pw_module_load(core, "libpipewire-module-rtkit", NULL, NULL, NULL, NULL); - pw_module_load(core, "libpipewire-module-client-node", NULL, NULL, NULL, NULL); - pw_module_load(core, "libpipewire-module-adapter", NULL, NULL, NULL, NULL); + pw_module_load(core, "libpipewire-module-rtkit", NULL, NULL); + pw_module_load(core, "libpipewire-module-client-node", NULL, NULL); + pw_module_load(core, "libpipewire-module-adapter", NULL, NULL); spa_list_append(&core->remote_list, &this->link); diff --git a/src/tests/test-core.c b/src/tests/test-core.c index d69cdaac..12772906 100644 --- a/src/tests/test-core.c +++ b/src/tests/test-core.c @@ -147,8 +147,6 @@ static void test_create(void) spa_assert(global != NULL); spa_assert(pw_core_find_global(core, 0) == global); spa_assert(pw_global_get_core(global) == core); - spa_assert(pw_global_get_owner(global) == NULL); - spa_assert(pw_global_get_parent(global) == global); spa_assert(pw_global_get_type(global) == PW_TYPE_INTERFACE_Core); spa_assert(pw_global_get_version(global) == PW_VERSION_CORE_PROXY); spa_assert(pw_global_get_id(global) == 0); diff --git a/src/tests/test-interfaces.c b/src/tests/test-interfaces.c index e4d029f2..f8f046c9 100644 --- a/src/tests/test-interfaces.c +++ b/src/tests/test-interfaces.c @@ -106,7 +106,7 @@ static void test_registry_abi(void) } methods = { PW_VERSION_REGISTRY_PROXY_METHODS, }; struct { uint32_t version; - void (*global) (void *object, uint32_t id, uint32_t parent_id, + void (*global) (void *object, uint32_t id, uint32_t permissions, uint32_t type, uint32_t version, const struct spa_dict *props); void (*global_remove) (void *object, uint32_t id); diff --git a/src/tools/pipewire-cli.c b/src/tools/pipewire-cli.c index 5092d793..c02d2b0d 100644 --- a/src/tools/pipewire-cli.c +++ b/src/tools/pipewire-cli.c @@ -54,7 +54,6 @@ struct data { struct global { struct remote_data *rd; uint32_t id; - uint32_t parent_id; uint32_t permissions; uint32_t type; uint32_t version; @@ -247,7 +246,7 @@ static bool do_load_module(struct data *data, const char *cmd, char *args, char return false; } - module = pw_module_load(data->core, a[0], n == 2 ? a[1] : NULL, NULL, NULL, NULL); + module = pw_module_load(data->core, a[0], n == 2 ? a[1] : NULL, NULL); if (module == NULL) { asprintf(error, "Could not load module"); return false; @@ -288,7 +287,7 @@ static int print_global(void *obj, void *data) if (global == NULL) return 0; - fprintf(stdout, "\tid %d, parent %d, type %s/%d\n", global->id, global->parent_id, + fprintf(stdout, "\tid %d, type %s/%d\n", global->id, spa_debug_type_find_name(pw_type_info(), global->type), global->version); if (global->properties) @@ -297,7 +296,7 @@ static int print_global(void *obj, void *data) return 0; } -static void registry_event_global(void *data, uint32_t id, uint32_t parent_id, +static void registry_event_global(void *data, uint32_t id, uint32_t permissions, uint32_t type, uint32_t version, const struct spa_dict *props) { @@ -308,7 +307,6 @@ static void registry_event_global(void *data, uint32_t id, uint32_t parent_id, global = calloc(1, sizeof(struct global)); global->rd = rd; global->id = id; - global->parent_id = parent_id; global->permissions = permissions; global->type = type; global->version = version; @@ -527,7 +525,6 @@ static void info_global(struct proxy_data *pd) return; fprintf(stdout, "\tid: %d\n", global->id); - fprintf(stdout, "\tparent_id: %d\n", global->parent_id); fprintf(stdout, "\tpermissions: %c%c%c\n", global->permissions & PW_PERM_R ? 'r' : '-', global->permissions & PW_PERM_W ? 'w' : '-', global->permissions & PW_PERM_X ? 'x' : '-'); @@ -1386,7 +1383,7 @@ int main(int argc, char *argv[]) data.core = pw_core_new(l, pw_properties_new(PW_KEY_CORE_DAEMON, "1", NULL), 0); info = pw_core_get_info(data.core); - pw_module_load(data.core, "libpipewire-module-link-factory", NULL, NULL, NULL, NULL); + pw_module_load(data.core, "libpipewire-module-link-factory", NULL, NULL); pw_loop_add_io(l, STDIN_FILENO, SPA_IO_IN|SPA_IO_HUP, false, do_input, &data); diff --git a/src/tools/pipewire-monitor.c b/src/tools/pipewire-monitor.c index 9bb3aa3b..abb2ad97 100644 --- a/src/tools/pipewire-monitor.c +++ b/src/tools/pipewire-monitor.c @@ -67,7 +67,6 @@ struct proxy_data { bool first; struct pw_proxy *proxy; uint32_t id; - uint32_t parent_id; uint32_t permissions; uint32_t version; uint32_t type; @@ -223,7 +222,6 @@ static void module_event_info(void *object, const struct pw_module_info *info) info = data->info = pw_module_info_update(data->info, info); printf("\tid: %d\n", data->id); - printf("\tparent_id: %d\n", data->parent_id); printf("\tpermissions: %c%c%c\n", data->permissions & PW_PERM_R ? 'r' : '-', data->permissions & PW_PERM_W ? 'w' : '-', data->permissions & PW_PERM_X ? 'x' : '-'); @@ -259,7 +257,6 @@ static void print_node(struct proxy_data *data) } printf("\tid: %d\n", data->id); - printf("\tparent_id: %d\n", data->parent_id); printf("\tpermissions: %c%c%c\n", data->permissions & PW_PERM_R ? 'r' : '-', data->permissions & PW_PERM_W ? 'w' : '-', data->permissions & PW_PERM_X ? 'x' : '-'); @@ -328,7 +325,6 @@ static void print_port(struct proxy_data *data) } printf("\tid: %d\n", data->id); - printf("\tparent_id: %d\n", data->parent_id); printf("\tpermissions: %c%c%c\n", data->permissions & PW_PERM_R ? 'r' : '-', data->permissions & PW_PERM_W ? 'w' : '-', data->permissions & PW_PERM_X ? 'x' : '-'); @@ -390,7 +386,6 @@ static void factory_event_info(void *object, const struct pw_factory_info *info) info = data->info = pw_factory_info_update(data->info, info); printf("\tid: %d\n", data->id); - printf("\tparent_id: %d\n", data->parent_id); printf("\tpermissions: %c%c%c\n", data->permissions & PW_PERM_R ? 'r' : '-', data->permissions & PW_PERM_W ? 'w' : '-', data->permissions & PW_PERM_X ? 'x' : '-'); @@ -427,7 +422,6 @@ static void client_event_info(void *object, const struct pw_client_info *info) info = data->info = pw_client_info_update(data->info, info); printf("\tid: %d\n", data->id); - printf("\tparent_id: %d\n", data->parent_id); printf("\tpermissions: %c%c%c\n", data->permissions & PW_PERM_R ? 'r' : '-', data->permissions & PW_PERM_W ? 'w' : '-', data->permissions & PW_PERM_X ? 'x' : '-'); @@ -462,7 +456,6 @@ static void link_event_info(void *object, const struct pw_link_info *info) info = data->info = pw_link_info_update(data->info, info); printf("\tid: %d\n", data->id); - printf("\tparent_id: %d\n", data->parent_id); printf("\tpermissions: %c%c%c\n", data->permissions & PW_PERM_R ? 'r' : '-', data->permissions & PW_PERM_W ? 'w' : '-', data->permissions & PW_PERM_X ? 'x' : '-'); @@ -511,7 +504,6 @@ static void print_device(struct proxy_data *data) } printf("\tid: %d\n", data->id); - printf("\tparent_id: %d\n", data->parent_id); printf("\tpermissions: %c%c%c\n", data->permissions & PW_PERM_R ? 'r' : '-', data->permissions & PW_PERM_W ? 'w' : '-', data->permissions & PW_PERM_X ? 'x' : '-'); @@ -577,7 +569,7 @@ static const struct pw_proxy_events proxy_events = { .destroy = destroy_proxy, }; -static void registry_event_global(void *data, uint32_t id, uint32_t parent_id, +static void registry_event_global(void *data, uint32_t id, uint32_t permissions, uint32_t type, uint32_t version, const struct spa_dict *props) { @@ -631,7 +623,6 @@ static void registry_event_global(void *data, uint32_t id, uint32_t parent_id, default: printf("added:\n"); printf("\tid: %u\n", id); - printf("\tparent_id: %d\n", parent_id); printf("\tpermissions: %c%c%c\n", permissions & PW_PERM_R ? 'r' : '-', permissions & PW_PERM_W ? 'w' : '-', permissions & PW_PERM_X ? 'x' : '-'); @@ -651,7 +642,6 @@ static void registry_event_global(void *data, uint32_t id, uint32_t parent_id, pd->first = true; pd->proxy = proxy; pd->id = id; - pd->parent_id = parent_id; pd->permissions = permissions; pd->version = version; pd->type = type; |