Skip to content

Alarm: snapshot active volume at start to fix pre-alarm volume restore#1563

Merged
michaelherger merged 1 commit intoLMS-Community:public/9.2from
boudekerk:fix/alarm-volume-restore
May 6, 2026
Merged

Alarm: snapshot active volume at start to fix pre-alarm volume restore#1563
michaelherger merged 1 commit intoLMS-Community:public/9.2from
boudekerk:fix/alarm-volume-restore

Conversation

@boudekerk
Copy link
Copy Markdown
Contributor

@boudekerk boudekerk commented May 2, 2026

Problem

For alarms that use the default volume (i.e. no per-alarm volume override), the restore check in stop() calls $self->volume dynamically. That method falls through to defaultVolume() which reads the alarmDefaultVolume preference live.

If the user changes the default alarm volume in settings while an alarm is active, $self->volume now returns a different value than the one that was set at alarm start. The guard condition:

if (! $client->isPlaying && $vol == $self->volume)

then fails, and the pre-alarm volume is never restored — even though the user never touched the player volume during the alarm.

Fix

Snapshot $self->volume into $self->{_activeVolume} in sound() and compare against that snapshot in stop(). The // fallback handles alarm objects that were created before this field existed.

This does not change behaviour when the user manually adjusts volume during an alarm: the current volume will differ from _activeVolume, so the restore is correctly skipped.

For alarms using the default volume, the restore check in stop() called
$self->volume dynamically, which reads alarmDefaultVolume live. If that
setting changed mid-alarm the check would fail and the pre-alarm volume
would never be restored, even though the user hadn't touched the player.

Fix: capture $self->volume into $self->{_activeVolume} in sound() and
compare against that snapshot in stop(). The // fallback handles alarm
objects created before this field existed.

Signed-off-by: Bartosz Oudekerk <lot+github@unreachablehost.net>
@michaelherger
Copy link
Copy Markdown
Member

I don't follow. There's only one volume setting. There is no per-alarm setting, is there?

@boudekerk
Copy link
Copy Markdown
Contributor Author

boudekerk commented May 4, 2026

It looks like the per-alarm setting is simply not being exposed:

N.B. This feature is not exposed in the default interfaces. Alarms all use the default volume.

N.B. This feature is not exposed in the default interfaces. Alarms all use the default volume.

@michaelherger michaelherger merged commit ce279fd into LMS-Community:public/9.2 May 6, 2026
1 check passed
@michaelherger
Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants