]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
timerec: fix 20:40 ... 00:40 case, fixes #3662
authorJaroslav Kysela <perex@perex.cz>
Sun, 27 Mar 2016 18:02:46 +0000 (20:02 +0200)
committerJaroslav Kysela <perex@perex.cz>
Sun, 27 Mar 2016 18:02:46 +0000 (20:02 +0200)
src/dvr/dvr_timerec.c

index c75510e88d97c1da84588c7541a08d5be29ea7bb..7da367bd94eca7c96f9a1c8f07d7f996f8a6638d 100644 (file)
@@ -105,7 +105,7 @@ void
 dvr_timerec_check(dvr_timerec_entry_t *dte)
 {
   dvr_entry_t *de;
-  time_t start, stop, limit;
+  time_t clk, start, stop, limit;
   struct tm tm_start, tm_stop;
   const char *title;
   char buf[200];
@@ -119,22 +119,21 @@ dvr_timerec_check(dvr_timerec_entry_t *dte)
   if(dte->dte_channel == NULL)
     goto fail;
 
-  limit = gclk() - 600;
-  start = dvr_timerec_timecorrection(gclk(), dte->dte_start, &tm_start);
-  stop  = dvr_timerec_timecorrection(gclk(), dte->dte_stop,  &tm_stop);
+  clk   = gclk();
+  limit = clk - 600;
+  start = dvr_timerec_timecorrection(clk, dte->dte_start, &tm_start);
+  stop  = dvr_timerec_timecorrection(clk, dte->dte_stop,  &tm_stop);
   if (start < limit && stop < limit) {
     /* next day */
-    start = dvr_timerec_timecorrection(gclk() + 24*60*60,
-                                       dte->dte_start,
-                                       &tm_start);
-    stop  = dvr_timerec_timecorrection(gclk() + 24*60*60,
-                                       dte->dte_stop,
-                                       &tm_stop);
+    clk += 24*60*60;
+    start = dvr_timerec_timecorrection(clk, dte->dte_start, &tm_start);
+    stop  = dvr_timerec_timecorrection(clk, dte->dte_stop, &tm_stop);
   }
   /* day boundary correction */
-  if (start > stop)
-    stop += 24 * 60 * 60;
-  assert(start <= stop);
+  while (start > stop) {
+    clk += 24*60*60;
+    stop = dvr_timerec_timecorrection(clk, dte->dte_stop, &tm_stop);
+  }
 
   if(dte->dte_weekdays != 0x7f) {
     localtime_r(&start, &tm_start);