From c593d868fbff4d206f2815bb0f9cbab1f6f41822 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 19 Jan 2018 11:18:17 +0100 Subject: [PATCH] global: add properties Add properties to global objects to make it easier to select what nodes and objects to bind too. They can also be used to implement permissions on the globals based on properties. Add more error handling in _register. Make more functions return a result code. Make a separate pw_module_register, like all other objects. --- src/examples/export-sink.c | 2 +- src/examples/export-source.c | 2 +- src/examples/local-v4l2.c | 4 +- src/gst/gstpipewiredeviceprovider.c | 3 +- src/modules/module-autolink.c | 2 +- src/modules/module-client-node.c | 2 +- src/modules/module-jack.c | 6 +-- src/modules/module-jack/jack-node.c | 4 +- src/modules/module-link-factory.c | 4 +- src/modules/module-mixer.c | 2 +- src/modules/module-protocol-native.c | 2 +- .../module-protocol-native/protocol-native.c | 44 +++++++++++---- src/modules/spa/module-node-factory.c | 2 +- src/modules/spa/spa-node.c | 2 +- src/pipewire/client.c | 32 +++++++---- src/pipewire/client.h | 11 ++-- src/pipewire/command.c | 1 + src/pipewire/core.c | 9 +++- src/pipewire/core.h | 2 +- src/pipewire/factory.c | 22 +++++--- src/pipewire/factory.h | 7 +-- src/pipewire/global.c | 15 +++++- src/pipewire/global.h | 15 ++++-- src/pipewire/interfaces.h | 4 +- src/pipewire/link.c | 25 +++++---- src/pipewire/link.h | 7 +-- src/pipewire/module.c | 33 ++++++++---- src/pipewire/module.h | 6 +++ src/pipewire/node.c | 37 +++++++++---- src/pipewire/node.h | 9 ++-- src/pipewire/port.c | 4 +- src/pipewire/port.h | 2 +- src/pipewire/private.h | 2 + src/pipewire/properties.c | 14 ++--- src/pipewire/properties.h | 4 +- src/pipewire/protocol.c | 9 +++- src/pipewire/protocol.h | 4 +- src/pipewire/remote.c | 9 ++-- src/pipewire/remote.h | 4 +- src/pipewire/stream.c | 6 ++- src/pipewire/stream.h | 4 +- src/pipewire/type.c | 3 +- src/pipewire/type.h | 3 +- src/tools/pipewire-cli.c | 54 +++++++++++-------- src/tools/pipewire-monitor.c | 6 ++- 45 files changed, 295 insertions(+), 149 deletions(-) diff --git a/src/examples/export-sink.c b/src/examples/export-sink.c index a8497b133..b5c7e80ef 100644 --- a/src/examples/export-sink.c +++ b/src/examples/export-sink.c @@ -536,7 +536,7 @@ static void make_node(struct data *data) data->node = pw_node_new(data->core, "SDL-sink", props, 0); data->impl_node = impl_node; pw_node_set_implementation(data->node, &data->impl_node); - pw_node_register(data->node, NULL, NULL); + pw_node_register(data->node, NULL, NULL, NULL); pw_node_set_active(data->node, true); pw_remote_export(data->remote, data->node); diff --git a/src/examples/export-source.c b/src/examples/export-source.c index 7fc2d1d8d..90384fec2 100644 --- a/src/examples/export-source.c +++ b/src/examples/export-source.c @@ -516,7 +516,7 @@ static void make_node(struct data *data) data->impl_node = impl_node; pw_node_set_implementation(data->node, &data->impl_node); - pw_node_register(data->node, NULL, NULL); + pw_node_register(data->node, NULL, NULL, NULL); pw_node_set_active(data->node, true); pw_remote_export(data->remote, data->node); diff --git a/src/examples/local-v4l2.c b/src/examples/local-v4l2.c index b71adae9f..410dc66fe 100644 --- a/src/examples/local-v4l2.c +++ b/src/examples/local-v4l2.c @@ -480,7 +480,7 @@ static void make_nodes(struct data *data) data->impl_node = impl_node; pw_node_set_implementation(data->node, &data->impl_node); - pw_node_register(data->node, NULL, NULL); + pw_node_register(data->node, NULL, NULL, NULL); factory = pw_core_find_factory(data->core, "spa-node-factory"); props = pw_properties_new("spa.library.name", "v4l2/libspa-v4l2", @@ -498,7 +498,7 @@ static void make_nodes(struct data *data) NULL, NULL, 0); - pw_link_register(data->link, NULL, NULL); + pw_link_register(data->link, NULL, NULL, NULL); pw_node_set_active(data->node, true); pw_node_set_active(data->v4l2, true); diff --git a/src/gst/gstpipewiredeviceprovider.c b/src/gst/gstpipewiredeviceprovider.c index 62382b580..c08d588a2 100644 --- a/src/gst/gstpipewiredeviceprovider.c +++ b/src/gst/gstpipewiredeviceprovider.c @@ -366,7 +366,8 @@ static const struct pw_node_proxy_events node_events = { static void registry_event_global(void *data, uint32_t id, uint32_t parent_id, uint32_t permissions, - uint32_t type, uint32_t version) + uint32_t type, uint32_t version, + const struct spa_dict *props) { struct registry_data *rd = data; GstPipeWireDeviceProvider *self = rd->self; diff --git a/src/modules/module-autolink.c b/src/modules/module-autolink.c index dfa13bf5c..45353b88e 100644 --- a/src/modules/module-autolink.c +++ b/src/modules/module-autolink.c @@ -226,7 +226,7 @@ static void try_link_port(struct pw_node *node, struct pw_port *port, struct nod pw_link_add_listener(link, &ld->link_listener, &link_events, ld); spa_list_append(&info->links, &ld->l); - pw_link_register(link, NULL, pw_module_get_global(impl->module)); + pw_link_register(link, NULL, pw_module_get_global(impl->module), NULL); try_link_controls(impl, port, target); diff --git a/src/modules/module-client-node.c b/src/modules/module-client-node.c index b1ef25e0f..616a6c950 100644 --- a/src/modules/module-client-node.c +++ b/src/modules/module-client-node.c @@ -133,7 +133,7 @@ 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)); + pw_factory_register(factory, NULL, pw_module_get_global(module), NULL); pw_module_add_listener(module, &data->module_listener, &module_events, data); diff --git a/src/modules/module-jack.c b/src/modules/module-jack.c index ff928cd6d..370e53c9c 100644 --- a/src/modules/module-jack.c +++ b/src/modules/module-jack.c @@ -813,7 +813,7 @@ handle_connect_name_ports(struct client *client) ld->in_port = in_port; spa_list_append(&impl->link_list, &ld->link_link); pw_link_add_listener(link, &ld->link_listener, &link_events, ld); - pw_link_register(link, NULL, pw_module_get_global(impl->module)); + pw_link_register(link, NULL, pw_module_get_global(impl->module), NULL); notify_clients(impl, jack_notify_PortConnectCallback, false, "", src_id, dst_id); @@ -1060,7 +1060,7 @@ static struct client *client_new(struct impl *impl, int fd) pw_client_add_listener(client, &this->client_listener, &client_events, this); - pw_client_register(client, NULL, pw_module_get_global(impl->module)); + pw_client_register(client, NULL, pw_module_get_global(impl->module), NULL); pw_log_debug("module-jack %p: added new client", impl); @@ -1339,7 +1339,7 @@ static int on_global(void *data, struct pw_global *global) pw_log_debug("module-jack %p: using buffer_size %d", impl, impl->server.engine_control->buffer_size); - pw_link_register(impl->sink_link, NULL, pw_module_get_global(impl->module)); + pw_link_register(impl->sink_link, NULL, pw_module_get_global(impl->module), NULL); return 1; } diff --git a/src/modules/module-jack/jack-node.c b/src/modules/module-jack/jack-node.c index eba04e177..6cd4bee43 100644 --- a/src/modules/module-jack/jack-node.c +++ b/src/modules/module-jack/jack-node.c @@ -944,7 +944,7 @@ struct pw_jack_node *pw_jack_node_new(struct pw_core *core, jack_connection_manager_init_ref_num(conn, ref_num); jack_graph_manager_next_stop(mgr); - pw_node_register(node, NULL, parent); + pw_node_register(node, NULL, parent, NULL); pw_node_set_active(node, true); return this; @@ -1041,7 +1041,7 @@ pw_jack_driver_new(struct pw_core *core, this->driver_out = alloc_port(this, PW_DIRECTION_OUTPUT, 0); pw_port_add(this->driver_out->port, node); } - pw_node_register(node, NULL, parent); + pw_node_register(node, NULL, parent, NULL); pw_node_set_active(node, true); return this; diff --git a/src/modules/module-link-factory.c b/src/modules/module-link-factory.c index 136268dbe..5be8d5a79 100644 --- a/src/modules/module-link-factory.c +++ b/src/modules/module-link-factory.c @@ -113,7 +113,7 @@ static void *create_object(void *_data, if (link == NULL) goto no_mem; - pw_link_register(link, client, pw_client_get_global(client)); + pw_link_register(link, client, pw_client_get_global(client), NULL); res = pw_global_bind(pw_link_get_global(link), client, PW_PERM_RWX, PW_VERSION_LINK, new_id); if (res < 0) @@ -206,7 +206,7 @@ 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)); + pw_factory_register(factory, NULL, pw_module_get_global(module), NULL); pw_module_add_listener(module, &data->module_listener, &module_events, data); diff --git a/src/modules/module-mixer.c b/src/modules/module-mixer.c index 9df5f8e48..f3c1a2f34 100644 --- a/src/modules/module-mixer.c +++ b/src/modules/module-mixer.c @@ -175,7 +175,7 @@ static int on_global(void *data, struct pw_global *global) NULL, pw_properties_new(PW_LINK_PROP_PASSIVE, "true", NULL), &error, 0); - pw_link_register(link, NULL, pw_module_get_global(impl->module)); + pw_link_register(link, NULL, pw_module_get_global(impl->module), NULL); return 0; } diff --git a/src/modules/module-protocol-native.c b/src/modules/module-protocol-native.c index 256ccccd6..d7a095dd8 100644 --- a/src/modules/module-protocol-native.c +++ b/src/modules/module-protocol-native.c @@ -334,7 +334,7 @@ static struct pw_client *client_new(struct server *s, int fd) spa_list_append(&s->this.client_list, &client->protocol_link); pw_client_add_listener(client, &this->client_listener, &client_events, this); - pw_client_register(client, NULL, pw_module_get_global(pd->module)); + pw_client_register(client, NULL, pw_module_get_global(pd->module), NULL); pw_global_bind(pw_core_get_global(core), client, PW_PERM_RWX, PW_VERSION_CORE, 0); diff --git a/src/modules/module-protocol-native/protocol-native.c b/src/modules/module-protocol-native/protocol-native.c index 2342c8217..e37f4b554 100644 --- a/src/modules/module-protocol-native/protocol-native.c +++ b/src/modules/module-protocol-native/protocol-native.c @@ -488,19 +488,31 @@ static int core_demarshal_update_types_server(void *object, void *data, size_t s } static void registry_marshal_global(void *object, uint32_t id, uint32_t parent_id, uint32_t permissions, - uint32_t type, uint32_t version) + uint32_t type, uint32_t version, const struct spa_dict *props) { struct pw_resource *resource = object; struct spa_pod_builder *b; + uint32_t i, n_items; b = pw_protocol_native_begin_resource(resource, PW_REGISTRY_PROXY_EVENT_GLOBAL); - spa_pod_builder_struct(b, - "i", id, - "i", parent_id, - "i", permissions, - "I", type, - "i", version); + n_items = props ? props->n_items : 0; + + spa_pod_builder_add(b, + "[", + "i", id, + "i", parent_id, + "i", permissions, + "I", type, + "i", version, + "i", n_items, NULL); + + for (i = 0; i < n_items; i++) { + spa_pod_builder_add(b, + "s", props->items[i].key, + "s", props->items[i].value, NULL); + } + spa_pod_builder_add(b, "]", NULL); pw_protocol_native_end_resource(resource, b); } @@ -874,7 +886,8 @@ static int registry_demarshal_global(void *object, void *data, size_t size) { struct pw_proxy *proxy = object; struct spa_pod_parser prs; - uint32_t id, parent_id, permissions, type, version; + uint32_t id, parent_id, permissions, type, version, i; + struct spa_dict props; spa_pod_parser_init(&prs, data, size, 0); if (spa_pod_parser_get(&prs, @@ -883,10 +896,21 @@ static int registry_demarshal_global(void *object, void *data, size_t size) "i", &parent_id, "i", &permissions, "I", &type, - "i", &version, NULL) < 0) + "i", &version, + "i", &props.n_items, NULL) < 0) return -EINVAL; - pw_proxy_notify(proxy, struct pw_registry_proxy_events, global, id, parent_id, permissions, type, version); + props.items = alloca(props.n_items * sizeof(struct spa_dict_item)); + for (i = 0; i < props.n_items; i++) { + if (spa_pod_parser_get(&prs, + "s", &props.items[i].key, + "s", &props.items[i].value, NULL) < 0) + return -EINVAL; + } + + pw_proxy_notify(proxy, struct pw_registry_proxy_events, + global, id, parent_id, permissions, type, version, + props.n_items > 0 ? &props : NULL); return 0; } diff --git a/src/modules/spa/module-node-factory.c b/src/modules/spa/module-node-factory.c index 33983797e..802fd75a4 100644 --- a/src/modules/spa/module-node-factory.c +++ b/src/modules/spa/module-node-factory.c @@ -176,7 +176,7 @@ static int module_init(struct pw_module *module, struct pw_properties *propertie pw_log_debug("module %p: new", module); pw_module_add_listener(module, &data->module_listener, &module_events, data); - pw_factory_register(factory, NULL, pw_module_get_global(module)); + pw_factory_register(factory, NULL, pw_module_get_global(module), NULL); return 0; } diff --git a/src/modules/spa/spa-node.c b/src/modules/spa/spa-node.c index 2c83a9eaf..34fe56d58 100644 --- a/src/modules/spa/spa-node.c +++ b/src/modules/spa/spa-node.c @@ -75,7 +75,7 @@ static void pw_spa_node_destroy(void *data) static void complete_init(struct impl *impl) { struct pw_node *this = impl->this; - pw_node_register(this, impl->owner, impl->parent); + pw_node_register(this, impl->owner, impl->parent, NULL); if (impl->flags & PW_SPA_NODE_FLAG_ACTIVATE) pw_node_set_active(this, true); } diff --git a/src/pipewire/client.c b/src/pipewire/client.c index 7c95fb116..b4354cda7 100644 --- a/src/pipewire/client.c +++ b/src/pipewire/client.c @@ -201,21 +201,28 @@ struct pw_client *pw_client_new(struct pw_core *core, return this; } -void pw_client_register(struct pw_client *client, - struct pw_client *owner, - struct pw_global *parent) +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; pw_log_debug("client %p: register parent %d", client, parent ? parent->id : SPA_ID_INVALID); + spa_list_append(&core->client_list, &client->link); - client->global = pw_global_new(core, core->type.client, PW_VERSION_CLIENT, - client_bind_func, client); - if (client->global != NULL) { - pw_global_register(client->global, owner, parent); - client->info.id = client->global->id; - } + client->global = pw_global_new(core, + core->type.client, PW_VERSION_CLIENT, + properties, + client_bind_func, client); + if (client->global == NULL) + return -ENOMEM; + + pw_global_register(client->global, owner, parent); + client->info.id = client->global->id; + + return 0; } struct pw_core *pw_client_get_core(struct pw_client *client) @@ -325,7 +332,7 @@ const struct pw_client_info *pw_client_get_info(struct pw_client *client) * * \memberof pw_client */ -void pw_client_update_properties(struct pw_client *client, const struct spa_dict *dict) +int pw_client_update_properties(struct pw_client *client, const struct spa_dict *dict) { struct pw_resource *resource; @@ -350,6 +357,8 @@ void pw_client_update_properties(struct pw_client *client, const struct spa_dict pw_client_resource_info(resource, &client->info); client->info.change_mask = 0; + + return 0; } struct permissions_update { @@ -410,7 +419,7 @@ static uint32_t parse_mask(const char *str) return mask; } -void pw_client_update_permissions(struct pw_client *client, const struct spa_dict *dict) +int pw_client_update_permissions(struct pw_client *client, const struct spa_dict *dict) { struct impl *impl = SPA_CONTAINER_OF(client, struct impl, this); int i; @@ -452,6 +461,7 @@ void pw_client_update_permissions(struct pw_client *client, const struct spa_dic pw_core_for_each_global(client->core, do_permissions, &update); } } + return 0; } void pw_client_set_busy(struct pw_client *client, bool busy) diff --git a/src/pipewire/client.h b/src/pipewire/client.h index 82b2a85cf..f653f93eb 100644 --- a/src/pipewire/client.h +++ b/src/pipewire/client.h @@ -131,9 +131,10 @@ pw_client_new(struct pw_core *core, /**< the core object */ void pw_client_destroy(struct pw_client *client); /** Finish configuration and register a client */ -void pw_client_register(struct pw_client *client, /**< the client to register */ - struct pw_client *owner, /**< optional owner */ - struct pw_global *parent /**< the client parent */); +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 */ void *pw_client_get_user_data(struct pw_client *client); @@ -142,10 +143,10 @@ void *pw_client_get_user_data(struct pw_client *client); const struct pw_client_info *pw_client_get_info(struct pw_client *client); /** Update the client properties */ -void pw_client_update_properties(struct pw_client *client, const struct spa_dict *dict); +int pw_client_update_properties(struct pw_client *client, const struct spa_dict *dict); /** Update the client permissions */ -void pw_client_update_permissions(struct pw_client *client, const struct spa_dict *dict); +int pw_client_update_permissions(struct pw_client *client, const struct spa_dict *dict); /** Get the client properties */ const struct pw_properties *pw_client_get_properties(struct pw_client *client); diff --git a/src/pipewire/command.c b/src/pipewire/command.c index cdb7d8a51..41908cbf1 100644 --- a/src/pipewire/command.c +++ b/src/pipewire/command.c @@ -97,6 +97,7 @@ execute_command_module_load(struct pw_command *command, struct pw_core *core, ch asprintf(err, "could not load module \"%s\"", command->args[1]); return -ENOMEM; } + pw_module_register(module, NULL, NULL, NULL); return 0; } diff --git a/src/pipewire/core.c b/src/pipewire/core.c index 46311fb93..338b4a14c 100644 --- a/src/pipewire/core.c +++ b/src/pipewire/core.c @@ -157,7 +157,9 @@ static void core_get_registry(void *object, uint32_t version, uint32_t new_id) global->parent->id, permissions, global->type, - global->version); + global->version, + global->properties ? + &global->properties->dict : NULL); } } @@ -391,6 +393,7 @@ struct pw_core *pw_core_new(struct pw_loop *main_loop, struct pw_properties *pro this->global = pw_global_new(this, this->type.core, PW_VERSION_CORE, + NULL, core_bind_func, this); if (this->global != NULL) { @@ -502,7 +505,7 @@ const struct pw_properties *pw_core_get_properties(struct pw_core *core) * * \memberof pw_core */ -void pw_core_update_properties(struct pw_core *core, const struct spa_dict *dict) +int pw_core_update_properties(struct pw_core *core, const struct spa_dict *dict) { struct pw_resource *resource; uint32_t i; @@ -520,6 +523,8 @@ void pw_core_update_properties(struct pw_core *core, const struct spa_dict *dict pw_core_resource_info(resource, &core->info); core->info.change_mask = 0; + + return 0; } int pw_core_for_each_global(struct pw_core *core, diff --git a/src/pipewire/core.h b/src/pipewire/core.h index 76b8b2378..b2036e291 100644 --- a/src/pipewire/core.h +++ b/src/pipewire/core.h @@ -143,7 +143,7 @@ struct pw_global *pw_core_get_global(struct pw_core *core); const struct pw_properties *pw_core_get_properties(struct pw_core *core); /** Update the core properties */ -void pw_core_update_properties(struct pw_core *core, const struct spa_dict *dict); +int pw_core_update_properties(struct pw_core *core, const struct spa_dict *dict); /** Get the core support objects */ const struct spa_support *pw_core_get_support(struct pw_core *core, uint32_t *n_support); diff --git a/src/pipewire/factory.c b/src/pipewire/factory.c index 599d968c5..efa5d9106 100644 --- a/src/pipewire/factory.c +++ b/src/pipewire/factory.c @@ -116,18 +116,26 @@ factory_bind_func(struct pw_global *global, return -ENOMEM; } -void pw_factory_register(struct pw_factory *factory, +int pw_factory_register(struct pw_factory *factory, struct pw_client *owner, - struct pw_global *parent) + struct pw_global *parent, + struct pw_properties *properties) { struct pw_core *core = factory->core; + spa_list_append(&core->factory_list, &factory->link); + factory->global = pw_global_new(core, - core->type.factory, 0, factory_bind_func, factory); - if (factory->global != NULL) { - pw_global_register(factory->global, owner, parent); - factory->info.id = factory->global->id; - } + core->type.factory, PW_VERSION_FACTORY, + properties, + factory_bind_func, factory); + if (factory->global == NULL) + return -ENOMEM; + + pw_global_register(factory->global, owner, parent); + factory->info.id = factory->global->id; + + return 0; } void *pw_factory_get_user_data(struct pw_factory *factory) diff --git a/src/pipewire/factory.h b/src/pipewire/factory.h index 7caf0087c..eb62146a3 100644 --- a/src/pipewire/factory.h +++ b/src/pipewire/factory.h @@ -70,9 +70,10 @@ struct pw_factory *pw_factory_new(struct pw_core *core, struct pw_properties *properties, size_t user_data_size); -void pw_factory_register(struct pw_factory *factory, - struct pw_client *owner, - struct pw_global *parent); +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 d9978458c..9157918f2 100644 --- a/src/pipewire/global.c +++ b/src/pipewire/global.c @@ -53,6 +53,7 @@ uint32_t pw_global_get_permissions(struct pw_global *global, struct pw_client *c * \param core a core object * \param type the type of the global * \param version the version of the type + * \param properties extra properties * \param bind a function to bind to this global * \param object the associated object * \return a result global @@ -63,6 +64,7 @@ struct pw_global * pw_global_new(struct pw_core *core, uint32_t type, uint32_t version, + struct pw_properties *properties, pw_bind_func_t bind, void *object) { @@ -80,6 +82,7 @@ pw_global_new(struct pw_core *core, this->version = version; this->bind = bind; this->object = object; + this->properties = properties; pw_log_debug("global %p: new %s", this, spa_type_map_get_type(core->type.map, this->type)); @@ -129,7 +132,9 @@ pw_global_register(struct pw_global *global, global->parent->id, permissions, global->type, - global->version); + global->version, + global->properties ? + &global->properties->dict : NULL); } return 0; } @@ -159,6 +164,11 @@ uint32_t pw_global_get_version(struct pw_global *global) return global->version; } +const struct pw_properties *pw_global_get_properties(struct pw_global *global) +{ + return global->properties; +} + void * pw_global_get_object(struct pw_global *global) { return global->object; @@ -237,6 +247,9 @@ void pw_global_destroy(struct pw_global *global) spa_list_remove(&global->link); spa_hook_list_call(&core->listener_list, struct pw_core_events, global_removed, global); + if (global->properties) + pw_properties_free(global->properties); + pw_log_debug("global %p: free", global); free(global); } diff --git a/src/pipewire/global.h b/src/pipewire/global.h index b92bc0d90..b85b2efa9 100644 --- a/src/pipewire/global.h +++ b/src/pipewire/global.h @@ -53,6 +53,7 @@ struct pw_global; #include #include +#include /** The function to let a client bind to a global */ typedef int (*pw_bind_func_t) (struct pw_global *global, /**< the global to bind */ @@ -63,11 +64,12 @@ typedef int (*pw_bind_func_t) (struct pw_global *global, /**< the global to bind /** Create a new global object */ struct pw_global * -pw_global_new(struct pw_core *core, - uint32_t type, - uint32_t version, - pw_bind_func_t bind, - void *object); +pw_global_new(struct pw_core *core, /**< the core */ + uint32_t type, /**< the interface type of the global */ + uint32_t version, /**< the interface version of the global */ + struct pw_properties *properties, /**< extra properties */ + pw_bind_func_t bind, /**< function to bind to the global */ + void *object /**< global object */); /** Register a global object to the core registry */ int pw_global_register(struct pw_global *global, @@ -92,6 +94,9 @@ uint32_t pw_global_get_type(struct pw_global *global); /** Get the global version */ uint32_t pw_global_get_version(struct pw_global *global); +/** Get the global properties */ +const struct pw_properties *pw_global_get_properties(struct pw_global *global); + /** Get the object associated with the global. This depends on the type of the * global */ void *pw_global_get_object(struct pw_global *global); diff --git a/src/pipewire/interfaces.h b/src/pipewire/interfaces.h index 0b1179830..37a18d7cc 100644 --- a/src/pipewire/interfaces.h +++ b/src/pipewire/interfaces.h @@ -395,9 +395,11 @@ struct pw_registry_proxy_events { * \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, - uint32_t permissions, uint32_t type, uint32_t version); + uint32_t permissions, uint32_t type, uint32_t version, + const struct spa_dict *props); /** * Notify of a global object removal * diff --git a/src/pipewire/link.c b/src/pipewire/link.c index 1c1d61d12..111be219d 100644 --- a/src/pipewire/link.c +++ b/src/pipewire/link.c @@ -1201,21 +1201,25 @@ struct pw_link *pw_link_new(struct pw_core *core, return NULL; } -void pw_link_register(struct pw_link *link, - struct pw_client *owner, - struct pw_global *parent) +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 *input_node, *output_node; spa_list_append(&core->link_list, &link->link); - link->global = pw_global_new(core, core->type.link, PW_VERSION_LINK, - link_bind_func, link); - if (link->global != NULL) { - pw_global_register(link->global, owner, parent); - link->info.id = link->global->id; - } + link->global = pw_global_new(core, + core->type.link, PW_VERSION_LINK, + properties, + link_bind_func, link); + if (link->global == NULL) + return -ENOMEM; + + pw_global_register(link->global, owner, parent); + link->info.id = link->global->id; input_node = link->input->node; output_node = link->output->node; @@ -1234,8 +1238,9 @@ void pw_link_register(struct pw_link *link, output_node->n_used_output_links + 1 > output_node->idle_used_output_links) && input_node->active && output_node->active) pw_link_activate(link); -} + return 0; +} void pw_link_destroy(struct pw_link *link) { diff --git a/src/pipewire/link.h b/src/pipewire/link.h index 506d2d0fb..5c4aa0c44 100644 --- a/src/pipewire/link.h +++ b/src/pipewire/link.h @@ -96,9 +96,10 @@ void pw_link_add_listener(struct pw_link *link, void *data); /** Finish link configuration and register */ -void pw_link_register(struct pw_link *link, /**< the link to register */ - struct pw_client *owner, /**< optional link owner */ - struct pw_global *parent /**< parent global */); +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 */ struct pw_core *pw_link_get_core(struct pw_link *link); diff --git a/src/pipewire/module.c b/src/pipewire/module.c index bdecadfeb..a1a347f2b 100644 --- a/src/pipewire/module.c +++ b/src/pipewire/module.c @@ -218,15 +218,6 @@ struct pw_module *pw_module_load(struct pw_core *core, const char *name, const c this->info.args = args ? strdup(args) : NULL; this->info.props = NULL; - spa_list_append(&core->module_list, &this->link); - this->global = pw_global_new(core, core->type.module, PW_VERSION_MODULE, - module_bind_func, this); - - if (this->global != NULL) { - pw_global_register(this->global, NULL, core->global); - this->info.id = this->global->id; - } - if ((res = init_func(this, args)) < 0) goto init_failed; @@ -253,6 +244,30 @@ struct pw_module *pw_module_load(struct pw_core *core, const char *name, const c return NULL; } +int pw_module_register(struct pw_module *module, + struct pw_client *owner, + struct pw_global *parent, + struct pw_properties *properties) +{ + struct pw_core *core = module->core; + + spa_list_append(&core->module_list, &module->link); + + module->global = pw_global_new(core, + core->type.module, PW_VERSION_MODULE, + properties, + module_bind_func, module); + + if (module->global == NULL) + return -ENOMEM; + + pw_global_register(module->global, owner, parent); + + module->info.id = module->global->id; + + return 0; +} + /** Destroy a module * \param module the module to destroy * \memberof pw_module diff --git a/src/pipewire/module.h b/src/pipewire/module.h index 42865e101..784b094d1 100644 --- a/src/pipewire/module.h +++ b/src/pipewire/module.h @@ -66,6 +66,12 @@ struct pw_module_events { struct pw_module * pw_module_load(struct pw_core *core, const char *name, const char *args); +/** Finish module configuration and register */ +int pw_module_register(struct pw_module *module, /**< the module to register */ + 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 */ struct pw_core * pw_module_get_core(struct pw_module *module); diff --git a/src/pipewire/node.c b/src/pipewire/node.c index a44884383..80305406c 100644 --- a/src/pipewire/node.c +++ b/src/pipewire/node.c @@ -329,11 +329,13 @@ do_node_add(struct spa_loop *loop, return 0; } -void pw_node_register(struct pw_node *this, - struct pw_client *owner, - struct pw_global *parent) +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; + const char *str; pw_log_debug("node %p: register", this); @@ -342,17 +344,30 @@ void pw_node_register(struct pw_node *this, pw_loop_invoke(this->data_loop, do_node_add, 1, NULL, 0, false, this); + if (properties == NULL) + properties = pw_properties_new(NULL, NULL); + if (properties == NULL) + return -ENOMEM; + + if ((str = pw_properties_get(this->properties, "media.class")) != NULL) + pw_properties_set(properties, "media.class", str); + spa_list_append(&core->node_list, &this->link); - this->global = pw_global_new(core, core->type.node, PW_VERSION_NODE, - node_bind_func, this); - if (this->global != NULL) { - pw_global_register(this->global, owner, parent); - this->info.id = this->global->id; - } + this->global = pw_global_new(core, + core->type.node, PW_VERSION_NODE, + properties, + node_bind_func, this); + if (this->global == NULL) + return -ENOMEM; + + pw_global_register(this->global, owner, parent); + this->info.id = this->global->id; spa_hook_list_call(&this->listener_list, struct pw_node_events, initialized); pw_node_update_state(this, PW_NODE_STATE_SUSPENDED, NULL); + + return 0; } struct pw_node *pw_node_new(struct pw_core *core, @@ -434,7 +449,7 @@ const struct pw_properties *pw_node_get_properties(struct pw_node *node) return node->properties; } -void pw_node_update_properties(struct pw_node *node, const struct spa_dict *dict) +int pw_node_update_properties(struct pw_node *node, const struct spa_dict *dict) { struct pw_resource *resource; uint32_t i; @@ -452,6 +467,8 @@ void pw_node_update_properties(struct pw_node *node, const struct spa_dict *dict pw_node_resource_info(resource, &node->info); node->info.change_mask = 0; + + return 0; } static void node_done(void *data, int seq, int res) diff --git a/src/pipewire/node.h b/src/pipewire/node.h index 307b82a18..a982c35f7 100644 --- a/src/pipewire/node.h +++ b/src/pipewire/node.h @@ -102,9 +102,10 @@ pw_node_new(struct pw_core *core, /**< the core */ size_t user_data_size /**< user data size */); /** Complete initialization of the node and register */ -void pw_node_register(struct pw_node *node, /**< node to register */ - struct pw_client *owner, /**< optional owner */ - struct pw_global *parent /**< optional parent */); +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 */ void pw_node_destroy(struct pw_node *node); @@ -125,7 +126,7 @@ struct pw_global *pw_node_get_global(struct pw_node *node); const struct pw_properties *pw_node_get_properties(struct pw_node *node); /** Update the node properties */ -void pw_node_update_properties(struct pw_node *node, const struct spa_dict *dict); +int pw_node_update_properties(struct pw_node *node, const struct spa_dict *dict); /** Set the node implementation */ void pw_node_set_implementation(struct pw_node *node, struct spa_node *spa_node); diff --git a/src/pipewire/port.c b/src/pipewire/port.c index 172596762..1c20b304a 100644 --- a/src/pipewire/port.c +++ b/src/pipewire/port.c @@ -233,7 +233,7 @@ const struct pw_properties *pw_port_get_properties(struct pw_port *port) return port->properties; } -void pw_port_update_properties(struct pw_port *port, const struct spa_dict *dict) +int pw_port_update_properties(struct pw_port *port, const struct spa_dict *dict) { uint32_t i; for (i = 0; i < dict->n_items; i++) @@ -241,6 +241,8 @@ void pw_port_update_properties(struct pw_port *port, const struct spa_dict *dict spa_hook_list_call(&port->listener_list, struct pw_port_events, properties_changed, port->properties); + + return 0; } struct pw_node *pw_port_get_node(struct pw_port *port) diff --git a/src/pipewire/port.h b/src/pipewire/port.h index 6386d4b94..247744e41 100644 --- a/src/pipewire/port.h +++ b/src/pipewire/port.h @@ -93,7 +93,7 @@ enum pw_direction pw_port_get_direction(struct pw_port *port); const struct pw_properties *pw_port_get_properties(struct pw_port *port); /** Update the port properties */ -void pw_port_update_properties(struct pw_port *port, const struct spa_dict *dict); +int pw_port_update_properties(struct pw_port *port, const struct spa_dict *dict); /** Get the port id */ uint32_t pw_port_get_id(struct pw_port *port); diff --git a/src/pipewire/private.h b/src/pipewire/private.h index 532f8a68c..1f1e7418d 100644 --- a/src/pipewire/private.h +++ b/src/pipewire/private.h @@ -109,6 +109,8 @@ struct pw_global { uint32_t id; /**< server id of the object */ struct pw_global *parent; /**< parent global */ + struct pw_properties *properties; /**< properties of the global */ + uint32_t type; /**< type of interface */ uint32_t version; /**< version of interface */ pw_bind_func_t bind; /**< function to bind to the interface */ diff --git a/src/pipewire/properties.c b/src/pipewire/properties.c index 9a4906b38..fbe8a51f0 100644 --- a/src/pipewire/properties.c +++ b/src/pipewire/properties.c @@ -30,7 +30,7 @@ struct properties { }; /** \endcond */ -static void add_func(struct pw_properties *this, char *key, char *value) +static int add_func(struct pw_properties *this, char *key, char *value) { struct spa_dict_item *item; struct properties *impl = SPA_CONTAINER_OF(this, struct properties, this); @@ -41,6 +41,7 @@ static void add_func(struct pw_properties *this, char *key, char *value) this->dict.items = impl->items.data; this->dict.n_items = pw_array_get_len(&impl->items, struct spa_dict_item); + return 0; } static void clear_item(struct spa_dict_item *item) @@ -200,7 +201,7 @@ void pw_properties_free(struct pw_properties *properties) free(impl); } -static void do_replace(struct pw_properties *properties, char *key, char *value) +static int do_replace(struct pw_properties *properties, char *key, char *value) { struct properties *impl = SPA_CONTAINER_OF(properties, struct properties, this); int index = find_index(properties, key); @@ -224,6 +225,7 @@ static void do_replace(struct pw_properties *properties, char *key, char *value) item->value = value; } } + return 0; } /** Set a property value @@ -238,9 +240,9 @@ static void do_replace(struct pw_properties *properties, char *key, char *value) * * \memberof pw_properties */ -void pw_properties_set(struct pw_properties *properties, const char *key, const char *value) +int pw_properties_set(struct pw_properties *properties, const char *key, const char *value) { - do_replace(properties, strdup(key), value ? strdup(value) : NULL); + return do_replace(properties, strdup(key), value ? strdup(value) : NULL); } /** Set a property value by format @@ -255,7 +257,7 @@ void pw_properties_set(struct pw_properties *properties, const char *key, const * * \memberof pw_properties */ -void pw_properties_setf(struct pw_properties *properties, const char *key, const char *format, ...) +int pw_properties_setf(struct pw_properties *properties, const char *key, const char *format, ...) { va_list varargs; char *value; @@ -264,7 +266,7 @@ void pw_properties_setf(struct pw_properties *properties, const char *key, const vasprintf(&value, format, varargs); va_end(varargs); - do_replace(properties, strdup(key), value); + return do_replace(properties, strdup(key), value); } /** Get a property diff --git a/src/pipewire/properties.h b/src/pipewire/properties.h index 0716e224a..2176603a0 100644 --- a/src/pipewire/properties.h +++ b/src/pipewire/properties.h @@ -55,10 +55,10 @@ pw_properties_merge(const struct pw_properties *oldprops, void pw_properties_free(struct pw_properties *properties); -void +int pw_properties_set(struct pw_properties *properties, const char *key, const char *value); -void +int pw_properties_setf(struct pw_properties *properties, const char *key, const char *format, ...) SPA_PRINTF_FUNC(3, 4); const char * diff --git a/src/pipewire/protocol.c b/src/pipewire/protocol.c index 4646c3d30..da961163a 100644 --- a/src/pipewire/protocol.c +++ b/src/pipewire/protocol.c @@ -17,6 +17,8 @@ * Boston, MA 02110-1301, USA. */ +#include + #include #include @@ -111,13 +113,16 @@ void pw_protocol_add_listener(struct pw_protocol *protocol, spa_hook_list_append(&protocol->listener_list, listener, events, data); } -void +int pw_protocol_add_marshal(struct pw_protocol *protocol, const struct pw_protocol_marshal *marshal) { struct marshal *impl; impl = calloc(1, sizeof(struct marshal)); + if (impl == NULL) + return -ENOMEM; + impl->marshal = marshal; impl->type = spa_type_map_get_id (protocol->core->type.map, marshal->type); @@ -125,6 +130,8 @@ pw_protocol_add_marshal(struct pw_protocol *protocol, pw_log_info("Add marshal %s:%d to protocol %s", marshal->type, marshal->version, protocol->name); + + return 0; } const struct pw_protocol_marshal * diff --git a/src/pipewire/protocol.h b/src/pipewire/protocol.h index c5be48d10..77d777e09 100644 --- a/src/pipewire/protocol.h +++ b/src/pipewire/protocol.h @@ -119,8 +119,8 @@ void pw_protocol_add_listener(struct pw_protocol *protocol, * * \brief Manages protocols and their implementation */ -void pw_protocol_add_marshal(struct pw_protocol *protocol, - const struct pw_protocol_marshal *marshal); +int pw_protocol_add_marshal(struct pw_protocol *protocol, + const struct pw_protocol_marshal *marshal); const struct pw_protocol_marshal * pw_protocol_get_marshal(struct pw_protocol *protocol, uint32_t type); diff --git a/src/pipewire/remote.c b/src/pipewire/remote.c index 4e13b11a5..07d1a8bd3 100644 --- a/src/pipewire/remote.c +++ b/src/pipewire/remote.c @@ -117,7 +117,7 @@ const char *pw_remote_state_as_string(enum pw_remote_state state) return "invalid-state"; } -void +int pw_remote_update_state(struct pw_remote *remote, enum pw_remote_state state, const char *fmt, ...) { enum pw_remote_state old = remote->state; @@ -146,6 +146,7 @@ pw_remote_update_state(struct pw_remote *remote, enum pw_remote_state state, con spa_hook_list_call(&remote->listener_list, struct pw_remote_events, state_changed, old, state, remote->error); } + return 0; } static void core_event_info(void *data, struct pw_core_info *info) @@ -403,14 +404,14 @@ int pw_remote_connect_fd(struct pw_remote *remote, int fd) return do_connect(remote); } -void pw_remote_disconnect(struct pw_remote *remote) +int pw_remote_disconnect(struct pw_remote *remote) { struct pw_proxy *proxy, *t2; struct pw_stream *stream, *s2; pw_log_debug("remote %p: disconnect", remote); spa_list_for_each_safe(stream, s2, &remote->stream_list, link) - pw_stream_disconnect(stream); + pw_stream_disconnect(stream); pw_protocol_client_disconnect (remote->conn); @@ -427,6 +428,8 @@ void pw_remote_disconnect(struct pw_remote *remote) remote->info = NULL; } pw_remote_update_state(remote, PW_REMOTE_STATE_UNCONNECTED, NULL); + + return 0; } static int diff --git a/src/pipewire/remote.h b/src/pipewire/remote.h index 999cca420..fbd0070cb 100644 --- a/src/pipewire/remote.h +++ b/src/pipewire/remote.h @@ -188,10 +188,10 @@ const struct pw_core_info *pw_remote_get_core_info(struct pw_remote *remote); struct pw_proxy *pw_remote_find_proxy(struct pw_remote *remote, uint32_t id); /** Disconnect from the remote PipeWire. \memberof pw_remote */ -void pw_remote_disconnect(struct pw_remote *remote); +int pw_remote_disconnect(struct pw_remote *remote); /** Update the state of the remote, mostly used by protocols */ -void pw_remote_update_state(struct pw_remote *remote, enum pw_remote_state state, const char *fmt, ...); +int pw_remote_update_state(struct pw_remote *remote, enum pw_remote_state state, const char *fmt, ...); /** run a local node in a remote graph */ struct pw_proxy *pw_remote_export(struct pw_remote *remote, struct pw_node *node); diff --git a/src/pipewire/stream.c b/src/pipewire/stream.c index 981a27c4a..766fb42ee 100644 --- a/src/pipewire/stream.c +++ b/src/pipewire/stream.c @@ -1081,7 +1081,7 @@ pw_stream_finish_format(struct pw_stream *stream, impl->pending_seq = SPA_ID_INVALID; } -void pw_stream_disconnect(struct pw_stream *stream) +int pw_stream_disconnect(struct pw_stream *stream) { struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this); @@ -1097,12 +1097,14 @@ void pw_stream_disconnect(struct pw_stream *stream) pw_client_node_transport_destroy(impl->trans); impl->trans = NULL; } + return 0; } -void pw_stream_set_active(struct pw_stream *stream, bool active) +int pw_stream_set_active(struct pw_stream *stream, bool active) { struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this); pw_client_node_proxy_set_active(impl->node_proxy, active); + return 0; } int pw_stream_get_time(struct pw_stream *stream, struct pw_time *time) diff --git a/src/pipewire/stream.h b/src/pipewire/stream.h index 293064a24..5d99dab60 100644 --- a/src/pipewire/stream.h +++ b/src/pipewire/stream.h @@ -275,7 +275,7 @@ uint32_t pw_stream_get_node_id(struct pw_stream *stream); /** Disconnect \a stream \memberof pw_stream */ -void pw_stream_disconnect(struct pw_stream *stream); +int pw_stream_disconnect(struct pw_stream *stream); /** Complete the negotiation process with result code \a res \memberof pw_stream * @@ -292,7 +292,7 @@ pw_stream_finish_format(struct pw_stream *stream, /**< a \ref pw_stream */ uint32_t n_params /**< number of elements in \a params */); /** Activate or deactivate the stream \memberof pw_stream */ -void pw_stream_set_active(struct pw_stream *stream, bool active); +int pw_stream_set_active(struct pw_stream *stream, bool active); /** Query the time on the stream \memberof pw_stream */ int pw_stream_get_time(struct pw_stream *stream, struct pw_time *time); diff --git a/src/pipewire/type.c b/src/pipewire/type.c index 93e2dd234..da2083137 100644 --- a/src/pipewire/type.c +++ b/src/pipewire/type.c @@ -35,7 +35,7 @@ * \param type a type structure * \memberof pw_type */ -void pw_type_init(struct pw_type *type) +int pw_type_init(struct pw_type *type) { type->map = pw_get_support_interface(SPA_TYPE__TypeMap); @@ -64,4 +64,5 @@ void pw_type_init(struct pw_type *type) spa_type_param_buffers_map(type->map, &type->param_buffers); spa_type_param_meta_map(type->map, &type->param_meta); spa_type_param_io_map(type->map, &type->param_io); + return 0; } diff --git a/src/pipewire/type.h b/src/pipewire/type.h index a290ee75e..5bf7ad0d8 100644 --- a/src/pipewire/type.h +++ b/src/pipewire/type.h @@ -78,8 +78,7 @@ struct pw_type { struct spa_type_param_io param_io; }; -void -pw_type_init(struct pw_type *type); +int pw_type_init(struct pw_type *type); #ifdef __cplusplus } diff --git a/src/tools/pipewire-cli.c b/src/tools/pipewire-cli.c index fb88d2594..0cbd8e43f 100644 --- a/src/tools/pipewire-cli.c +++ b/src/tools/pipewire-cli.c @@ -56,6 +56,7 @@ struct global { uint32_t version; struct pw_proxy *proxy; bool info_pending; + struct pw_properties *properties; }; struct remote_data { @@ -139,6 +140,23 @@ static struct pw_properties *parse_props(char *str) return props; } +static void print_properties(struct spa_dict *props, char mark, bool header) +{ + const struct spa_dict_item *item; + + if (header) + fprintf(stdout, "%c\tproperties:\n", mark); + if (props == NULL || props->n_items == 0) { + if (header) + fprintf(stdout, "\t\tnone\n"); + return; + } + + spa_dict_for_each(item, props) { + fprintf(stdout, "%c\t\t%s = \"%s\"\n", mark, item->key, item->value); + } +} + static bool do_not_implemented(struct data *data, const char *cmd, char *args, char **error) { asprintf(error, "Command \"%s\" not yet implemented", cmd); @@ -251,10 +269,14 @@ static void print_global(void *obj, void *data) fprintf(stdout, "\tid %d, parent %d, type %s/%d\n", global->id, global->parent_id, spa_type_map_get_type(t->map, global->type), global->version); + if (global->properties) + print_properties(&global->properties->dict, ' ', false); + } static void registry_event_global(void *data, uint32_t id, uint32_t parent_id, - uint32_t permissions, uint32_t type, uint32_t version) + uint32_t permissions, uint32_t type, uint32_t version, + const struct spa_dict *props) { struct remote_data *rd = data; struct global *global; @@ -267,6 +289,7 @@ static void registry_event_global(void *data, uint32_t id, uint32_t parent_id, global->permissions = permissions; global->type = type; global->version = version; + global->properties = props ? pw_properties_new_dict(props) : NULL; fprintf(stdout, "remote %d added global: ", rd->id); print_global(global, NULL); @@ -285,6 +308,8 @@ static void destroy_global(void *obj, void *data) return; pw_map_remove(&global->rd->globals, global->id); + if (global->properties) + pw_properties_free(global->properties); free(global); } @@ -462,21 +487,6 @@ static bool do_switch_remote(struct data *data, const char *cmd, char *args, cha return false; } -static void print_properties(struct spa_dict *props, char mark) -{ - const struct spa_dict_item *item; - - fprintf(stdout, "%c\tproperties:\n", mark); - if (props == NULL || props->n_items == 0) { - fprintf(stdout, "\t\tnone\n"); - return; - } - - spa_dict_for_each(item, props) { - fprintf(stdout, "%c\t\t%s = \"%s\"\n", mark, item->key, item->value); - } -} - #define MARK_CHANGE(f) ((((info)->change_mask & (1 << (f)))) ? '*' : ' ') static void info_global(struct proxy_data *pd) @@ -505,7 +515,7 @@ static void info_core(struct proxy_data *pd) fprintf(stdout, "%c\tversion: \"%s\"\n", MARK_CHANGE(2), info->version); fprintf(stdout, "%c\tname: \"%s\"\n", MARK_CHANGE(3), info->name); fprintf(stdout, "%c\tcookie: %u\n", MARK_CHANGE(4), info->cookie); - print_properties(info->props, MARK_CHANGE(5)); + print_properties(info->props, MARK_CHANGE(5), true); info->change_mask = 0; } @@ -517,7 +527,7 @@ static void info_module(struct proxy_data *pd) fprintf(stdout, "%c\tname: \"%s\"\n", MARK_CHANGE(0), info->name); fprintf(stdout, "%c\tfilename: \"%s\"\n", MARK_CHANGE(1), info->filename); fprintf(stdout, "%c\targs: \"%s\"\n", MARK_CHANGE(2), info->args); - print_properties(info->props, MARK_CHANGE(3)); + print_properties(info->props, MARK_CHANGE(3), true); info->change_mask = 0; } @@ -551,7 +561,7 @@ static void info_node(struct proxy_data *pd) fprintf(stdout, " \"%s\"\n", info->error); else fprintf(stdout, "\n"); - print_properties(info->props, MARK_CHANGE(6)); + print_properties(info->props, MARK_CHANGE(6), true); info->change_mask = 0; } @@ -563,7 +573,7 @@ static void info_factory(struct proxy_data *pd) info_global(pd); fprintf(stdout, "\tname: \"%s\"\n", info->name); fprintf(stdout, "\tobject-type: %s/%d\n", spa_type_map_get_type(t->map, info->type), info->version); - print_properties(info->props, MARK_CHANGE(0)); + print_properties(info->props, MARK_CHANGE(0), true); info->change_mask = 0; } @@ -572,7 +582,7 @@ static void info_client(struct proxy_data *pd) struct pw_client_info *info = pd->info; info_global(pd); - print_properties(info->props, MARK_CHANGE(0)); + print_properties(info->props, MARK_CHANGE(0), true); info->change_mask = 0; } @@ -590,7 +600,7 @@ static void info_link(struct proxy_data *pd) spa_debug_pod(info->format, SPA_DEBUG_FLAG_FORMAT); else fprintf(stdout, "\t\tnone\n"); - print_properties(info->props, MARK_CHANGE(3)); + print_properties(info->props, MARK_CHANGE(3), true); info->change_mask = 0; } diff --git a/src/tools/pipewire-monitor.c b/src/tools/pipewire-monitor.c index d7dde7685..b0a3addb5 100644 --- a/src/tools/pipewire-monitor.c +++ b/src/tools/pipewire-monitor.c @@ -53,7 +53,7 @@ struct proxy_data { struct spa_hook proxy_proxy_listener; }; -static void print_properties(struct spa_dict *props, char mark) +static void print_properties(const struct spa_dict *props, char mark) { const struct spa_dict_item *item; @@ -314,7 +314,8 @@ static const struct pw_proxy_events proxy_events = { }; static void registry_event_global(void *data, uint32_t id, uint32_t parent_id, - uint32_t permissions, uint32_t type, uint32_t version) + uint32_t permissions, uint32_t type, uint32_t version, + const struct spa_dict *props) { struct data *d = data; struct pw_proxy *proxy; @@ -358,6 +359,7 @@ static void registry_event_global(void *data, uint32_t id, uint32_t parent_id, permissions & PW_PERM_W ? 'w' : '-', permissions & PW_PERM_X ? 'x' : '-'); printf("\ttype: %s (version %d)\n", spa_type_map_get_type(t->map, type), version); + print_properties(props, ' '); return; }