From 1d40e7713f8b9034e628584b1b196e81ccfa0ec3 Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Mon, 15 Feb 2021 19:43:07 +0200 Subject: [PATCH] config: load reserve-device only if alsa.reserve is true and also make the default of alsa.reserve to be false, for easier scripting --- src/config/config.lua | 3 --- src/config/config.lua.d/30-alsa-monitor.lua | 9 +++++++-- src/scripts/monitors/monitor-alsa.lua | 5 ++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/config/config.lua b/src/config/config.lua index 8a306e34..bbd9894e 100644 --- a/src/config/config.lua +++ b/src/config/config.lua @@ -83,9 +83,6 @@ function enable_audio() -- Implements storing metadata about objects in RAM load_module("metadata") - - -- Enables device reservation via org.freedesktop.ReserveDevice1 on D-Bus - load_module("reserve-device") end function enable_endpoints() diff --git a/src/config/config.lua.d/30-alsa-monitor.lua b/src/config/config.lua.d/30-alsa-monitor.lua index 32521771..b6633d72 100644 --- a/src/config/config.lua.d/30-alsa-monitor.lua +++ b/src/config/config.lua.d/30-alsa-monitor.lua @@ -7,8 +7,8 @@ local properties = { -- connect to the real JACK server. --["alsa.jack-device"] = false, - -- Reserve devices. - --["alsa.reserve"] = true, + -- Reserve devices via org.freedesktop.ReserveDevice1 on D-Bus + ["alsa.reserve"] = true, --["alsa.reserve.priority"] = -20, --["alsa.reserve.application-name"] = "WirePlumber", } @@ -97,6 +97,11 @@ local rules = { } function enable_alsa() + -- The "reserve-device" module needs to be loaded for reservation to work + if properties["alsa.reserve"] then + load_module("reserve-device") + end + load_monitor("alsa", { properties = properties, rules = rules, diff --git a/src/scripts/monitors/monitor-alsa.lua b/src/scripts/monitors/monitor-alsa.lua index 4ab7f558..a81d7693 100644 --- a/src/scripts/monitors/monitor-alsa.lua +++ b/src/scripts/monitors/monitor-alsa.lua @@ -303,9 +303,8 @@ if config.properties["alsa.jack-device"] then }) end --- reservation is only disabled by explicitly setting it to false -if config.properties["alsa.reserve"] == true or - config.properties["alsa.reserve"] == nil then +-- enable device reservation if requested +if config.properties["alsa.reserve"] then rd_plugin = Plugin("reserve-device") end