From: Jaroslav Kysela Date: Wed, 30 Dec 2015 18:58:46 +0000 (+0100) Subject: timeshift: remove buffering_mutex - state_mutex protection is fine X-Git-Tag: v4.2.1~1266 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=41279efbb4e76c1fbcc71e0f183d6e92d27a5d6a;p=thirdparty%2Ftvheadend.git timeshift: remove buffering_mutex - state_mutex protection is fine --- diff --git a/src/timeshift.c b/src/timeshift.c index f99798bec..e4aa79c06 100644 --- a/src/timeshift.c +++ b/src/timeshift.c @@ -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); diff --git a/src/timeshift/private.h b/src/timeshift/private.h index 56fd91071..35f0a9a83 100644 --- a/src/timeshift/private.h +++ b/src/timeshift/private.h @@ -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, diff --git a/src/timeshift/timeshift_reader.c b/src/timeshift/timeshift_reader.c index d9e2c6ef7..1c924703a 100644 --- a/src/timeshift/timeshift_reader.c +++ b/src/timeshift/timeshift_reader.c @@ -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) {