]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
timeshift: remove buffering_mutex - state_mutex protection is fine
authorJaroslav Kysela <perex@perex.cz>
Wed, 30 Dec 2015 18:58:46 +0000 (19:58 +0100)
committerJaroslav Kysela <perex@perex.cz>
Wed, 30 Dec 2015 18:58:46 +0000 (19:58 +0100)
src/timeshift.c
src/timeshift/private.h
src/timeshift/timeshift_reader.c

index f99798beced209631ffad0c34eaa3a7dc1d9bc7c..e4aa79c060b5c98b96b03f8e5de538c9a4fbddf8 100644 (file)
@@ -289,7 +289,7 @@ timeshift_packets_clone( timeshift_t *ts, struct streaming_message_queue *dst )
   struct streaming_message_queue *sq, *backlogs;
   int i;
 
-  lock_assert(&ts->buffering_mutex);
+  lock_assert(&ts->state_mutex);
 
   /* init temporary queues */
   backlogs = alloca(ts->backlog_max * sizeof(*backlogs));
@@ -340,8 +340,6 @@ static void timeshift_input
     if (type == SMT_START && ts->state == TS_INIT)
       ts->state = TS_LIVE;
 
-    pthread_mutex_lock(&ts->buffering_mutex);
-
     /* Change PTS/DTS offsets */
     if (ts->packet_mode && ts->start_pts && type == SMT_PACKET) {
       pkt2 = pkt_copy_shallow(pkt);
@@ -410,8 +408,6 @@ static void timeshift_input
     }
 pktcont:
 
-    pthread_mutex_unlock(&ts->buffering_mutex);
-
     /* Exit/Stop */
     if (exit) {
       timeshift_write_exit(ts->rd_pipe.wr);
@@ -501,7 +497,6 @@ streaming_target_t *timeshift_create
     TAILQ_INIT(&ts->backlog[i]);
   pthread_mutex_init(&ts->rdwr_mutex, NULL);
   pthread_mutex_init(&ts->state_mutex, NULL);
-  pthread_mutex_init(&ts->buffering_mutex, NULL);
 
   /* Initialise output */
   tvh_pipe(O_NONBLOCK, &ts->rd_pipe);
index 56fd91071cc9a80ffdd25b231013f6856b7c149d..35f0a9a83214e1fee12be6fa5d11de7913b60cf6 100644 (file)
@@ -97,7 +97,6 @@ typedef struct timeshift {
   int64_t                     ref_time;   ///< Start time in us (monoclock)
   struct streaming_message_queue backlog[TIMESHIFT_BACKLOG_MAX]; ///< Queued packets for time sorting
   int                         backlog_max;///< Maximum component index in backlog
-  pthread_mutex_t             buffering_mutex;///< Protect backlog / write queues
 
   enum {
     TS_INIT,
index d9e2c6ef7ba93652028f83a7e968ab9bb83b5ea9..1c924703a067d595ca4c42263a9c52e97af5152f 100644 (file)
@@ -757,10 +757,12 @@ void *timeshift_reader ( void *p )
                 end = _timeshift_do_skip(ts, skip_time, last_time, &cur_file, &tsi);
                 if (tsi) {
                   pause_time = tsi->time;
+                  tvhtrace("timeshift", "ts %d skip set pause_time %"PRId64" last_time %"PRId64,
+                           ts->id, pause_time, last_time);
 
                   /* Adjust time */
                   if (mono_play_time != mono_now)
-                    tvhtrace("timeshift", "update play time skip - %"PRId64, mono_now);
+                    tvhtrace("timeshift", "ts %d update play time skip - %"PRId64, ts->id, mono_now);
                   mono_play_time = mono_now;
 
                   /* Clear existing packet */
@@ -898,20 +900,14 @@ void *timeshift_reader ( void *p )
         ctrl      = NULL;
         tvhtrace("timeshift", "reader - set TS_LIVE");
 
-        /* Critical section - protect write / backlog queues */
-        pthread_mutex_lock(&ts->buffering_mutex);
-
         /* Flush timeshift buffer to live */
-        if (_timeshift_flush_to_live(ts, &cur_file, &sm, &wait) == -1) {
-          pthread_mutex_unlock(&ts->buffering_mutex);
+        if (_timeshift_flush_to_live(ts, &cur_file, &sm, &wait) == -1)
           break;
-        }
 
         /* Flush write / backlog queues */
         _timeshift_write_queues(ts);
         
         ts->state = TS_LIVE;
-        pthread_mutex_unlock(&ts->buffering_mutex);
 
         /* Close file (if open) */
         if (cur_file && cur_file->rfd >= 0) {