Author: bklaas
Date: Mon Jul 19 12:50:11 2010
New Revision: 8966

URL: http://svn.slimdevices.com/jive?rev=8966&view=rev
Log:
 r40...@daddymac (orig r8961):  agrundman | 2010-07-19 10:36:46 -0500
 Add decode_output_max_rate function for use in WMA
 r40...@daddymac (orig r8963):  bklaas | 2010-07-19 14:36:20 -0500
 Fixed Bug: 15766
 Description: optimize code to reduce os.date() calls by using the *t arg to it 
and then manipulating the returned hash
 
 r40...@daddymac (orig r8964):  bklaas | 2010-07-19 14:47:10 -0500
 Bug: 15766
 Description: need leading zeroes for several strings when number < 10
 time.wday counts from 1 while strings.txt counts from 0
 
 r40...@daddymac (orig r8965):  bklaas | 2010-07-19 14:49:54 -0500
  r40...@daddymac (orig r8960):  ayoung | 2010-07-19 00:32:15 -0500
  bug 16295: SB Radio changes state & display on its own. 
  Avoid using player state information for the current player from a 
serverstatus notification except under specific conditions:
  - when the state indicates a change in server;
  - when the state indicates a change in connected status.
  r40...@daddymac (orig r8962):  bklaas | 2010-07-19 12:58:58 -0500
  Fixed Bug: 16149
  Description: honor alarm timeout from server for fallback alarm.
  in the absence of the SBS 7.5/trunk checkin r31076, player hard coded to a 60 
minute timeout (which is also the server default for a player's alarm timeout)
  
 

Modified:
    7.6/branches/new-setup/   (props changed)
    
7.6/branches/new-setup/squeezeplay/src/squeezeplay/share/applets/AlarmSnooze/AlarmSnoozeApplet.lua
    
7.6/branches/new-setup/squeezeplay/src/squeezeplay/share/applets/Clock/ClockApplet.lua
    
7.6/branches/new-setup/squeezeplay/src/squeezeplay/share/jive/slim/Player.lua
    
7.6/branches/new-setup/squeezeplay/src/squeezeplay/share/jive/slim/SlimServer.lua
    
7.6/branches/new-setup/squeezeplay/src/squeezeplay/src/audio/decode/decode_output.c
    
7.6/branches/new-setup/squeezeplay/src/squeezeplay/src/audio/decode/decode_priv.h

Propchange: 7.6/branches/new-setup/
------------------------------------------------------------------------------
--- svk:merge (original)
+++ svk:merge Mon Jul 19 12:50:11 2010
@@ -13,8 +13,8 @@
 bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/7.4/private-branches/fab4-skin:4552
 bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/7.4/private-branches/new-alsa:6567
 bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/7.4/trunk:8423
-bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/7.5/trunk:8955
-bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/7.6/trunk:8957
+bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/7.5/trunk:8962
+bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/7.6/trunk:8965
 bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/7.0:2013
 bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/SN:1083
 bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/scrolling:1378

Modified: 
7.6/branches/new-setup/squeezeplay/src/squeezeplay/share/applets/AlarmSnooze/AlarmSnoozeApplet.lua
URL: 
http://svn.slimdevices.com/jive/7.6/branches/new-setup/squeezeplay/src/squeezeplay/share/applets/AlarmSnooze/AlarmSnoozeApplet.lua?rev=8966&r1=8965&r2=8966&view=diff
==============================================================================
--- 
7.6/branches/new-setup/squeezeplay/src/squeezeplay/share/applets/AlarmSnooze/AlarmSnoozeApplet.lua
 (original)
+++ 
7.6/branches/new-setup/squeezeplay/src/squeezeplay/share/applets/AlarmSnooze/AlarmSnoozeApplet.lua
 Mon Jul 19 12:50:11 2010
@@ -129,6 +129,9 @@
 function notify_playerAlarmState(self, player, alarmState, alarmNext)
 
        log:warn('notify_playerAlarmState received for ', player, ' with 
alarmState of ', alarmState)
+       if not player then
+               return
+       end
        if player:isLocal() then
                log:warn('**************************** notify_playerAlarmState 
received: ', alarmState, ' ', alarmNext)
                -- if there's an existing alarm window on the screen and the 
rtc alarm isn't firing, 
@@ -253,6 +256,9 @@
 
 function notify_playerLoaded(self, player)
        log:info("notify_playerLoaded(", player, ")")
+       if not player then
+               return
+       end
        if player == self.localPlayer then
 --             self:_alarm_sledgehammerRearm('notify_playerLoaded')
                -- check for pending server alarm in case that one is pending 
instead, since we may have changed players to force 
@@ -265,6 +271,9 @@
 
 
 function notify_playerPower(self, player, power)
+       if not player then
+               return
+       end
         if player ~= self.localPlayer then
                 return
         end
@@ -293,6 +302,9 @@
 
 function notify_playerModeChange(self, player, mode)
        log:warn('notify_playerModeChange: player (', player,') mode has been 
changed to ', mode)
+       if not player then
+               return
+       end
        local status = decode:status()
        log:warn('notify_playerModeChange: - audioState is ', status.audioState)
 end
@@ -300,6 +312,9 @@
 
 function notify_playerConnected(self, player)
        log:warn('notify_playerConnected: ', player, ' ', self.alarmInProgress)
+       if not player then
+               return
+       end
        if player == self.localPlayer then
 --             self:_alarm_sledgehammerRearm('notify_playerConnected')
                self.server = player:getSlimServer()
@@ -312,6 +327,9 @@
 
 function notify_playerDisconnected(self, player)
        log:warn('notify_playerDisconnected ', player, self.alarmInProgress)
+       if not player then
+               return
+       end
        if player == self.localPlayer then
        end
 end
@@ -428,6 +446,21 @@
        )
        self.fadeInTimer:start()
 
+       local alarmTimeoutSeconds = self.localPlayer:getAlarmTimeoutSeconds() 
or ( 60 * 60 ) -- defaults to 1 hour
+       if alarmTimeoutSeconds ~= 0 then
+               local alarmTimeoutMsecs = alarmTimeoutSeconds * 1000
+               log:info("Fallback alarm will timeout in ", 
alarmTimeoutSeconds, " seconds")
+               self.fallbackAlarmTimeout = Timer(alarmTimeoutMsecs,
+                               function ()
+                                       if self.alarmInProgress == 'rtc' then
+                                               log:warn('rtc alarm has timed 
out')
+                                               self:_alarmOff()
+                                       end
+                               end
+               )
+               self.fallbackAlarmTimeout:start()
+       end
+
 end
 
 
@@ -655,6 +688,11 @@
                log:warn('_alarmOff: send stopAlarm to connected server')
                self.localPlayer:stopAlarm()
        end
+
+       if self.fallbackAlarmTimeout and self.fallbackAlarmTimeout:isRunning() 
then
+               self.fallbackAlarmTimeout:stop()
+       end
+
 end
 
 

Modified: 
7.6/branches/new-setup/squeezeplay/src/squeezeplay/share/applets/Clock/ClockApplet.lua
URL: 
http://svn.slimdevices.com/jive/7.6/branches/new-setup/squeezeplay/src/squeezeplay/share/applets/Clock/ClockApplet.lua?rev=8966&r1=8965&r2=8966&view=diff
==============================================================================
--- 
7.6/branches/new-setup/squeezeplay/src/squeezeplay/share/applets/Clock/ClockApplet.lua
 (original)
+++ 
7.6/branches/new-setup/squeezeplay/src/squeezeplay/share/applets/Clock/ClockApplet.lua
 Mon Jul 19 12:50:11 2010
@@ -143,6 +143,31 @@
        return obj
 end
 
+function Clock:_getHour(time)
+       local theHour = time.hour
+       if self.clock_format_hour == "%I" then
+               theHour = time.hour % 12
+       end
+       return string.format("%02s", tostring(theHour))
+
+end
+
+
+function Clock:_getMinute(time)
+       return string.format("%02s", tostring(time.min))
+end
+
+
+function Clock:_getDate(time)
+       local theDate
+       if self.clock_format_date == "%d%m%Y" then
+               theDate = string.format("%02s", tostring(time.day)) .. 
string.format("%02s", tostring(time.month)) .. tostring(time.year)
+       else
+               theDate = string.format("%02s", tostring(time.month)) .. 
string.format("%02s", tostring(time.day)) .. tostring(time.year)
+       end
+       return theDate
+end
+
 DotMatrix = oo.class({}, Clock)
 
 function DotMatrix:__init(ampm, shortDateFormat)
@@ -260,10 +285,11 @@
 
 function DotMatrix:Draw()
 
-
-       local theHour   = os.date(self.clock_format_hour)
-       local theMinute = os.date(self.clock_format_minute)
-       local theDate   = os.date(self.clock_format_date)
+       local time = os.date("*t")
+
+       local theHour   = self:_getHour(time)
+       local theMinute = self:_getMinute(time)
+       local theDate   = self:_getDate(time)
 
 --[[
        FOR TESTING PURPOSES 
@@ -278,18 +304,15 @@
        local theMinute = '59'
        local theDate   = '12312009'
 --]]
-
        -- draw hour digits
        self:DrawClock(string.sub(theHour, 1, 1), 'h1')
        self:DrawClock(string.sub(theHour, 2, 2), 'h2')
 
        -- draw minute digits
-       theTime = os.date(self.clock_format_minute)
        self:DrawClock(string.sub(theMinute, 1, 1), 'm1')
        self:DrawClock(string.sub(theMinute, 2, 2), 'm2')
 
        -- draw month digits
-       theTime = os.date(self.clock_format_date)
        self:DrawDate(string.sub(theDate, 1, 1), 'M1')
        self:DrawDate(string.sub(theDate, 2, 2), 'M2')
 
@@ -370,8 +393,9 @@
        local x, y
 
        -- Setup Time Objects
-       local m = os.date("%M")
-       local h = os.date("%I")
+       local time = os.date("*t")
+       local m = time.min
+       local h = time.hour % 12
 
        -- Hour Pointer
        local angle = (360 / 12) * (h + (m/60))
@@ -506,22 +530,24 @@
        
 function Digital:Draw()
 
+       local time = os.date("*t")
+
        -- string day of week
-       local dayOfWeek   = os.date("%w")
-       local token = "SCREENSAVER_CLOCK_DAY_" .. tostring(dayOfWeek)
+       local dayOfWeek   = tostring(time.wday - 1)
+
+       local token = "SCREENSAVER_CLOCK_DAY_" .. dayOfWeek
        local dayOfWeekString = self.applet:string(token)
        self.today:setValue(dayOfWeekString)
        local widget = self.dateGroup:getWidget('dayofweek')
        widget:setValue(dayOfWeekString)
 
        -- numerical day of month
-       local dayOfMonth = os.date("%d")
+       local dayOfMonth = tostring(time.day)
        widget = self.dateGroup:getWidget('dayofmonth')
        widget:setValue(dayOfMonth)
 
        -- string month of year
-       local monthOfYear = os.date("%m")
-       token = "SCREENSAVER_CLOCK_MONTH_" .. tostring(monthOfYear)
+       token = "SCREENSAVER_CLOCK_MONTH_" .. string.format("%02s", 
tostring(time.month))
        local monthString = self.applet:string(token)
        widget = self.dateGroup:getWidget('month')
        widget:setValue(monthString)
@@ -534,7 +560,7 @@
        end
 
        -- what time is it? it's time to get ill!
-       self:DrawTime()
+       self:DrawTime(time)
        
        --FOR DEBUG
        --[[
@@ -584,10 +610,15 @@
        widget:setValue('September')
 end
 
-
-function Digital:DrawTime()
-       local theHour   = os.date(self.clock_format_hour)
-       local theMinute = os.date(self.clock_format_minute)
+function Digital:DrawTime(time)
+
+       if not time then
+               time = os.date("*t")
+       end
+
+       --local theMinute = tostring(time.min)
+       local theMinute = self:_getMinute(time)
+       local theHour   = self:_getHour(time)
 
        if string.sub(theHour, 1, 1) == '0' then
                self.h1:setValue('')
@@ -605,7 +636,7 @@
        
        -- Draw AM PM
        if self.useAmPm then
-               -- localized ampm rendering
+               -- localized ampm rendering requires an os.date() call
                local ampm = os.date("%p")
                self.ampm:setValue(ampm)
        end

Modified: 
7.6/branches/new-setup/squeezeplay/src/squeezeplay/share/jive/slim/Player.lua
URL: 
http://svn.slimdevices.com/jive/7.6/branches/new-setup/squeezeplay/src/squeezeplay/share/jive/slim/Player.lua?rev=8966&r1=8965&r2=8966&view=diff
==============================================================================
--- 
7.6/branches/new-setup/squeezeplay/src/squeezeplay/share/jive/slim/Player.lua 
(original)
+++ 
7.6/branches/new-setup/squeezeplay/src/squeezeplay/share/jive/slim/Player.lua 
Mon Jul 19 12:50:11 2010
@@ -1188,7 +1188,10 @@
        self.playlistCurrentIndex = event.data.playlist_cur_index and 
tonumber(event.data.playlist_cur_index) + 1
        self.definedPresets = event.data.preset_loop
        -- alarm snooze seconds for player, defaults to 540
-       self.alarmSnoozeSeconds = event.data.alarm_snooze_seconds
+       self.alarmSnoozeSeconds  = event.data.alarm_snooze_seconds
+       -- alarm timeout seconds for player, defaults to 3600 (same as server 
default)
+       self.alarmTimeoutSeconds = event.data.alarm_timeout_seconds
+
        -- Bug 15814: flag for when the audio hasn't started streaming yet but 
mode is play
        self.waitingToPlay = event.data.waitingToPlay or false
 
@@ -1874,6 +1877,10 @@
        return self.alarmSnoozeSeconds or 540
 end
 
+function getAlarmTimeoutSeconds(self)
+       return self.alarmTimeoutSeconds or 3600
+end
+
 function isConnected(self)
        return self.slimServer and self.slimServer:isConnected() and 
self.info.connected
 end

Modified: 
7.6/branches/new-setup/squeezeplay/src/squeezeplay/share/jive/slim/SlimServer.lua
URL: 
http://svn.slimdevices.com/jive/7.6/branches/new-setup/squeezeplay/src/squeezeplay/share/jive/slim/SlimServer.lua?rev=8966&r1=8965&r2=8966&view=diff
==============================================================================
--- 
7.6/branches/new-setup/squeezeplay/src/squeezeplay/share/jive/slim/SlimServer.lua
 (original)
+++ 
7.6/branches/new-setup/squeezeplay/src/squeezeplay/share/jive/slim/SlimServer.lua
 Mon Jul 19 12:50:11 2010
@@ -254,19 +254,37 @@
                        if not self.players[playerId] then
                                self.players[playerId] = Player(self.jnt, 
playerId)
                        end
+                       
+                       local player = self.players[playerId]
 
                        -- update player state
 
                        local useSequenceNumber = false
                        local isSequenceNumberInSync = true
-                       if self.players[playerId]:isLocal() and 
player_info.seq_no then
+                       if player:isLocal() and player_info.seq_no then
                                useSequenceNumber = true
-                               if not 
self.players[playerId]:isSequenceNumberInSync(tonumber(player_info.seq_no)) then
+                               if not 
player:isSequenceNumberInSync(tonumber(player_info.seq_no)) then
                                        isSequenceNumberInSync = false
                                end
                        end
-
-                       self.players[playerId]:updatePlayerInfo(self, 
player_info, useSequenceNumber, isSequenceNumberInSync)
+                       
+                       -- Bug 16295: ignore serverStatus updates with 
information about the current player
+                       -- because serverStatus from SN can contain out-of-date 
information (cached query);
+                       -- just rely on (player)status notifications for that 
information,
+                       -- unless this status indicates a change of server 
(possibly from none) for the player
+                       -- or the connected status has changed (should be 
reliable).
+                       --
+                       -- It is important that these tests allow the first 
serverstatus for the current player
+                       -- to be used because otherwise the correct 
notifications are not issued and various
+                       -- necessary initialization functions are not run, 
including those that subscribe to
+                       -- (player)status notifications.
+                       
+                       if Player:getCurrentPlayer() ~= player
+                               or player:getSlimServer() ~= self
+                               or player:isConnected() ~= 
(tonumber(player_info.connected) == 1)
+                       then
+                               player:updatePlayerInfo(self, player_info, 
useSequenceNumber, isSequenceNumberInSync)
+                       end
                end
        else
                log:debug(self, ": has no players!")

Modified: 
7.6/branches/new-setup/squeezeplay/src/squeezeplay/src/audio/decode/decode_output.c
URL: 
http://svn.slimdevices.com/jive/7.6/branches/new-setup/squeezeplay/src/squeezeplay/src/audio/decode/decode_output.c?rev=8966&r1=8965&r2=8966&view=diff
==============================================================================
--- 
7.6/branches/new-setup/squeezeplay/src/squeezeplay/src/audio/decode/decode_output.c
 (original)
+++ 
7.6/branches/new-setup/squeezeplay/src/squeezeplay/src/audio/decode/decode_output.c
 Mon Jul 19 12:50:11 2010
@@ -433,6 +433,17 @@
        decode_audio_unlock();
 
        return sample_rate;
+}
+
+
+int decode_output_max_rate(void) {
+       u32_t max_rate;
+
+       decode_audio_lock();
+       max_rate = decode_audio->max_rate;
+       decode_audio_unlock();
+
+       return max_rate;
 }
 
 

Modified: 
7.6/branches/new-setup/squeezeplay/src/squeezeplay/src/audio/decode/decode_priv.h
URL: 
http://svn.slimdevices.com/jive/7.6/branches/new-setup/squeezeplay/src/squeezeplay/src/audio/decode/decode_priv.h?rev=8966&r1=8965&r2=8966&view=diff
==============================================================================
--- 
7.6/branches/new-setup/squeezeplay/src/squeezeplay/src/audio/decode/decode_priv.h
 (original)
+++ 
7.6/branches/new-setup/squeezeplay/src/squeezeplay/src/audio/decode/decode_priv.h
 Mon Jul 19 12:50:11 2010
@@ -99,6 +99,8 @@
 
 extern int decode_output_samplerate(void);
 
+extern int decode_output_max_rate(void);
+
 extern void decode_output_song_ended(void);
 
 extern void decode_output_set_transition(u32_t type, u32_t period);

_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/jive-checkins

Reply via email to