--- Alarm.pm.saved 2011-09-03 22:42:42.000000000 -0700 +++ Alarm.pm 2011-09-04 11:16:12.000000000 -0700 @@ -647,11 +647,11 @@ # if this is a squeezeplay-based player on or after r8312, fallback alarm comes from client-side only } else { - Slim::Utils::Timers::setTimer($self, Time::HiRes::time() + 20, \&_checkPlaying); + Slim::Utils::Timers::setRelTimer($self, 20, \&_checkPlaying); } # Allow a slight delay for things to load up then tell the user what's going on - Slim::Utils::Timers::setTimer($client, Time::HiRes::time() + 2, sub { + Slim::Utils::Timers::setRelTimer($client, 2, sub { # Show a long-lasting notification unless we've already pushed into an alarm screensaver my $showBrieflyDur = 30; if (Slim::Buttons::Common::mode($client) eq $class->alarmScreensaver($client)) { @@ -694,7 +694,7 @@ my $timeout = $prefs->client($client)->alarmTimeoutSeconds; if ($timeout) { main::DEBUGLOG && $isDebug && $log->debug("Scheduling time out in $timeout seconds"); - $self->{_timeoutTimer} = Slim::Utils::Timers::setTimer($self, Time::HiRes::time + $timeout, \&_timeout); + $self->{_timeoutTimer} = Slim::Utils::Timers::setRelTimer($self, $timeout, \&_timeout); } } @@ -753,7 +753,7 @@ Slim::Utils::Timers::killSpecific($self->{_timeoutTimer}); main::DEBUGLOG && $isDebug && $log->debug(sub {'Scheduling automatic timeout in ' . ($timeout + $snoozeSeconds) . ' seconds'}); $self->{_timeoutTimer} = - Slim::Utils::Timers::setTimer($self, Time::HiRes::time + $timeout + $snoozeSeconds, \&_timeout); + Slim::Utils::Timers::setRelTimer($self, $timeout + $snoozeSeconds, \&_timeout); } if (Slim::Music::Info::isRemoteURL(Slim::Player::Playlist::url($client))) { @@ -772,7 +772,7 @@ $self->{_snoozeActive} = 1; # Set timer for snooze expiry - Slim::Utils::Timers::setTimer($self, Time::HiRes::time + $snoozeSeconds, \&stopSnooze); + Slim::Utils::Timers::setRelTimer($self, $snoozeSeconds, \&stopSnooze); # Set up snooze subscription to end snooze on user activity $class->_setAlarmSubscription($client, 1); @@ -821,7 +821,7 @@ # Set a callback to check we're playing. As internet radio # streams have to restart at the end of a snooze they could # potentially fail. - Slim::Utils::Timers::setTimer($self, Time::HiRes::time() + 20, \&_checkPlaying); + Slim::Utils::Timers::setRelTimer($self, 20, \&_checkPlaying); } $client->showBriefly({ @@ -878,7 +878,7 @@ && $client->lineOutConnected()) { # Restore in a second in order to avoid a blip that can occur if setAnalogOutMode # is called during a power off volume fade. Bug 9093. - Slim::Utils::Timers::setTimer($self, Time::HiRes::time() + 1, sub { + Slim::Utils::Timers::setRelTimer($self, 1, sub { main::DEBUGLOG && $isDebug && $log->debug('Restoring previous line out mode'); $client->setAnalogOutMode(); }); @@ -887,7 +887,7 @@ # Restore original volume if the music is stopped at the end of the alarm and # the volume hasn't been changed from the alarm volume level. Do this after a pause # to allow any volume fades to complete. - Slim::Utils::Timers::setTimer($self, Time::HiRes::time() + 1, sub { + Slim::Utils::Timers::setRelTimer($self, 1, sub { # 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'); @@ -1445,7 +1445,7 @@ # to timers firing a few seconds late. my $alarmTime = $nextAlarm->{_nextDue}; main::DEBUGLOG && $isDebug && $log->debug('Scheduling alarm'); - $nextAlarm->{_timerRef} = Slim::Utils::Timers::setTimer($nextAlarm, $alarmTime, \&sound, $alarmTime); + $nextAlarm->{_timerRef} = Slim::Utils::Timers::setAbsTimer($nextAlarm, $alarmTime, \&sound, $alarmTime); $alarmsScheduled++; $class->_startStopTimeCheck; @@ -1527,7 +1527,7 @@ } # Set a timer to check again in 24 hours - $client->alarmData->{_rtcTimerRef} = Slim::Utils::Timers::setTimer($class, $now + 86400, \&setRTCAlarm, $client); + $client->alarmData->{_rtcTimerRef} = Slim::Utils::Timers::setAbsTimer($class, $now + 86400, \&setRTCAlarm, $client); } =head2 defaultVolume( [ $volume ] ) @@ -1910,9 +1910,10 @@ if ($alarmsScheduled && ! $checkTimeTimerRef) { # Start watching the time to track any changes main::DEBUGLOG && $isDebug && $log->debug('Starting time checker task'); - $lastSeenTime = CORE::time; + #$lastSeenTime = CORE::time; + $lastSeenTime = Time::HiRes::time(); $lastSeenDST = (localtime($lastSeenTime))[8]; - $checkTimeTimerRef = Slim::Utils::Timers::setTimer($class, Time::HiRes::time + 60, \&_checkTime); + $checkTimeTimerRef = Slim::Utils::Timers::setRelTimer($class, 60, \&_checkTime); } elsif ($alarmsScheduled == 0 && $checkTimeTimerRef) { main::DEBUGLOG && $isDebug && $log->debug('Stopping time checker task'); Slim::Utils::Timers::killSpecific($checkTimeTimerRef); @@ -1925,11 +1926,12 @@ sub _checkTime { my $class = shift; - my $time = CORE::time; + my $time = Time::HiRes::time(); + #my $time = CORE::time; my $isdst = (localtime($time))[8]; my $delta = $time - $lastSeenTime; - $checkTimeTimerRef = Slim::Utils::Timers::setTimer($class, Time::HiRes::time + 60, \&_checkTime); + $checkTimeTimerRef = Slim::Utils::Timers::setRelTimer($class, 60, \&_checkTime); # We should now be 60 seconds ahead of when the time was last checked. # Timers should never fire early (unless fired manually) so if we appear to be less than @@ -1943,6 +1945,7 @@ $class->scheduleNext($client); } } + main::DEBUGLOG && $log->is_debug && $log->debug("System time check monitor: (delta $delta, lastDST $lastSeenDST, dst: $isdst)"); $lastSeenTime = $time; $lastSeenDST = $isdst;