monitors/alsa: remove vm.node.defaults and use match rules instead

The vm.node.defaults logic which was inherited from p-m-s is not really
good because it seems like different VM hardware requires different
values for the defaults. Also, passthrough USB hardware should not
inerhit these values, they just cause trouble.

Instead, we can use rules to match the vm.type and specific device
properties to set a more informed period & headroom.

For now, I am also decreasing the default headroom down to 2048, which
works for me and perhaps it's a good default. We can always add more
rules here and fine-tune per vm type and virtual hardware.

See !394, #316, #348, #507, #162, pipewire#3452
This commit is contained in:
George Kiagiadakis 2023-11-14 21:32:18 +02:00
parent 501f119803
commit ac0d8ee4a8
3 changed files with 27 additions and 17 deletions

View file

@ -0,0 +1,23 @@
# ALSA node property overrides for virtual machine hardware
monitor.alsa.rules = [
# Generic PCI cards on any VM type
{
matches = [
{
node.name = "~alsa_input.pci.*"
vm.type = "~.*"
}
{
node.name = "~alsa_output.pci.*"
vm.type = "~.*"
}
]
actions = {
update-props = {
api.alsa.period-size = 1024
api.alsa.headroom = 2048
}
}
}
]

View file

@ -22,14 +22,6 @@ monitor.alsa.midi.node-properties = {
# api.alsa.disable-longname = false
}
monitor.alsa.vm.node.defaults = {
## These properties override node defaults when running in a virtual machine.
## The rules below still override those.
api.alsa.period-size = 1024
api.alsa.headroom = 8192
}
monitor.alsa.rules = [
## The list of monitor rules

View file

@ -12,7 +12,6 @@ defaults = {}
defaults.reserve_priority = -20
defaults.reserve_application_name = "WirePlumber"
defaults.properties = Json.Object {}
defaults.vm_node_defaults = Json.Object {}
config = {}
config.reserve_device = Core.test_feature ("monitor.alsa.reserve-device")
@ -22,8 +21,6 @@ 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.vm_node_defaults = Conf.get_section (
"monitor.alsa.vm.node.defaults", defaults.vm_node_defaults):parse ()
-- unique device/node name tables
device_names_table = nil
@ -155,12 +152,10 @@ function createNode(parent, id, obj_type, factory, properties)
end
end
-- apply VM overrides
if nonempty(Core.get_vm_type()) and
type(config.vm_node_defaults) == "table" then
for k, v in pairs(config.vm_node_defaults) do
properties[k] = v
end
-- add vm.type for rule matching purposes
local vm_type = Core.get_vm_type()
if nonempty(vm_type) then
properties["vm.type"] = vm_type
end
-- apply properties from rules defined in JSON .conf file