]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
DVR: try to fix the late running flag update, issue #4958
authorJaroslav Kysela <perex@perex.cz>
Sat, 24 Feb 2018 18:25:51 +0000 (19:25 +0100)
committerJaroslav Kysela <perex@perex.cz>
Sat, 24 Feb 2018 18:31:31 +0000 (19:31 +0100)
src/dvr/dvr_db.c
src/epg.c
src/epg.h

index 983070928c701e583fd0720da6c98daba8f94bc9..fd857f00969eb6547f341053927c024cd2d463d5 100644 (file)
@@ -2264,6 +2264,17 @@ dvr_entry_start_recording(dvr_entry_t *de, int clone)
   tvhinfo(LS_DVR, "\"%s\" on \"%s\" recorder starting",
          lang_str_get(de->de_title, NULL), DVR_CH_NAME(de));
 
+  /*
+   * The running flag is updated only on the event change. When the DVR
+   * entry is added too late, the running timers might not be updated.
+   */
+  if (de->de_bcast && de->de_running_start == 0 && de->de_running_stop == 0) {
+    epg_broadcast_t *ebc = epg_broadcast_get_prev(de->de_bcast);
+    if (de->de_bcast->running != EPG_RUNNING_NOTSET ||
+        (ebc && ebc->running != EPG_RUNNING_NOTSET))
+      de->de_running_stop = gclk();
+  }
+
   if (!clone && (r = dvr_rec_subscribe(de)) < 0) {
     dvr_entry_completed(de, r == -EPERM ? SM_CODE_USER_ACCESS :
                            (r == -EOVERFLOW ? SM_CODE_USER_LIMIT :
index 5ede01463a2ef17dbf18eb31bd9512b3dc80d050..c26c913bbdb4971198e54d90a54dd67f376669f4 100644 (file)
--- a/src/epg.c
+++ b/src/epg.c
@@ -2108,10 +2108,16 @@ int epg_broadcast_set_description
                                   changed, EPG_CHANGED_DESCRIPTION);
 }
 
-epg_broadcast_t *epg_broadcast_get_next ( epg_broadcast_t *broadcast )
+epg_broadcast_t *epg_broadcast_get_prev ( epg_broadcast_t *b )
 {
-  if ( !broadcast ) return NULL;
-  return RB_NEXT(broadcast, sched_link);
+  if (!b) return NULL;
+  return RB_PREV(b, sched_link);
+}
+
+epg_broadcast_t *epg_broadcast_get_next ( epg_broadcast_t *b )
+{
+  if (!b) return NULL;
+  return RB_NEXT(b, sched_link);
 }
 
 const char *epg_broadcast_get_title ( epg_broadcast_t *b, const char *lang )
index 4d2d65e5bd669989abcaa614c3bebda4d15e6aa6..65b673faa5e1763d8b16c0b36fb774d9b99d999f 100644 (file)
--- a/src/epg.h
+++ b/src/epg.h
@@ -583,7 +583,8 @@ int epg_broadcast_set_serieslink
   __attribute__((warn_unused_result));
 
 /* Accessors */
-epg_broadcast_t *epg_broadcast_get_next    ( epg_broadcast_t *b );
+epg_broadcast_t *epg_broadcast_get_prev( epg_broadcast_t *b );
+epg_broadcast_t *epg_broadcast_get_next( epg_broadcast_t *b );
 const char *epg_broadcast_get_title 
   ( epg_broadcast_t *b, const char *lang );
 const char *epg_broadcast_get_subtitle