diff --git a/docs/rst/daemon/configuration/settings.rst b/docs/rst/daemon/configuration/settings.rst index e9d04234..22bf4dcd 100644 --- a/docs/rst/daemon/configuration/settings.rst +++ b/docs/rst/daemon/configuration/settings.rst @@ -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 diff --git a/src/scripts/device/apply-routes.lua b/src/scripts/device/apply-routes.lua index f74c337f..f8686da4 100644 --- a/src/scripts/device/apply-routes.lua +++ b/src/scripts/device/apply-routes.lua @@ -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")