Fix -w volume script: shared helper, correct dB mapping, skip on power-off#1
Merged
mr-manuel merged 1 commit intoMay 6, 2026
Conversation
Adds a -w <script> option that invokes an executable script whenever LMS sends a volume command (AUDG packet). The script receives a single integer argument 0-100 mapped from the LMS dB range (-72..0 dB) using the same linear scale that the ALSA mixer path already uses. When -w is active the internal software gain is held at unity (FIXED_ONE) so the script has full control over output level. The shared helper call_volume_script() is placed in output.c (always compiled) to avoid duplicating the mapping arithmetic across the ALSA, PortAudio and PulseAudio backends. On POSIX the script is launched asynchronously via a shell "&" so the audio thread is not blocked; on Windows "start /B" is used instead. -w is mutually exclusive with -V (ALSA hardware volume control).
Owner
|
Thanks! |
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.
Following up on your comment in ralph-irving#258.
This fixes three issues in the current
-wimplementation and refactors the code to avoid duplication across backends.Changes
Shared helper in output.c — replaces the ~40-line inline block copy-pasted into
output_alsa.candoutput_pa.cwith a singlecall_volume_script()function. All three backends (ALSA, PortAudio, PulseAudio) call it with one line.Correct dB floor — the hardcoded
dB_min = -49.510895causedvol=0for any LMS volume at or below ~16%, as reported by allmazz in the PR comments. The fix mirrors the floor that ALSA's own mixer path uses:MINVOL_DB = 72, giving a -72..0 dB range mapped linearly to 0-100.Skip script on power-off —
call_volume_script()returns immediately whenoutput.state == OUTPUT_OFF. This prevents LMS's fade-to-off AUDG sequence from reaching the script and muting external hardware (e.g. a miniDSP whose master gain affects all inputs including sources other than squeezelite).Consistent async on all backends — PulseAudio previously ran the script synchronously (blocking the audio thread). Now all POSIX backends launch with
&; Windows usesstart /B.Man page —
-wdocumented indoc/squeezelite.1.