Streamline regards to recordings timers when coming from deep standby
authorLittlesat <littlesat99@yahoo.com>
Sun, 8 Sep 2013 20:54:09 +0000 (22:54 +0200)
committerLittlesat <littlesat99@yahoo.com>
Sun, 8 Sep 2013 20:54:09 +0000 (22:54 +0200)
Go to standby not directly buy after 30 seconds and not directly as it seems to make some plugins not compatible and for some hardware the wasWakeupTimer is not
functioning properly, so put the box in standby after 30 seconds when there is realty a record timer (record, zap&record or only zap) within 6 minutes. It is assumed that within 30 seconds we should have a correct timestamp as this is proven to perform well for years.

Thanks Dima73 for all comments and sorry for not always understanding you.

Navigation.py
RecordTimer.py

index 84ac980..54c8c38 100644 (file)
@@ -1,4 +1,4 @@
-from enigma import eServiceCenter, eServiceReference, eTimer, pNavigation, getBestPlayableServiceReference, iPlayableService
+from enigma import eServiceCenter, eServiceReference, eTimer, pNavigation, getBestPlayableServiceReference, iPlayableService, eActionMap
 from Components.ParentalControl import parentalControl
 from Tools.BoundFunction import boundFunction
 from Tools.StbHardware import setFPWakeuptime, getFPWakeuptime, getFPWasTimerWakeup
@@ -9,6 +9,7 @@ import Screens.Standby
 import NavigationInstance
 import ServiceReference
 from Screens.InfoBar import InfoBar
+from sys import maxint
 
 # TODO: remove pNavgation, eNavigation and rewrite this stuff in python.
 class Navigation:
@@ -33,10 +34,24 @@ class Navigation:
                self.RecordTimer = RecordTimer.RecordTimer()
                self.__wasTimerWakeup = getFPWasTimerWakeup()
                if self.__wasTimerWakeup:
+                       # We need to give the systemclock the chance to sync with the transponder time,
+                       self.recordshutdowntimer = eTimer()
+                       self.recordshutdowntimer.callback.append(self.checkShutdownAfterRecording)
+                       self.recordshutdowntimer.startLongTimer(30)
+                       eActionMap.getInstance().bindAction('', -maxint - 1, self.keypress)
+
+       def checkShutdownAfterRecording(self):
+               if len(self.getRecordings()) or abs(self.RecordTimer.getNextTimerTime() - time()) <= 360:
                        if Screens.Standby.inStandby: #In case some plugin did put the receiver already in standby
                                config.misc.standbyCounter.value = 0
                        else:
                                Notifications.AddNotification(Screens.Standby.Standby, StandbyCounterIncrease=False)
+                       self.keypress() #this ensures to unbind the keypress detection  
+
+       def keypress(self, key=None, flag=1):
+               if flag:
+                       eActionMap.getInstance().unbindAction('', self.keypress)
+                       self.recordshutdowntimer.stop()
 
        def wasTimerWakeup(self):
                return self.__wasTimerWakeup
index 5b8dc39..4f42426 100644 (file)
@@ -258,15 +258,11 @@ class RecordTimerEntry(timer.TimerEntry, object):
                self.log(5, "activating state %d" % next_state)
 
                if next_state == 1:
-                       if Screens.Standby.inStandby:
-                               Screens.Standby.inStandby.prev_running_service = NavigationInstance.instance.getCurrentlyPlayingServiceOrGroup()
-                               Screens.Standby.inStandby.paused_service = None
-                               NavigationInstance.instance.stopService()
-                               self.log(5, "stopped service in standby")
                        if self.always_zap:
                                if Screens.Standby.inStandby:
-                                       self.wasInStandby = True
-                                       eActionMap.getInstance().bindAction('', -maxint - 1, self.keypress)
+                                       if not config.misc.standbyCounter.value:
+                                               self.wasInStandby = True
+                                               eActionMap.getInstance().bindAction('', -maxint - 1, self.keypress)
                                        #set service to zap after standby
                                        Screens.Standby.inStandby.prev_running_service = self.service_ref.ref
                                        Screens.Standby.inStandby.paused_service = None
@@ -326,8 +322,9 @@ class RecordTimerEntry(timer.TimerEntry, object):
                                return True
                        if self.justplay:
                                if Screens.Standby.inStandby:
-                                       self.wasInStandby = True
-                                       eActionMap.getInstance().bindAction('', -maxint - 1, self.keypress)
+                                       if not config.misc.standbyCounter.value:
+                                               self.wasInStandby = True
+                                               eActionMap.getInstance().bindAction('', -maxint - 1, self.keypress)
                                        self.log(11, "wakeup and zap")
                                        #set service to zap after standby
                                        Screens.Standby.inStandby.prev_running_service = self.service_ref.ref
@@ -720,6 +717,15 @@ class RecordTimer(timer.Timer):
                        return next_act
                return -1
 
+       def getNextTimerTime(self):
+               now = time()
+               for timer in self.timer_list:
+                       next_act = timer.getNextActivation()
+                       if next_act < now:
+                               continue
+                       return next_act
+               return -1
+
        def isNextRecordAfterEventActionAuto(self):
                now = time()
                t = None