dvb/frontend: set sec once
[enigma2.git] / timer.py
index ff23b70d91808960f201b67a89918201ea869fd1..a230545df27d012a3fbd5b1178072955752c9faf 100644 (file)
--- a/timer.py
+++ b/timer.py
@@ -52,17 +52,19 @@ class Timer:
                
                self.timer = eTimer()
                self.timer.timeout.get().append(self.calcNextActivation)
+               self.lastActivation = time.time()
                
                self.calcNextActivation()
        
-       def addTimerEntry(self, entry):
+       def addTimerEntry(self, entry, noRecalc=0):
                # we either go trough Prepare/Start/End-state if the timer is still running,
                # or skip it when it's alrady past the end.
                if entry.end > time.time():
                        bisect.insort(self.timer_list, entry)
-                       self.calcNextActivation()
+                       if not noRecalc:
+                               self.calcNextActivation()
                else:
-                       bisect.insort(self.process_timers, entry)
+                       bisect.insort(self.processed_timers, entry)
        
        def setNextActivation(self, when):
                delay = int((when - time.time()) * 1000)
@@ -72,7 +74,15 @@ class Timer:
                self.next = when
 
        def calcNextActivation(self):
+               if self.lastActivation > time.time():
+                       print "[timer.py] timewarp - re-evaluating all processed timers."
+                       tl = self.processed_timers
+                       self.processed_timers = [ ]
+                       for x in tl:
+                               self.addTimerEntry(x, noRecalc=1)
+               
                self.processActivation()
+               self.lastActivation = time.time()
        
                min = int(time.time()) + self.MaxWaitTime
                
@@ -86,7 +96,7 @@ class Timer:
        
        def timeChanged(self, timer):
                self.timer_list.remove(timer)
-               bisect.insort(self.timer_list, timer)
+               self.addTimerEntry(timer)
        
        def doActivate(self, w):
                w.activate(w.state)