playback: fall back to raw-range mapping for Alsa mixers without dB info - #1731
Open
qianc wants to merge 1 commit into
Open
playback: fall back to raw-range mapping for Alsa mixers without dB info#1731qianc wants to merge 1 commit into
qianc wants to merge 1 commit into
Conversation
Some Alsa mixer controls expose no dB information at all, most notably the Alsa pulse plugin's `Master`, which maps onto the PulseAudio sink volume. AlsaMixer::open() failed with "Could not get Alsa softvol dB range" for such controls, making them unusable as `--mixer alsa` targets. Instead of failing, map the volume linearly onto the control's raw range and force `VolumeCtrl::Linear`, since without dB information other taper curves cannot be applied faithfully. The softvol antilog compensation is also skipped for these controls: it counteracts Alsa's internal linear-to-dB conversion, which does not happen when the raw volume is applied directly. For PulseAudio a linear raw mapping is the desired behavior anyway, as its raw volume scale is already perceptually (cubically) tapered. This allows `--mixer alsa --alsa-mixer-device pulse --alsa-mixer-control Master` to control the PulseAudio sink (master) volume from Spotify Connect while playing back through the pulseaudio backend. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
qianc
force-pushed
the
alsa-mixer-no-db-fallback
branch
from
July 20, 2026 18:43
4e49aae to
45c0c2b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Some Alsa mixer controls expose no dB information at all — most notably the Alsa pulse plugin's
Master, which maps onto the PulseAudio sink volume.AlsaMixer::open()currently fails hard for such controls:making them unusable as
--mixer alsatargets.What this PR does
When
snd_ctl_get_dB_rangereports that no dB information is available, fall back to mapping the volume linearly onto the control's raw volume range instead of erroring out:VolumeCtrlis forced toLinear, since without dB information other taper curves cannot be applied faithfully.For PulseAudio specifically, a linear raw mapping is the desired behavior: PA's raw volume scale is already perceptually (cubically) tapered (e.g. raw 50% = −18.06 dB), so the Connect volume slider tracks the sink volume 1:1.
Motivation / use case
Running librespot with
--backend pulseaudioon a headless device (raspotify on a Pi 4 with an IQaudIO DAC), where the DAC's hardwareDigitalcontrol spans −103.5..0 dB — too wide a range for a usable taper, and separate from the PulseAudio sink volume that other audio sources go through. With this change,lets Spotify Connect control the PulseAudio sink (master) volume directly, affecting all streams on the sink with a sensible taper.
Testing
Alsa mixer control has no dB information ..., falling back to linear mapping on the raw volume range), the Connect volume slider tracks the PulseAudio sink volume (pactl/alsamixer -D pulseMaster) ~1:1 in both directions, and playback through the pulseaudio backend is unaffected.🤖 Generated with Claude Code