From 43ea3db02c5ef39473dfc604aadbe0c5411d0bf2 Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Tue, 3 Sep 2024 11:32:54 +0300 Subject: [PATCH] wireplumber.conf: add systemwide, embedded and split-instance profiles Revamp the profiles section, making use of the inherits feature and add commonly used profiles for systemwide & embedded use cases, as well as profiles for a split-instance configuration where the policy hooks run in a separate instance from the alsa, bluetooth and camera monitors (which run in 3 separate instances respectively) Also add an example on how to configure the loaded profile using a config file instead of the CLI switch. Fixes: #608 --- lib/wp/private/internal-comp-loader.c | 2 + src/config/wireplumber.conf | 90 ++++++++++++++++--- .../wireplumber.conf.d.examples/profile.conf | 9 ++ 3 files changed, 90 insertions(+), 11 deletions(-) create mode 100644 src/config/wireplumber.conf.d.examples/profile.conf diff --git a/lib/wp/private/internal-comp-loader.c b/lib/wp/private/internal-comp-loader.c index 41584f6e..45877eb7 100644 --- a/lib/wp/private/internal-comp-loader.c +++ b/lib/wp/private/internal-comp-loader.c @@ -942,6 +942,8 @@ wp_internal_comp_loader_load (WpComponentLoader * self, WpCore * core, g_autoptr (GError) error = NULL; const gchar *profile_name = component; + wp_notice ("Loading profile '%s'", profile_name); + all_profiles_j = wp_conf_get_section (conf, "wireplumber.profiles"); if (!parse_profile_description (profile, all_profiles_j, profile_name, diff --git a/src/config/wireplumber.conf b/src/config/wireplumber.conf index 1685f9b9..65aa0824 100644 --- a/src/config/wireplumber.conf +++ b/src/config/wireplumber.conf @@ -57,6 +57,7 @@ context.modules = [ wireplumber.profiles = { ## Syntax: ## = { + ## inherits = [ other, profile, names ] # optional ## # optional is the default ## = [ required | optional | disabled ] ## ... @@ -64,29 +65,94 @@ wireplumber.profiles = { # The default profile main = { - check.no-media-session = required + inherits = [ base ] + metadata.sm-settings = required - support.settings = required - support.log-settings = required metadata.sm-objects = required + + policy.standard = required + hardware.audio = required hardware.bluetooth = required hardware.video-capture = required - policy.standard = required + } + + # Profile for running on a systemwide level + main-systemwide = { + inherits = [ main, mixin.systemwide-session ] + } + + # Typical profile for embedded use cases, systemwide without maintaining state + main-embedded = { + inherits = [ main, mixin.systemwide-session, mixin.stateless ] } # Profile for video-only use cases (camera & screen sharing) video-only = { - check.no-media-session = required - metadata.sm-settings = required - support.settings = required - support.log-settings = required - metadata.sm-objects = required + inherits = [ main ] hardware.audio = disabled hardware.bluetooth = disabled - hardware.video-capture = required + } + + ## + ## Profiles for multi-instance setup + ## + + policy = { + inherits = [ base ] + metadata.sm-settings = required + metadata.sm-objects = required policy.standard = required } + + audio = { + inherits = [ base ] + hardware.audio = required + } + + bluetooth = { + inherits = [ base ] + hardware.bluetooth = required + } + + video-capture = { + inherits = [ base ] + hardware.video-capture = required + } + + ## + ## The following are not complete profiles, but blocks that can be inherited + ## + + # The bare minimum that all instances should have by default + base = { + check.no-media-session = required + support.settings = required + support.log-settings = required + } + + # Disable features that are meant only for user sessions + mixin.systemwide-session = { + support.reserve-device = disabled + monitor.alsa.reserve-device = disabled + + support.portal-permissionstore = disabled + script.client.access-portal = disabled + + support.logind = disabled + monitor.bluez.seat-monitoring = disabled + } + + # Disable storing/restoring runtime state information regarding + # default nodes selection, profiles, routes and stream volume / properties + # This makes sense for embedded systems that should always reboot to a default + # state, not remembering any of the user's runtime changes + mixin.stateless = { + hooks.device.profile.state = disabled + hooks.device.routes.state = disabled + hooks.default-nodes.state = disabled + hooks.stream.state = disabled + } } wireplumber.components = [ @@ -167,7 +233,9 @@ wireplumber.components = [ } ## Activates a global WpSettings instance, providing settings from - ## the sm-settings metadata object + ## the sm-settings metadata object. Note that this blocks and waits for the + ## sm-settings metadata object to become available, so one instance must + ## provide that, while others should only load this to access settings { name = settings-instance, type = built-in arguments = { metadata.name = sm-settings } diff --git a/src/config/wireplumber.conf.d.examples/profile.conf b/src/config/wireplumber.conf.d.examples/profile.conf new file mode 100644 index 00000000..41fb9399 --- /dev/null +++ b/src/config/wireplumber.conf.d.examples/profile.conf @@ -0,0 +1,9 @@ +# This example configuration fragment shows how to permanently instruct +# WirePlumber to load with a specific profile. Note that this overrides the +# `-p, --profile` command line switch, rendering it useless. If you intend to +# run WirePlumber with multiple profiles based on its command line arguments, +# do not use this + +context.properties = { + wireplumber.profile = main-embedded +}