diff --git a/src/config/wireplumber.conf.d/alsa.conf b/src/config/wireplumber.conf.d/alsa.conf index 0143c6ed..39548a42 100644 --- a/src/config/wireplumber.conf.d/alsa.conf +++ b/src/config/wireplumber.conf.d/alsa.conf @@ -2,11 +2,11 @@ wireplumber.components = [ # The "reserve-device" module needs to be loaded for reservation to work - { name = libwireplumber-module-reserve-device , type = module, deps = alsa_monitor.alsa.reserve } + { name = libwireplumber-module-reserve-device , type = module, deps = monitor.alsa.reserve } { name = monitors/alsa.lua, type = script/lua } - { name = monitors/alsa-midi.lua, type = script/lua, deps = alsa_monitor.alsa.midi } - { name = libwireplumber-module-file-monitor-api, type = module, deps = alsa_monitor.alsa.midi.monitoring } + { name = monitors/alsa-midi.lua, type = script/lua, deps = monitor.alsa.midi } + { name = libwireplumber-module-file-monitor-api, type = module, deps = monitor.alsa.midi.monitoring } ] wireplumber.settings = { @@ -14,22 +14,22 @@ wireplumber.settings = { # it requires that the PipeWire JACK replacement libraries are # not used by the session manager, in order to be able to # connect to the real JACK server. - # alsa_monitor.alsa.jack-device = false + # monitor.alsa.jack-device = false # Reserve devices via org.freedesktop.ReserveDevice1 on D-Bus - alsa_monitor.alsa.reserve = true - # alsa_monitor.alsa.reserve.priority = -20 - # alsa_monitor.alsa.reserve.application-name = WirePlumber + monitor.alsa.reserve = true + # monitor.alsa.reserve.priority = -20 + # monitor.alsa.reserve.application-name = WirePlumber # Enables MIDI functionality - alsa_monitor.alsa.midi = true + monitor.alsa.midi = true # Enables monitoring of alsa MIDI devices - alsa_monitor.alsa.midi.monitoring = true + monitor.alsa.midi.monitoring = true # These properties override node defaults when running in a virtual machine. # The rules below still override those. - alsa_monitor.vm.node.defaults = { + monitor.vm.node.defaults = { api.alsa.period-size = 256 api.alsa.headroom = 8192 } @@ -43,7 +43,7 @@ wireplumber.settings = { # api.alsa.disable-longname = true }, - alsa_monitor = [ + monitor.alsa = [ { # An array of matches/actions to evaluate. diff --git a/src/config/wireplumber.conf.d/bluetooth.conf b/src/config/wireplumber.conf.d/bluetooth.conf index d1cc5696..d977229f 100644 --- a/src/config/wireplumber.conf.d/bluetooth.conf +++ b/src/config/wireplumber.conf.d/bluetooth.conf @@ -4,7 +4,7 @@ wireplumber.components = [ # If ifexists is given, the module is ignored when it is not found. # If nofail is given, module initialization failures are ignored. - { name = libwireplumber-module-logind , type = module, deps = bluez-enable-logind, flags = [ ifexists ] } + { name = libwireplumber-module-logind , type = module, deps = monitor.bluetooth.enable-logind, flags = [ ifexists ] } ] wireplumber.settings = { @@ -81,9 +81,9 @@ wireplumber.settings = { # pipewire and wireplumber). # This requires access to the D-Bus user session; disable if you are running # a system-wide instance of wireplumber. - bluez-enable-logind = true + monitor.bluetooth.enable-logind = true - bluez_monitor = [ + monitor.bluetooth = [ { # Rules for matching a device or node. It is an array of # properties that all need to match the regexp. If any of the diff --git a/src/config/wireplumber.conf.d/libcamera.conf b/src/config/wireplumber.conf.d/libcamera.conf index 6fc0ec2a..bac3e522 100644 --- a/src/config/wireplumber.conf.d/libcamera.conf +++ b/src/config/wireplumber.conf.d/libcamera.conf @@ -1,12 +1,12 @@ # libcamera device settings wireplumber.components = [ - { name = monitors/libcamera.lua, type = script/lua, deps = libcamera_monitor.enable } + { name = monitors/libcamera.lua, type = script/lua, deps = monitor.libcamera.enable } ] wireplumber.settings = { - libcamera_monitor.enable = true - libcamera_monitor = [ + monitor.libcamera.enable = true + monitor.libcamera = [ { # Rules for matching a device or node. It is an array of # properties that all need to match the regexp. If any of the diff --git a/src/config/wireplumber.conf.d/policy.conf b/src/config/wireplumber.conf.d/policy.conf index b4edbda4..4c040c0f 100644 --- a/src/config/wireplumber.conf.d/policy.conf +++ b/src/config/wireplumber.conf.d/policy.conf @@ -60,18 +60,18 @@ wireplumber.settings = { policy.default.duck-level = 0.3 # Whether to store state on the filesystem. - bt-policy-use-persistent-storage = true + policy.bluetooth.use-persistent-storage = true # Whether to use headset profile in the presence of an input stream. - bt-policy-media-role.use-headset-profile = true + policy.bluetooth.media-role.use-headset-profile = true # Application names correspond to application.name in stream properties. # Applications which do not set media.role but which should be considered # for role based profile switching can be specified here. - - bt-policy-media-role.applications = [ + policy.bluetooth.media-role.applications = [ "Firefox", "Chromium input", "Google Chrome input", "Brave input", "Microsoft Edge input", "Vivaldi input", "ZOOM VoiceEngine", "Telegram Desktop", "telegram-desktop", "linphone", "Mumble", - "WEBRTC VoiceEngine", "Skype"] + "WEBRTC VoiceEngine", "Skype" + ] } diff --git a/src/config/wireplumber.conf.d/v4l2.conf b/src/config/wireplumber.conf.d/v4l2.conf index 76212b78..dd3fb6fa 100644 --- a/src/config/wireplumber.conf.d/v4l2.conf +++ b/src/config/wireplumber.conf.d/v4l2.conf @@ -5,7 +5,7 @@ wireplumber.components = [ ] wireplumber.settings = { - v4l2_monitor = [ + monitor.v4l2 = [ { # Rules for matching a device or node. It is an array of # properties that all need to match the regexp. If any of the diff --git a/src/scripts/monitors/alsa.lua b/src/scripts/monitors/alsa.lua index cf7089fb..4c51cd7d 100644 --- a/src/scripts/monitors/alsa.lua +++ b/src/scripts/monitors/alsa.lua @@ -5,23 +5,14 @@ -- -- SPDX-License-Identifier: MIT -local config_settings = Settings.get_all ("alsa_monitor.*"):parse () +local cutils = require ("common-utils") + +local config_settings = Settings.get_all ("monitor.alsa*"):parse () -- unique device/node name tables device_names_table = nil node_names_table = nil -function rulesApplyProperties(properties) - local matched, mprops = Settings.apply_rule ("alsa_monitor", properties) - - if (matched and mprops) then - for k, v in pairs(mprops) do - properties[k] = v - end - end - -end - function nonempty(str) return str ~= "" and str or nil end @@ -152,7 +143,7 @@ function createNode(parent, id, obj_type, factory, properties) end -- apply properties from rules defined in JSON .conf file - rulesApplyProperties(properties) + cutils.evaluateRulesApplyProperties (properties, "monitor.alsa") if properties["node.disabled"] then node_names_table [properties ["node.name"]] = nil return @@ -254,8 +245,8 @@ function prepareDevice(parent, id, obj_type, factory, properties) end -- apply properties from rules defined in JSON .conf file - rulesApplyProperties(properties) - if properties["device.disabled"] then + cutils.evaluateRulesApplyProperties (properties, "monitor.alsa") + if properties ["device.disabled"] then device_names_table [properties ["device.name"]] = nil return end diff --git a/src/scripts/monitors/bluez.lua b/src/scripts/monitors/bluez.lua index 907500a6..1dce4341 100644 --- a/src/scripts/monitors/bluez.lua +++ b/src/scripts/monitors/bluez.lua @@ -7,7 +7,9 @@ local COMBINE_OFFSET = 64 -local config_settings = Settings.get_all ("bluez5.*"):parse () +local cutils = require ("common-utils") + +local config_settings = Settings.get_all ("monitor.bluetooth.*"):parse () devices_om = ObjectManager { Interest { @@ -23,18 +25,6 @@ nodes_om = ObjectManager { } } --- applies rules from bluez-settings.conf when asked to -function rulesApplyProperties(properties) - local matched, mprops = Settings.apply_rule ("bluez_monitor", properties) - - if (matched and mprops) then - for k, v in pairs(mprops) do - properties[k] = v - end - end - -end - function setOffloadActive(device, value) local pod = Pod.Object { "Spa:Pod:Object:Param:Props", "Props", bluetoothOffloadActive = value @@ -281,7 +271,7 @@ function createNode(parent, id, type, factory, properties) end -- apply properties from bluetooth.conf - rulesApplyProperties(properties) + cutils.evaluateRulesApplyProperties (properties, "monitor.bluetooth") -- create the node; bluez requires "local" nodes, i.e. ones that run in -- the same process as the spa device, for several reasons @@ -343,7 +333,7 @@ function createDevice(parent, id, type, factory, properties) properties["api.bluez5.id"] = id -- apply properties from bluetooth.conf - rulesApplyProperties(properties) + cutils.evaluateRulesApplyProperties (properties, "monitor.bluetooth") -- create the device device = SpaDevice(factory, properties) diff --git a/src/scripts/monitors/libcamera.lua b/src/scripts/monitors/libcamera.lua index 061eab62..1a7cdbf6 100644 --- a/src/scripts/monitors/libcamera.lua +++ b/src/scripts/monitors/libcamera.lua @@ -5,19 +5,10 @@ -- -- SPDX-License-Identifier: MIT +local cutils = require ("common-utils") + local config_settings = {} --- apply properties from rules defined in JSON .conf file -function rulesApplyProperties(properties) - local matched, mprops = Settings.apply_rule ("libcamera_monitor", properties) - - if (matched and mprops) then - for k, v in pairs(mprops) do - properties[k] = v - end - end -end - function findDuplicate(parent, id, property, value) for i = 0, id - 1, 1 do local obj = parent:get_managed_object(i) @@ -94,7 +85,7 @@ function createNode(parent, id, type, factory, properties) end -- apply properties from rules defined in JSON .conf file - rulesApplyProperties(properties) + cutils.evaluateRulesApplyProperties (properties, "monitor.libcamera") if properties ["node.disabled"] then return end @@ -131,10 +122,11 @@ function createDevice(parent, id, type, factory, properties) or "Unknown device" -- apply properties from rules defined in JSON .conf file - rulesApplyProperties(properties) + cutils.evaluateRulesApplyProperties (properties, "monitor.libcamera") if properties ["device.disabled"] then return end + -- create the device local device = SpaDevice(factory, properties) if device then diff --git a/src/scripts/monitors/v4l2.lua b/src/scripts/monitors/v4l2.lua index 07ce0ba2..195f2b14 100644 --- a/src/scripts/monitors/v4l2.lua +++ b/src/scripts/monitors/v4l2.lua @@ -5,19 +5,10 @@ -- -- SPDX-License-Identifier: MIT +local cutils = require ("common-utils") + local config_settings = {} --- apply properties from rules defined in JSON .conf file -function rulesApplyProperties(properties) - local matched, mprops = Settings.apply_rule ("v4l2_monitor", properties) - - if (matched and mprops) then - for k, v in pairs(mprops) do - properties[k] = v - end - end -end - function findDuplicate(parent, id, property, value) for i = 0, id - 1, 1 do local obj = parent:get_managed_object(i) @@ -84,7 +75,7 @@ function createNode(parent, id, type, factory, properties) end -- apply properties from rules defined in JSON .conf file - rulesApplyProperties(properties) + cutils.evaluateRulesApplyProperties (properties, "monitor.v4l2") if properties["node.disabled"] then return end @@ -121,7 +112,7 @@ function createDevice(parent, id, type, factory, properties) or "Unknown device" -- apply properties from rules defined in JSON .conf file - rulesApplyProperties(properties) + cutils.evaluateRulesApplyProperties (properties, "monitor.v4l2") if properties["device.disabled"] then return end