]> 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:32:07 +0000 (19:32 +0100)
src/dvr/dvr_db.c
src/epg.c
src/epg.h

index 302a42a9d4f4ac566f1d32abe9c7daad197da5d8..1ff3db5015ae1bd234156da18ed2470205fe24d5 100644 (file)
@@ -2464,6 +2464,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 7b5860333f7d6e72835e222953327318bbca0f45..e64a9d1e147256471730bca22818ba70f76d7b88 100644 (file)
--- a/src/epg.c
+++ b/src/epg.c
@@ -1453,10 +1453,16 @@ int epg_broadcast_set_first_aired
   return 0;
 }
 
-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 ba53c6c9594351d09c6106675694dc0bb5c1936e..84d872c4b743e98de666cf998509303da0886949 100644 (file)
--- a/src/epg.h
+++ b/src/epg.h
@@ -417,7 +417,8 @@ int epg_broadcast_set_age_rating
   __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