policy-node.lua: apply policy settings live
Also change the setting names as per nomenclature.
This commit is contained in:

committed by
Julian Bouzas

parent
d28d7d4278
commit
4dd8dd6ce5
@@ -40,24 +40,24 @@ wireplumber.components = [
|
||||
|
||||
wireplumber.settings = {
|
||||
# moves session items when metadata target.node changes
|
||||
default-policy-move = true
|
||||
policy.default.move = true
|
||||
|
||||
# moves session items to the default device when it has changed
|
||||
default-policy-follow = true
|
||||
policy.default.follow = true
|
||||
|
||||
# Whether to forward the ports format of filter stream nodes to their
|
||||
# associated filter device nodes. This is needed for application to stream
|
||||
# surround audio if echo-cancel is enabled.
|
||||
filter.forward-format = false
|
||||
policy.default.filter-forward-format = false
|
||||
|
||||
# Set to 'true' to disable channel splitting & merging on nodes and enable
|
||||
# passthrough of audio in the same format as the format of the device.
|
||||
# Note that this breaks JACK support; it is generally not recommended
|
||||
default-policy-audio.no-dsp = false
|
||||
policy.default.audio-no-dsp = false
|
||||
|
||||
# how much to lower the volume of lower priority streams when ducking
|
||||
# note that this is a linear volume modifier (not cubic as in pulseaudio)
|
||||
default-policy-duck.level = 0.3
|
||||
policy.default.duck-level = 0.3
|
||||
|
||||
# Whether to store state on the filesystem.
|
||||
bt-policy-use-persistent-storage = true
|
||||
|
@@ -16,7 +16,7 @@ function configProperties (node)
|
||||
["item.node"] = node,
|
||||
["item.plugged.usec"] = GLib.get_monotonic_time (),
|
||||
["item.features.no-dsp"] =
|
||||
Settings.parse_boolean_safe ("default-policy-audio.no-dsp", false),
|
||||
Settings.parse_boolean_safe ("policy.default.audio-no-dsp", false),
|
||||
["item.features.monitor"] = true,
|
||||
["item.features.control-port"] = false,
|
||||
["node.id"] = node ["bound-id"],
|
||||
|
@@ -5,7 +5,7 @@
|
||||
--
|
||||
-- SPDX-License-Identifier: MIT
|
||||
|
||||
local duck_level = Settings.parse_float_safe ("default-policy-duck.level", 0.3)
|
||||
local duck_level = Settings.parse_float_safe ("policy.default.duck-level", 0.3)
|
||||
local roles = Settings.parse_object_safe ("endpoints-roles")
|
||||
|
||||
function findRole(role)
|
||||
|
@@ -5,8 +5,8 @@
|
||||
--
|
||||
-- SPDX-License-Identifier: MIT
|
||||
|
||||
local move = Settings.parse_boolean_safe ("default-policy-move", false)
|
||||
local follow = Settings.parse_boolean_safe ("default-policy-follow", false)
|
||||
local move = Settings.parse_boolean_safe ("policy.default.move", false)
|
||||
local follow = Settings.parse_boolean_safe ("policy.default.follow", false)
|
||||
|
||||
local self = {}
|
||||
self.scanning = false
|
||||
|
@@ -14,6 +14,12 @@ local cutils = require ("common-utils")
|
||||
|
||||
local move = Settings.parse_boolean_safe ("default-policy-move", false)
|
||||
|
||||
function settingsChangedCallback (_, setting, _)
|
||||
move = Settings.parse_boolean_safe ("policy.default.move", move)
|
||||
end
|
||||
|
||||
Settings.subscribe ("policy.default.move", settingsChangedCallback)
|
||||
|
||||
function parseBool (var)
|
||||
return cutils.parseBool (var)
|
||||
end
|
||||
|
@@ -16,14 +16,32 @@
|
||||
|
||||
-- settings file: policy.conf
|
||||
|
||||
local move = Settings.parse_boolean_safe ("default-policy-move", false)
|
||||
local follow = Settings.parse_boolean_safe ("default-policy-follow", false)
|
||||
local filter_forward_format =
|
||||
Settings.parse_boolean_safe ("filter.forward-format", false)
|
||||
|
||||
local putils = require ("policy-utils")
|
||||
local cutils = require ("common-utils")
|
||||
|
||||
local move = Settings.parse_boolean_safe ("policy.default.move", false)
|
||||
local follow = Settings.parse_boolean_safe ("policy.default.follow", false)
|
||||
local filter_forward_format = Settings.parse_boolean_safe
|
||||
("policy.default.filter-forward-format", false)
|
||||
|
||||
local function settingsChangedCallback (_, setting, _)
|
||||
|
||||
if setting == "policy.default.move" then
|
||||
move = Settings.parse_boolean_safe ("policy.default.move", move)
|
||||
handleMoveSetting (move)
|
||||
elseif setting == "policy.default.follow" then
|
||||
follow = Settings.parse_boolean_safe ("policy.default.move", follow)
|
||||
handleFollowSetting (follow)
|
||||
elseif setting == "policy.default.filter-forward-format" then
|
||||
filter_forward_format = Settings.parse_boolean_safe
|
||||
("policy.default.filter-forward-format", filter_forward_format)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Settings.subscribe ("policy.default*", settingsChangedCallback)
|
||||
|
||||
find_target_events = {}
|
||||
|
||||
function parseBool (var)
|
||||
@@ -291,62 +309,81 @@ SimpleEventHook {
|
||||
end
|
||||
}:register ()
|
||||
|
||||
if follow then
|
||||
SimpleEventHook {
|
||||
name = "follow@policy-node",
|
||||
type = "after-events",
|
||||
priority = "rescan-policy",
|
||||
interests = {
|
||||
EventInterest {
|
||||
Constraint { "event.type", "=", "object-changed" },
|
||||
Constraint { "event.subject.type", "=", "metadata" },
|
||||
Constraint { "metadata.name", "=", "default" },
|
||||
Constraint { "event.subject.key", "=", "default.audio.source" },
|
||||
local follow_hook_handle = nil
|
||||
|
||||
local function handleFollowSetting (enable)
|
||||
if (follow_hook_handle == nil) and (enable == true) then
|
||||
follow_hook_handle = SimpleEventHook {
|
||||
name = "follow@policy-node",
|
||||
type = "after-events",
|
||||
priority = "rescan-policy",
|
||||
interests = {
|
||||
EventInterest {
|
||||
Constraint { "event.type", "=", "object-changed" },
|
||||
Constraint { "event.subject.type", "=", "metadata" },
|
||||
Constraint { "metadata.name", "=", "default" },
|
||||
Constraint { "event.subject.key", "=", "default.audio.source" },
|
||||
},
|
||||
EventInterest {
|
||||
Constraint { "event.type", "=", "object-changed" },
|
||||
Constraint { "event.subject.type", "=", "metadata" },
|
||||
Constraint { "metadata.name", "=", "default" },
|
||||
Constraint { "event.subject.key", "=", "default.audio.sink" },
|
||||
},
|
||||
EventInterest {
|
||||
Constraint { "event.type", "=", "object-changed" },
|
||||
Constraint { "event.subject.type", "=", "metadata" },
|
||||
Constraint { "metadata.name", "=", "default" },
|
||||
Constraint { "event.subject.key", "=", "default.video.source" },
|
||||
},
|
||||
},
|
||||
EventInterest {
|
||||
Constraint { "event.type", "=", "object-changed" },
|
||||
Constraint { "event.subject.type", "=", "metadata" },
|
||||
Constraint { "metadata.name", "=", "default" },
|
||||
Constraint { "event.subject.key", "=", "default.audio.sink" },
|
||||
},
|
||||
EventInterest {
|
||||
Constraint { "event.type", "=", "object-changed" },
|
||||
Constraint { "event.subject.type", "=", "metadata" },
|
||||
Constraint { "metadata.name", "=", "default" },
|
||||
Constraint { "event.subject.key", "=", "default.video.source" },
|
||||
},
|
||||
},
|
||||
execute = function ()
|
||||
rescan ()
|
||||
end
|
||||
}:register ()
|
||||
execute = function ()
|
||||
rescan ()
|
||||
end
|
||||
}
|
||||
follow_hook_handle:register ()
|
||||
elseif (follow_hook_handle ~= nil) and (enable == false) then
|
||||
follow_hook_handle:remove ()
|
||||
follow_hook_handle = nil
|
||||
end
|
||||
end
|
||||
|
||||
if move then
|
||||
SimpleEventHook {
|
||||
name = "move@policy-node",
|
||||
type = "after-events",
|
||||
priority = "rescan-policy",
|
||||
interests = {
|
||||
EventInterest {
|
||||
Constraint { "event.type", "=", "object-changed" },
|
||||
Constraint { "event.subject.type", "=", "metadata" },
|
||||
Constraint { "metadata.name", "=", "default" },
|
||||
Constraint { "event.subject.key", "=", "target.node" },
|
||||
local move_hook_handle = nil
|
||||
|
||||
function handleMoveSetting (enable)
|
||||
if (move_hook_handle == nil) and (enable == true) then
|
||||
move_hook_handle = SimpleEventHook {
|
||||
name = "move@policy-node",
|
||||
type = "after-events",
|
||||
priority = "rescan-policy",
|
||||
interests = {
|
||||
EventInterest {
|
||||
Constraint { "event.type", "=", "object-changed" },
|
||||
Constraint { "event.subject.type", "=", "metadata" },
|
||||
Constraint { "metadata.name", "=", "default" },
|
||||
Constraint { "event.subject.key", "=", "target.node" },
|
||||
},
|
||||
EventInterest {
|
||||
Constraint { "event.type", "=", "object-changed" },
|
||||
Constraint { "event.subject.type", "=", "metadata" },
|
||||
Constraint { "metadata.name", "=", "default" },
|
||||
Constraint { "event.subject.key", "=", "target.object" },
|
||||
},
|
||||
},
|
||||
EventInterest {
|
||||
Constraint { "event.type", "=", "object-changed" },
|
||||
Constraint { "event.subject.type", "=", "metadata" },
|
||||
Constraint { "metadata.name", "=", "default" },
|
||||
Constraint { "event.subject.key", "=", "target.object" },
|
||||
},
|
||||
},
|
||||
execute = function ()
|
||||
rescan ()
|
||||
end
|
||||
}:register ()
|
||||
execute = function ()
|
||||
rescan ()
|
||||
end
|
||||
}
|
||||
move_hook_handle:register()
|
||||
elseif (move_hook_handle ~= nil) and (enable == false) then
|
||||
move_hook_handle:remove ()
|
||||
move_hook_handle = nil
|
||||
end
|
||||
end
|
||||
|
||||
handleMoveSetting (move)
|
||||
handleFollowSetting (follow)
|
||||
|
||||
default_nodes = Plugin.find ("default-nodes-api")
|
||||
|
||||
endpoints_om = ObjectManager { Interest { type = "SiEndpoint" } }
|
||||
|
Reference in New Issue
Block a user