From: Jaroslav Kysela Date: Sun, 3 Jan 2016 09:43:53 +0000 (+0100) Subject: timeshift: remove rdwr_mutex X-Git-Tag: v4.2.1~1242 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e4788aee498fecc706bd88dd75a56b5911c419ca;p=thirdparty%2Ftvheadend.git timeshift: remove rdwr_mutex --- diff --git a/src/timeshift.c b/src/timeshift.c index 987fa81db..19e956426 100644 --- a/src/timeshift.c +++ b/src/timeshift.c @@ -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 */ diff --git a/src/timeshift/private.h b/src/timeshift/private.h index 12d1fdf02..cce7feee6 100644 --- a/src/timeshift/private.h +++ b/src/timeshift/private.h @@ -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 diff --git a/src/timeshift/timeshift_reader.c b/src/timeshift/timeshift_reader.c index c75412905..4efbe49f1 100644 --- a/src/timeshift/timeshift_reader.c +++ b/src/timeshift/timeshift_reader.c @@ -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 */ diff --git a/src/timeshift/timeshift_writer.c b/src/timeshift/timeshift_writer.c index b0fb8600c..ec0e47141 100644 --- a/src/timeshift/timeshift_writer.c +++ b/src/timeshift/timeshift_writer.c @@ -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; }