]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
timeshift: change the on-demand purpose to allow rewind/goto back
authorJaroslav Kysela <perex@perex.cz>
Thu, 31 Dec 2015 10:50:21 +0000 (11:50 +0100)
committerJaroslav Kysela <perex@perex.cz>
Thu, 31 Dec 2015 10:50:21 +0000 (11:50 +0100)
src/timeshift.c
src/timeshift/private.h
src/timeshift/timeshift_reader.c

index 5d0a85993dca327bb4170a20593303059d945eb8..97f8c236d1b0a0388c3ec784074fbf73567d1755 100644 (file)
@@ -154,7 +154,9 @@ const idclass_t timeshift_conf_class = {
     {
       .type   = PT_BOOL,
       .id     = "ondemand",
-      .name   = N_("On-demand (no rewind)"),
+      .name   = N_("On-demand (no first rewind)"),
+      .desc   = N_("Use timeshift only on-demand. It is started when the first request "
+                   "to move in the playback time occurs (fast-forward, rewind, goto)."),
       .off    = offsetof(timeshift_conf_t, ondemand),
     },
     {
@@ -379,7 +381,7 @@ static void timeshift_input
       ts->packet_mode = 0;
 
     /* Buffer to disk */
-    if ((ts->state > TS_LIVE) || (!ts->ondemand && (ts->state == TS_LIVE))) {
+    if ((ts->state > TS_LIVE) || (ts->dobuf && (ts->state == TS_LIVE))) {
       if (ts->packet_mode) {
         sm->sm_time = ts->last_time;
         if (type == SMT_PACKET) {
@@ -493,6 +495,7 @@ streaming_target_t *timeshift_create
   ts->vididx     = -1;
   ts->id         = timeshift_index;
   ts->ondemand   = timeshift_conf.ondemand;
+  ts->dobuf      = ts->ondemand ? 0 : 1;
   ts->packet_mode= 1;
   ts->last_time  = 0;
   ts->start_pts  = 0;
index 35f0a9a83214e1fee12be6fa5d11de7913b60cf6..2a762eabb292d1912c6511f5a1bbc84eb5dc4c97 100644 (file)
@@ -92,6 +92,7 @@ typedef struct timeshift {
   time_t                      max_time;   ///< Maximum period to shift
   int                         ondemand;   ///< Whether this is an on-demand timeshift
   int                         packet_mode;///< Packet mode (otherwise MPEG-TS data mode)
+  int                         dobuf;      ///< Buffer packets (store)
   int64_t                     last_time;  ///< Last time in us (PTS conversion)
   int64_t                     start_pts;  ///< Start time for packets (PTS)
   int64_t                     ref_time;   ///< Start time in us (monoclock)
index f61ad42cbf471c61417ebfc9abbacd50a8b58b65..191b1e85ad43f7ace8e056d515403bbf5a78c9af 100644 (file)
@@ -617,7 +617,7 @@ void *timeshift_reader ( void *p )
           if (speed < -3200) speed = -3200;
 
           /* Ignore negative */
-          if (ts->ondemand && (speed < 0))
+          if (!ts->dobuf && (speed < 0))
             speed = cur_file ? speed : 0;
 
           /* Process */
@@ -637,6 +637,7 @@ void *timeshift_reader ( void *p )
                 tvhlog(LOG_DEBUG, "timeshift", "ts %d enter timeshift mode",
                        ts->id);
                 timeshift_writer_flush(ts);
+                ts->dobuf = 1;
                 pthread_mutex_lock(&ts->rdwr_mutex);
                 cur_file = timeshift_filemgr_newest(ts);
                 cur_file = timeshift_filemgr_get(ts, cur_file ? cur_file->last :
@@ -747,6 +748,7 @@ void *timeshift_reader ( void *p )
                     skip = NULL;
                   } else {
                     ts->state = TS_PLAY;
+                    ts->dobuf = 1;
                     tvhtrace("timeshift", "reader - set TS_PLAY");
                   }
                 }
@@ -924,10 +926,6 @@ void *timeshift_reader ( void *p )
           cur_file->rfd = -1;
         }
 
-        /* Flush ALL files */
-        if (ts->ondemand)
-          timeshift_filemgr_flush(ts, NULL);
-
       /* Pause */
       } else {
         if (cur_speed <= 0) {
@@ -938,6 +936,7 @@ void *timeshift_reader ( void *p )
           cur_speed = 100;
           tvhtrace("timeshift", "reader - set TS_PLAY");
           ts->state = TS_PLAY;
+          ts->dobuf = 1;
           if (mono_play_time != mono_now)
             tvhtrace("timeshift", "update play time (pause) - %"PRId64, mono_now);
           mono_play_time = mono_now;
@@ -949,11 +948,6 @@ void *timeshift_reader ( void *p )
         ctrl       = NULL;
       }
 
-    /* Flush unwanted */
-    } else if (ts->ondemand && cur_file) {
-      pthread_mutex_lock(&ts->rdwr_mutex);
-      timeshift_filemgr_flush(ts, cur_file);
-      pthread_mutex_unlock(&ts->rdwr_mutex);
     }
 
     pthread_mutex_unlock(&ts->state_mutex);