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 */
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
/* 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);
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;
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;
pause_time = i64;
last_time = pause_time;
}
- pthread_mutex_unlock(&ts->rdwr_mutex);
}
}
/* 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 */
/* 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;
last_time = ts->last_time;
}
skip_delivered = 0;
- pthread_mutex_unlock(&ts->rdwr_mutex);
}
/* May have failed */
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);
}
tsf->refcount--;
}
- pthread_mutex_unlock(&ts->rdwr_mutex);
+ pthread_mutex_unlock(&ts->state_mutex);
break;
}