]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
timeshift: remove rdwr_mutex
authorJaroslav Kysela <perex@perex.cz>
Sun, 3 Jan 2016 09:43:53 +0000 (10:43 +0100)
committerJaroslav Kysela <perex@perex.cz>
Sun, 3 Jan 2016 09:43:53 +0000 (10:43 +0100)
src/timeshift.c
src/timeshift/private.h
src/timeshift/timeshift_reader.c
src/timeshift/timeshift_writer.c

index 987fa81db92725d09ddea119dcaee496d75c05b8..19e956426c7e67b559692be7482a5b4f88b27b80 100644 (file)
@@ -515,7 +515,6 @@ streaming_target_t *timeshift_create
   ts->ref_time   = 0;
   for (i = 0; i < TIMESHIFT_BACKLOG_MAX; i++)
     TAILQ_INIT(&ts->backlog[i]);
-  pthread_mutex_init(&ts->rdwr_mutex, NULL);
   pthread_mutex_init(&ts->state_mutex, NULL);
 
   /* Initialise output */
index 12d1fdf02511b36ee74e74d49658cb5bf1298993..cce7feee61dfc81010dca1e40015d4788e64e558 100644 (file)
@@ -117,7 +117,6 @@ typedef struct timeshift {
   pthread_t                   rd_thread;  ///< Reader thread
   th_pipe_t                   rd_pipe;    ///< Message passing to reader
 
-  pthread_mutex_t             rdwr_mutex; ///< Buffer protection
   timeshift_file_list_t       files;      ///< List of files
 
   int                         vididx;     ///< Index of (current) video stream
index c75412905a27817a2b4c169b02b37b9bc3bc3569..4efbe49f1b09d0885aef8bf590a959952dbb9372 100644 (file)
@@ -343,11 +343,9 @@ static int _timeshift_do_skip
 
   /* Find */
   cur_file = *_cur_file;
-  pthread_mutex_lock(&ts->rdwr_mutex);
   end = _timeshift_skip(ts, req_time, last_time,
                         cur_file, &tsf, _tsi);
   tsi = *_tsi;
-  pthread_mutex_unlock(&ts->rdwr_mutex);
   if (tsi)
     tvhlog(LOG_DEBUG, "timeshift", "ts %d skip found pkt @ %"PRId64,
            ts->id, tsi->time);
@@ -417,9 +415,7 @@ static int _timeshift_read
       if (tsf->rfd >= 0)
         close(tsf->rfd);
       tsf->rfd  = -1;
-      pthread_mutex_lock(&ts->rdwr_mutex);
       *cur_file = tsf = timeshift_filemgr_next(tsf, NULL, 0);
-      pthread_mutex_unlock(&ts->rdwr_mutex);
       if (tsf)
         tsf->roff = 0; // reset
       *wait     = 0;
@@ -633,7 +629,6 @@ void *timeshift_reader ( void *p )
                 timeshift_writer_flush(ts);
                 ts->dobuf = 1;
                 skip_delivered = 1;
-                pthread_mutex_lock(&ts->rdwr_mutex);
                 tmp_file = timeshift_filemgr_newest(ts);
                 if (tmp_file != NULL) {
                   i64 = tmp_file->last;
@@ -650,7 +645,6 @@ void *timeshift_reader ( void *p )
                   pause_time     = i64;
                   last_time      = pause_time;
                 }
-                pthread_mutex_unlock(&ts->rdwr_mutex);
               }
             }
 
@@ -695,10 +689,8 @@ void *timeshift_reader ( void *p )
 
                 /* Reset */
                 if (ts->full) {
-                  pthread_mutex_lock(&ts->rdwr_mutex);
                   timeshift_filemgr_flush(ts, NULL);
                   ts->full = 0;
-                  pthread_mutex_unlock(&ts->rdwr_mutex);
                 }
 
                 /* Release */
@@ -721,7 +713,6 @@ void *timeshift_reader ( void *p )
 
               /* Live playback (stage1) */
               if (ts->state == TS_LIVE) {
-                pthread_mutex_lock(&ts->rdwr_mutex);
                 tmp_file = timeshift_filemgr_newest(ts);
                 if (tmp_file) {
                   i64 = tmp_file->last;
@@ -734,7 +725,6 @@ void *timeshift_reader ( void *p )
                   last_time      = ts->last_time;
                 }
                 skip_delivered = 0;
-                pthread_mutex_unlock(&ts->rdwr_mutex);
               }
 
               /* May have failed */
index b0fb8600ce0df7d0618f9a10377e950b67a897e4..ec0e47141bf8575c7a7feb3545cd327f81fa45ea 100644 (file)
@@ -348,7 +348,7 @@ static void _process_msg
     case SMT_START:
     case SMT_MPEGTS:
     case SMT_PACKET:
-      pthread_mutex_lock(&ts->rdwr_mutex);
+      pthread_mutex_lock(&ts->state_mutex);
       if ((tsf = timeshift_filemgr_get(ts, sm->sm_time)) && (tsf->wfd >= 0 || tsf->ram)) {
         if ((err = _process_msg0(ts, tsf, &sm)) < 0) {
           timeshift_filemgr_close(tsf);
@@ -357,7 +357,7 @@ static void _process_msg
         }
         tsf->refcount--;
       }
-      pthread_mutex_unlock(&ts->rdwr_mutex);
+      pthread_mutex_unlock(&ts->state_mutex);
       break;
   }