]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
timeshift: fix the NULL cur_file 'deadlock', change to live mode when end-of-buffers
authorJaroslav Kysela <perex@perex.cz>
Mon, 14 Dec 2015 08:53:52 +0000 (09:53 +0100)
committerJaroslav Kysela <perex@perex.cz>
Mon, 14 Dec 2015 08:54:44 +0000 (09:54 +0100)
src/timeshift/timeshift_reader.c

index b29718ac0091a5c3771bda642b6b1e1ef97ab3e5..9402174fc2c73f09116127bcce5795ef53cb8169 100644 (file)
@@ -251,7 +251,7 @@ static int _timeshift_skip
     timeshift_index_iframe_t **iframe )
 {
   timeshift_index_iframe_t *tsi  = *iframe;
-  timeshift_file_t         *tsf  = cur_file;
+  timeshift_file_t         *tsf  = cur_file, *tsf_last;
   int64_t                   sec  = req_time / (1000000 * TIMESHIFT_FILE_PERIOD);
   int                       back = (req_time < cur_time) ? 1 : 0;
   int                       end  = 0;
@@ -304,20 +304,26 @@ static int _timeshift_skip
   /* Find start/end of buffer */
   if (end) {
     if (back) {
-      tsf = timeshift_filemgr_oldest(ts);
+      tsf = tsf_last = timeshift_filemgr_oldest(ts);
       tsi = NULL;
       while (tsf && !tsi) {
+        tsf_last = tsf;
         if (!(tsi = TAILQ_FIRST(&tsf->iframes)))
           tsf = timeshift_filemgr_next(tsf, &end, 0);
       }
+      if (!tsf)
+        tsf = tsf_last;
       end = -1;
     } else {
-      tsf = timeshift_filemgr_get(ts, 0);
+      tsf = tsf_last = timeshift_filemgr_get(ts, 0);
       tsi = NULL;
       while (tsf && !tsi) {
+        tsf_last = tsf;
         if (!(tsi = TAILQ_LAST(&tsf->iframes, timeshift_index_iframe_list)))
           tsf = timeshift_filemgr_prev(tsf, &end, 0);
       }
+      if (!tsf)
+        tsf = tsf_last;
       end = 1;
     }
   }
@@ -503,7 +509,7 @@ void *timeshift_reader ( void *p )
 
           /* Ignore negative */
           if (ts->ondemand && (speed < 0))
-            speed = 0;
+            speed = cur_file ? speed : 0;
 
           /* Process */
           if (cur_speed != speed) {
@@ -758,7 +764,7 @@ void *timeshift_reader ( void *p )
         /* Report error */
         skip->type = SMT_SKIP_ERROR;
         skip       = NULL;
-        tvhlog(LOG_DEBUG, "timeshift", "ts %d skip failed", ts->id);
+        tvhlog(LOG_DEBUG, "timeshift", "ts %d skip failed (%d)", ts->id, sm ? sm->sm_type : -1);
       }
       streaming_target_deliver2(ts->output, ctrl);
       ctrl = NULL;
@@ -832,6 +838,7 @@ void *timeshift_reader ( void *p )
           cur_speed = 0;
           ts->state = TS_PAUSE;
         } else {
+          cur_speed = 100;
           ts->state = TS_PLAY;
           play_time = now;
         }