s/create-item: add setting to enforce a media.role on streams that don't have one

This commit is contained in:
George Kiagiadakis 2024-06-25 15:53:11 +03:00
parent 42727fcbc6
commit fea6b11ad1
3 changed files with 28 additions and 0 deletions

View file

@ -787,6 +787,11 @@ wireplumber.settings.schema = {
min = 0.0
max = 1.0
}
node.stream.default-media-role = {
description = "A media.role to assign on streams that have none specified"
type = "string"
default = null
}
node.filter.forward-format = {
description = "Whether to forward format on filter nodes or not"
type = "bool"

View file

@ -12,6 +12,14 @@ wireplumber.profiles = {
}
}
wireplumber.settings = {
# This sets a default media role to be applied to streams that don't have
# a role already set. This allows you to force all streams to go through
# the role loopbacks. If not set, then streams without a role will follow
# the standard desktop policy and will link to the default sink
node.stream.default-media-role = "Multimedia"
}
wireplumber.components.rules = [
# This encodes common arguments and dependencies of the role loopbacks so that
# we don't have to repeateadly write them on all instances below
@ -29,7 +37,13 @@ wireplumber.components.rules = [
media.class = Audio/Sink
}
playback.props = {
# This must be set to ensure that the real audio sink is suspended
# when there is no active client stream linked
node.passive = true
# Set this to an unused role to make sure that loopbacks don't
# accidentally chain-link on to one another, especially when
# node.stream.default-media-role is configured in the settings
media.role = "Loopback"
}
}
requires = [ support.export-core, pw.node-factory.adapter ]

View file

@ -41,6 +41,15 @@ function configProperties (node)
Settings.get_boolean ("node.features.audio.control-port")
properties ["node.id"] = node ["bound-id"]
-- set the default media.role, if configured
-- avoid Settings.get_string(), as it will parse the default "null" value
-- as a string instead of returning nil
local default_role = Settings.get ("node.stream.default-media-role")
if default_role then
default_role = default_role:parse()
properties ["media.role"] = properties ["media.role"] or default_role
end
return properties
end