diff --git a/src/config/wireplumber.conf.d/alsa-vm.conf b/src/config/wireplumber.conf.d/alsa-vm.conf new file mode 100644 index 00000000..1ababe97 --- /dev/null +++ b/src/config/wireplumber.conf.d/alsa-vm.conf @@ -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 + } + } + } +] diff --git a/src/config/wireplumber.conf.d/alsa.conf b/src/config/wireplumber.conf.d/alsa.conf index 7c15c069..bda1657c 100644 --- a/src/config/wireplumber.conf.d/alsa.conf +++ b/src/config/wireplumber.conf.d/alsa.conf @@ -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 diff --git a/src/scripts/monitors/alsa.lua b/src/scripts/monitors/alsa.lua index 708deb55..edc37d1a 100644 --- a/src/scripts/monitors/alsa.lua +++ b/src/scripts/monitors/alsa.lua @@ -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