Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions Slim/Utils/Alarm.pm
Original file line number Diff line number Diff line change
Expand Up @@ -609,12 +609,17 @@ sub sound {
# Set up volume
my $currentVolume = $prefs->client($client)->get('volume');
$self->{_originalVolume} = $currentVolume;
main::DEBUGLOG && $isDebug && $log->debug("Current vol: $currentVolume Alarm vol: " . $self->volume);

if ($currentVolume != $self->volume) {
main::DEBUGLOG && $isDebug && $log->debug("Changing volume from $currentVolume to " . $self->volume);
# Capture the alarm volume now so the restore check at alarm end uses the same value,
# even if alarmDefaultVolume changes mid-alarm (which would make $self->volume return
# a different value and cause the restore condition to fail).
my $alarmVolume = $self->volume;
$self->{_activeVolume} = $alarmVolume;
main::DEBUGLOG && $isDebug && $log->debug("Current vol: $currentVolume Alarm vol: $alarmVolume");

if ($currentVolume != $alarmVolume) {
main::DEBUGLOG && $isDebug && $log->debug("Changing volume from $currentVolume to $alarmVolume");
# Bug 15662: use mixer command to change volume so that synced volumes are correctly set
$client->execute(['mixer', 'volume', $self->volume]);
$client->execute(['mixer', 'volume', $alarmVolume]);
}

# Set the player shuffle mode prior to loading
Expand Down Expand Up @@ -895,7 +900,7 @@ sub stop {
# Get volume level directly via the pref as we don't care about temporary
# volume levels (vol is reported as 0 after a mute)
my $vol = $prefs->client($client)->get('volume');
if (! $client->isPlaying && $vol == $self->volume) {
if (! $client->isPlaying && $vol == ($self->{_activeVolume} // $self->volume)) {
main::DEBUGLOG && $isDebug && $log->debug('Restoring pre-alarm volume level: ' . $self->{_originalVolume});
$client->volume($self->{_originalVolume});
}
Expand Down