From 93e6e98a17c9aff8d5fb500e0095afe0c0c5686c Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 28 Mar 2023 13:32:08 +0200 Subject: [PATCH] module-link-factory: ignore link.passive by default Make an option to allow link.passive properties and set it to false by default. This effectively ignores the link.passive properties from the session manager, jack clients and pw-link when set. This is a good idea because the logic for making passive links is better handled in the core. --- src/daemon/minimal.conf.in | 2 -- src/modules/module-link-factory.c | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/daemon/minimal.conf.in b/src/daemon/minimal.conf.in index 6d7122b65..72f44fa1b 100644 --- a/src/daemon/minimal.conf.in +++ b/src/daemon/minimal.conf.in @@ -326,7 +326,6 @@ context.objects = [ # link.output.port = capture_1 # link.input.node = my-mic # link.input.port = input_FL - # link.passive = true # } #} #{ factory = link-factory @@ -335,7 +334,6 @@ context.objects = [ # link.output.port = capture_2 # link.input.node = my-mic # link.input.port = input_FR - # link.passive = true # } #} ] diff --git a/src/modules/module-link-factory.c b/src/modules/module-link-factory.c index 125082fb2..eaddf654f 100644 --- a/src/modules/module-link-factory.c +++ b/src/modules/module-link-factory.c @@ -29,15 +29,22 @@ PW_LOG_TOPIC_STATIC(mod_topic, "mod." NAME); "("PW_KEY_OBJECT_LINGER"=) " \ "("PW_KEY_LINK_PASSIVE"=)" +#define MODULE_USAGE "( allow.link.passive= ) " + static const struct spa_dict_item module_props[] = { { PW_KEY_MODULE_AUTHOR, "Wim Taymans " }, { PW_KEY_MODULE_DESCRIPTION, "Allow clients to create links" }, + { PW_KEY_MODULE_USAGE, MODULE_USAGE }, { PW_KEY_MODULE_VERSION, PACKAGE_VERSION }, }; struct factory_data { struct pw_context *context; + struct pw_properties *props; + + unsigned int allow_passive:1; + struct pw_impl_module *module; struct spa_hook module_listener; @@ -396,6 +403,8 @@ static void *create_object(void *_data, pw_properties_setf(properties, PW_KEY_CLIENT_ID, "%d", pw_impl_client_get_info(client)->id); + if (!d->allow_passive) + pw_properties_set(properties, PW_KEY_LINK_PASSIVE, NULL); link = pw_context_create_link(context, outport, inport, NULL, properties, sizeof(struct link_data)); properties = NULL; @@ -462,6 +471,7 @@ static void factory_destroy(void *data) d->factory = NULL; if (d->module) pw_impl_module_destroy(d->module); + pw_properties_free(d->props); } static const struct pw_impl_factory_events factory_events = { @@ -527,6 +537,12 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args) data->module = module; data->context = context; data->work = pw_context_get_work_queue(context); + data->props = args ? pw_properties_new_string(args) : NULL; + + if (data->props) { + data->allow_passive = pw_properties_get_bool(data->props, + "allow.link.passive", false); + } spa_list_init(&data->link_list);