mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-05-09 02:48:05 +02:00
scripts: tidy up monitor settings and config options
* add a new common-utils method to get configuration sections with defaults more efficiently and with less boilerplate * rework the ALSA reserve-device settings so that the priority is configured per device using rules and the application name comes from the WpCore instead of the config file * rename bluetooth to bluez in all options for consistency with other monitors that use the backend API name * rename alsa.midi to alsa-midi for consistency with bluez-midi
This commit is contained in:
parent
4feebfc3a3
commit
ca3bc3eb6d
10 changed files with 56 additions and 58 deletions
|
|
@ -249,7 +249,7 @@ wireplumber.components = [
|
|||
requires = [ api.file-monitor ]
|
||||
}
|
||||
{
|
||||
type = virtual, provides = monitor.bluetooth.seat-monitoring,
|
||||
type = virtual, provides = monitor.bluez.seat-monitoring,
|
||||
requires = [ support.logind ]
|
||||
}
|
||||
|
||||
|
|
@ -267,7 +267,7 @@ wireplumber.components = [
|
|||
pw.client-device,
|
||||
pw.client-node,
|
||||
pw.node-factory.adapter ]
|
||||
wants = [ monitor.bluetooth.seat-monitoring ]
|
||||
wants = [ monitor.bluez.seat-monitoring ]
|
||||
}
|
||||
{
|
||||
name = monitors/bluez-midi.lua, type = script/lua
|
||||
|
|
@ -276,7 +276,7 @@ wireplumber.components = [
|
|||
pw.client-device,
|
||||
pw.client-node,
|
||||
pw.node-factory.spa ]
|
||||
wants = [ monitor.bluetooth.seat-monitoring ]
|
||||
wants = [ monitor.bluez.seat-monitoring ]
|
||||
}
|
||||
{
|
||||
name = monitors/alsa-midi.lua, type = script/lua
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ monitor.alsa.properties = {
|
|||
## The properties used when constructing the 'api.alsa.enum.udev' plugin
|
||||
}
|
||||
|
||||
monitor.alsa.midi.node-properties = {
|
||||
monitor.alsa-midi.properties = {
|
||||
## MIDI bridge node properties
|
||||
|
||||
## Name set for the node with ALSA MIDI ports
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ wireplumber.settings = {
|
|||
# ]
|
||||
}
|
||||
|
||||
monitor.bluetooth.properties = {
|
||||
monitor.bluez.properties = {
|
||||
## The properties used when constructing the 'api.bluez5.enum.dbus' plugin
|
||||
|
||||
## Enabled roles (default: [ a2dp_sink a2dp_source bap_sink bap_source hfp_hf hfp_ag ])
|
||||
|
|
@ -79,11 +79,11 @@ monitor.bluetooth.properties = {
|
|||
# bluez5.a2dp.opus.pro.bidi.frame-dms = 400
|
||||
}
|
||||
|
||||
monitor.bluetooth-midi.properties = {
|
||||
monitor.bluez-midi.properties = {
|
||||
## The properties used when constructing the 'api.bluez5.midi.enum' plugin
|
||||
}
|
||||
|
||||
monitor.bluetooth-midi.servers = [
|
||||
monitor.bluez-midi.servers = [
|
||||
## List of MIDI server node names. Each node name given will create a new instance
|
||||
## of a BLE MIDI service. Typical BLE MIDI instruments have on service instance,
|
||||
## so adding more than one here may confuse some clients. The node property matching
|
||||
|
|
@ -92,7 +92,7 @@ monitor.bluetooth-midi.servers = [
|
|||
# "bluez_midi.server"
|
||||
]
|
||||
|
||||
monitor.bluetooth.rules = [
|
||||
monitor.bluez.rules = [
|
||||
## The list of monitor rules
|
||||
|
||||
## The following are the default rules applied if none overrides them.
|
||||
|
|
@ -182,7 +182,7 @@ monitor.bluetooth.rules = [
|
|||
# }
|
||||
]
|
||||
|
||||
monitor.bluetooth-midi.rules = [
|
||||
monitor.bluez-midi.rules = [
|
||||
## The list of monitor MIDI rules
|
||||
|
||||
## This rule example allows changing properties on all Bluetooth MIDI nodes.
|
||||
|
|
|
|||
|
|
@ -158,5 +158,28 @@ function cutils.storeAfterTimeout (state, state_table)
|
|||
end)
|
||||
end
|
||||
|
||||
function cutils.get_application_name ()
|
||||
return Core.get_properties()["application.name"] or "WirePlumber"
|
||||
end
|
||||
|
||||
function cutils.get_config_section (name, defaults)
|
||||
local section = Conf.get_section (name)
|
||||
if not section then
|
||||
section = defaults or {}
|
||||
else
|
||||
section = section:parse ()
|
||||
for k, v in pairs (defaults) do
|
||||
if section [k] == nil then
|
||||
section [k] = v
|
||||
end
|
||||
end
|
||||
for k, v in ipairs (defaults) do
|
||||
if section [k] == nil then
|
||||
section [k] = v
|
||||
end
|
||||
end
|
||||
end
|
||||
return section
|
||||
end
|
||||
|
||||
return cutils
|
||||
|
|
|
|||
|
|
@ -5,15 +5,12 @@
|
|||
--
|
||||
-- SPDX-License-Identifier: MIT
|
||||
|
||||
cutils = require ("common-utils")
|
||||
log = Log.open_topic ("s-monitors")
|
||||
|
||||
defaults = {}
|
||||
defaults.node_properties = Json.Object {}
|
||||
|
||||
config = {}
|
||||
config.monitoring = Core.test_feature ("monitor.alsa-midi.monitoring")
|
||||
config.node_properties = Conf.get_section (
|
||||
"monitor.alsa.midi.node-properties", defaults.node_properties):parse ()
|
||||
config.node_properties = cutils.get_config_section ("monitor.alsa-midi.properties")
|
||||
|
||||
SND_PATH = "/dev/snd"
|
||||
SEQ_NAME = "seq"
|
||||
|
|
|
|||
|
|
@ -8,19 +8,9 @@
|
|||
cutils = require ("common-utils")
|
||||
log = Log.open_topic ("s-monitors")
|
||||
|
||||
defaults = {}
|
||||
defaults.reserve_priority = -20
|
||||
defaults.reserve_application_name = "WirePlumber"
|
||||
defaults.properties = Json.Object {}
|
||||
|
||||
config = {}
|
||||
config.reserve_device = Core.test_feature ("monitor.alsa.reserve-device")
|
||||
config.reserve_priority = Conf.get_value_int ("wireplumber.settings",
|
||||
"monitor.alsa.reserve-priority", defaults.reserve_priority)
|
||||
config.reserve_application_name = Conf.get_value_string ("wireplumber.settings",
|
||||
"monitor.alsa.reserve-application-name", defaults.reserve_application_name)
|
||||
config.properties = Conf.get_section (
|
||||
"monitor.alsa.properties", defaults.properties):parse ()
|
||||
config.properties = cutils.get_config_section ("monitor.alsa.properties")
|
||||
|
||||
-- unique device/node name tables
|
||||
device_names_table = nil
|
||||
|
|
@ -33,6 +23,7 @@ end
|
|||
function applyDefaultDeviceProperties (properties)
|
||||
properties["api.alsa.use-acp"] = true
|
||||
properties["api.acp.auto-port"] = false
|
||||
properties["api.dbus.ReserveDevice1.Priority"] = -20
|
||||
end
|
||||
|
||||
function createNode(parent, id, obj_type, factory, properties)
|
||||
|
|
@ -280,9 +271,9 @@ function prepareDevice(parent, id, obj_type, factory, properties)
|
|||
local rd_name = "Audio" .. properties["api.alsa.card"]
|
||||
local rd = rd_plugin:call("create-reservation",
|
||||
rd_name,
|
||||
config.reserve_application_name,
|
||||
cutils.get_application_name (),
|
||||
properties["device.name"],
|
||||
config.reserve_priority);
|
||||
properties["api.dbus.ReserveDevice1.Priority"]);
|
||||
|
||||
properties["api.dbus.ReserveDevice1"] = rd_name
|
||||
|
||||
|
|
|
|||
|
|
@ -9,15 +9,12 @@ cutils = require ("common-utils")
|
|||
log = Log.open_topic ("s-monitors")
|
||||
|
||||
defaults = {}
|
||||
defaults.properties = Json.Object {}
|
||||
defaults.servers = Json.Array { "bluez_midi.server" }
|
||||
defaults.servers = { "bluez_midi.server" }
|
||||
|
||||
config = {}
|
||||
config.seat_monitoring = Core.test_feature ("monitor.bluetooth.seat-monitoring")
|
||||
config.properties = Conf.get_section (
|
||||
"monitor.bluetooth-midi.properties", defaults.properties): parse ()
|
||||
config.servers = Conf.get_section (
|
||||
"monitor.bluetooth-midi.servers", defaults.servers): parse ()
|
||||
config.seat_monitoring = Core.test_feature ("monitor.bluez.seat-monitoring")
|
||||
config.properties = cutils.get_config_section ("monitor.bluez-midi.properties")
|
||||
config.servers = cutils.get_config_section ("monitor.bluez-midi.servers", defaults.servers)
|
||||
|
||||
-- unique device/node name tables
|
||||
node_names_table = nil
|
||||
|
|
@ -62,7 +59,7 @@ function createNode(parent, id, type, factory, properties)
|
|||
properties["api.glib.mainloop"] = "true"
|
||||
|
||||
-- apply properties from bluetooth.conf
|
||||
cutils.evaluateRulesApplyProperties (properties, "monitor.bluetooth-midi.rules")
|
||||
cutils.evaluateRulesApplyProperties (properties, "monitor.bluez-midi.rules")
|
||||
|
||||
local latency_offset = properties["node.latency-offset-msec"]
|
||||
properties["node.latency-offset-msec"] = nil
|
||||
|
|
@ -118,7 +115,7 @@ function createServers()
|
|||
["factory.name"] = "api.bluez5.midi.node",
|
||||
["api.glib.mainloop"] = "true",
|
||||
}
|
||||
cutils.evaluateRulesApplyProperties (node_props, "monitor.bluetooth-midi.rules")
|
||||
cutils.evaluateRulesApplyProperties (node_props, "monitor.bluez-midi.rules")
|
||||
|
||||
local latency_offset = node_props["node.latency-offset-msec"]
|
||||
node_props["node.latency-offset-msec"] = nil
|
||||
|
|
|
|||
|
|
@ -10,13 +10,12 @@ COMBINE_OFFSET = 64
|
|||
cutils = require ("common-utils")
|
||||
log = Log.open_topic ("s-monitors")
|
||||
|
||||
defaults = {}
|
||||
defaults.properties = Json.Object {}
|
||||
|
||||
config = {}
|
||||
config.seat_monitoring = Core.test_feature ("monitor.bluetooth.seat-monitoring")
|
||||
config.properties = Conf.get_section (
|
||||
"monitor.bluetooth.properties", defaults.properties): parse ()
|
||||
config.seat_monitoring = Core.test_feature ("monitor.bluez.seat-monitoring")
|
||||
config.properties = cutils.get_config_section ("monitor.bluez.properties")
|
||||
|
||||
-- This is not a setting, it must always be enabled
|
||||
config.properties["api.bluez5.connection-info"] = true
|
||||
|
||||
devices_om = ObjectManager {
|
||||
Interest {
|
||||
|
|
@ -278,7 +277,7 @@ function createNode(parent, id, type, factory, properties)
|
|||
end
|
||||
|
||||
-- apply properties from bluetooth.conf
|
||||
cutils.evaluateRulesApplyProperties (properties, "monitor.bluetooth.rules")
|
||||
cutils.evaluateRulesApplyProperties (properties, "monitor.bluez.rules")
|
||||
|
||||
-- create the node; bluez requires "local" nodes, i.e. ones that run in
|
||||
-- the same process as the spa device, for several reasons
|
||||
|
|
@ -340,7 +339,7 @@ function createDevice(parent, id, type, factory, properties)
|
|||
properties["api.bluez5.id"] = id
|
||||
|
||||
-- apply properties from bluetooth.conf
|
||||
cutils.evaluateRulesApplyProperties (properties, "monitor.bluetooth.rules")
|
||||
cutils.evaluateRulesApplyProperties (properties, "monitor.bluez.rules")
|
||||
|
||||
-- create the device
|
||||
device = SpaDevice(factory, properties)
|
||||
|
|
@ -367,9 +366,7 @@ function createDevice(parent, id, type, factory, properties)
|
|||
end
|
||||
|
||||
function createMonitor()
|
||||
local properties = config.properties
|
||||
properties["api.bluez5.connection-info"] = true
|
||||
local monitor = SpaDevice("api.bluez5.enum.dbus", properties)
|
||||
local monitor = SpaDevice("api.bluez5.enum.dbus", config.properties)
|
||||
if monitor then
|
||||
monitor:connect("create-object", createDevice)
|
||||
else
|
||||
|
|
|
|||
|
|
@ -5,14 +5,11 @@
|
|||
--
|
||||
-- SPDX-License-Identifier: MIT
|
||||
|
||||
cutils = require ("common-utils")
|
||||
log = Log.open_topic ("s-monitors-libcamera")
|
||||
|
||||
defaults = {}
|
||||
defaults.properties = Json.Object {}
|
||||
|
||||
config = {}
|
||||
config.properties = Conf.get_section (
|
||||
"monitor.libcamera.properties", defaults.properties):parse ()
|
||||
config.properties = cutils.get_config_section ("monitor.libcamera.properties")
|
||||
|
||||
function createCamDevice (parent, id, type, factory, properties)
|
||||
source = source or Plugin.find ("standard-event-source")
|
||||
|
|
|
|||
|
|
@ -5,15 +5,11 @@
|
|||
--
|
||||
-- SPDX-License-Identifier: MIT
|
||||
|
||||
cutils = require ("common-utils")
|
||||
log = Log.open_topic ("s-monitors-v4l2")
|
||||
|
||||
defaults = {}
|
||||
defaults.properties = Json.Object {}
|
||||
|
||||
config = {}
|
||||
config.properties = Conf.get_section (
|
||||
"monitor.v4l2.properties", defaults.properties):parse ()
|
||||
|
||||
config.properties = cutils.get_config_section ("monitor.v4l2.properties")
|
||||
|
||||
function createCamDevice (parent, id, type, factory, properties)
|
||||
source = source or Plugin.find ("standard-event-source")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue