mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2025-12-20 04:10:03 +01:00
apply-routes.lua: Add a mechanism for per-device default volumes
This allows us to have per-device configuration for device volumes, via a `device.routes.default-volume` property. This allows a non-global override for situations where we want to expose a different out-of-box volume (say for an internal speaker where we know a better comfortable default setting, or HDMI where we might want to avoid attenuation by default).
This commit is contained in:
parent
80478e7548
commit
080ebc5e17
2 changed files with 16 additions and 3 deletions
|
|
@ -43,6 +43,10 @@ previous section: :ref:`config_configuration_option_types`.
|
|||
device route (e.g. ALSA PCM sinks). This is used when the route is restored
|
||||
and the sink does not have a previously stored volume.
|
||||
|
||||
It is possible to override the value on a per-device basis with a property
|
||||
(*not* a setting, so this would go into a configuration file) on the device
|
||||
named ``device.routes.default-sink-volume``.
|
||||
|
||||
:Default value: ``0.4 ^ 3`` (40% on the cubic scale)
|
||||
|
||||
.. describe:: device.routes.default-source-volume
|
||||
|
|
@ -51,6 +55,10 @@ previous section: :ref:`config_configuration_option_types`.
|
|||
device route (e.g. ALSA PCM sources). This is used when the route is restored
|
||||
and the source does not have a previously stored volume.
|
||||
|
||||
It is possible to override the value on a per-device basis with a property
|
||||
(*not* a setting, so this would go into a configuration file) on the device
|
||||
named ``device.routes.default-source-volume``.
|
||||
|
||||
:Default value: ``1.0`` (100%)
|
||||
|
||||
.. describe:: linking.allow-moving-streams
|
||||
|
|
|
|||
|
|
@ -55,9 +55,14 @@ AsyncEventHook {
|
|||
-- ensure default values
|
||||
local is_input = (route_info.direction == "Input")
|
||||
props.mute = props.mute or false
|
||||
props.channelVolumes = props.channelVolumes or
|
||||
{ is_input and Settings.get_float ("device.routes.default-source-volume")
|
||||
or Settings.get_float ("device.routes.default-sink-volume") }
|
||||
props.channelVolumes = props.channelVolumes or {
|
||||
-- See if we have a per-device override
|
||||
(is_input and tonumber(device.properties["device.routes.default-source-volume"]))
|
||||
or tonumber(device.properties["device.routes.default-sink-volume"])
|
||||
-- Otherwise we use the global default
|
||||
or (is_input and Settings.get_float ("device.routes.default-source-volume"))
|
||||
or Settings.get_float ("device.routes.default-sink-volume")
|
||||
}
|
||||
|
||||
-- prefix the props with correct IDs to create a Pod.Object
|
||||
table.insert (props, 1, "Spa:Pod:Object:Param:Props")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue