From: Jaroslav Kysela Date: Thu, 31 Dec 2015 10:50:21 +0000 (+0100) Subject: timeshift: change the on-demand purpose to allow rewind/goto back X-Git-Tag: v4.2.1~1260 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=752b8f08605f182c5a0c26d0e203ba47f0aea87b;p=thirdparty%2Ftvheadend.git timeshift: change the on-demand purpose to allow rewind/goto back --- diff --git a/src/timeshift.c b/src/timeshift.c index 5d0a85993..97f8c236d 100644 --- a/src/timeshift.c +++ b/src/timeshift.c @@ -154,7 +154,9 @@ const idclass_t timeshift_conf_class = { { .type = PT_BOOL, .id = "ondemand", - .name = N_("On-demand (no rewind)"), + .name = N_("On-demand (no first rewind)"), + .desc = N_("Use timeshift only on-demand. It is started when the first request " + "to move in the playback time occurs (fast-forward, rewind, goto)."), .off = offsetof(timeshift_conf_t, ondemand), }, { @@ -379,7 +381,7 @@ static void timeshift_input ts->packet_mode = 0; /* Buffer to disk */ - if ((ts->state > TS_LIVE) || (!ts->ondemand && (ts->state == TS_LIVE))) { + if ((ts->state > TS_LIVE) || (ts->dobuf && (ts->state == TS_LIVE))) { if (ts->packet_mode) { sm->sm_time = ts->last_time; if (type == SMT_PACKET) { @@ -493,6 +495,7 @@ streaming_target_t *timeshift_create ts->vididx = -1; ts->id = timeshift_index; ts->ondemand = timeshift_conf.ondemand; + ts->dobuf = ts->ondemand ? 0 : 1; ts->packet_mode= 1; ts->last_time = 0; ts->start_pts = 0; diff --git a/src/timeshift/private.h b/src/timeshift/private.h index 35f0a9a83..2a762eabb 100644 --- a/src/timeshift/private.h +++ b/src/timeshift/private.h @@ -92,6 +92,7 @@ typedef struct timeshift { time_t max_time; ///< Maximum period to shift int ondemand; ///< Whether this is an on-demand timeshift int packet_mode;///< Packet mode (otherwise MPEG-TS data mode) + int dobuf; ///< Buffer packets (store) int64_t last_time; ///< Last time in us (PTS conversion) int64_t start_pts; ///< Start time for packets (PTS) int64_t ref_time; ///< Start time in us (monoclock) diff --git a/src/timeshift/timeshift_reader.c b/src/timeshift/timeshift_reader.c index f61ad42cb..191b1e85a 100644 --- a/src/timeshift/timeshift_reader.c +++ b/src/timeshift/timeshift_reader.c @@ -617,7 +617,7 @@ void *timeshift_reader ( void *p ) if (speed < -3200) speed = -3200; /* Ignore negative */ - if (ts->ondemand && (speed < 0)) + if (!ts->dobuf && (speed < 0)) speed = cur_file ? speed : 0; /* Process */ @@ -637,6 +637,7 @@ void *timeshift_reader ( void *p ) tvhlog(LOG_DEBUG, "timeshift", "ts %d enter timeshift mode", ts->id); timeshift_writer_flush(ts); + ts->dobuf = 1; pthread_mutex_lock(&ts->rdwr_mutex); cur_file = timeshift_filemgr_newest(ts); cur_file = timeshift_filemgr_get(ts, cur_file ? cur_file->last : @@ -747,6 +748,7 @@ void *timeshift_reader ( void *p ) skip = NULL; } else { ts->state = TS_PLAY; + ts->dobuf = 1; tvhtrace("timeshift", "reader - set TS_PLAY"); } } @@ -924,10 +926,6 @@ void *timeshift_reader ( void *p ) cur_file->rfd = -1; } - /* Flush ALL files */ - if (ts->ondemand) - timeshift_filemgr_flush(ts, NULL); - /* Pause */ } else { if (cur_speed <= 0) { @@ -938,6 +936,7 @@ void *timeshift_reader ( void *p ) cur_speed = 100; tvhtrace("timeshift", "reader - set TS_PLAY"); ts->state = TS_PLAY; + ts->dobuf = 1; if (mono_play_time != mono_now) tvhtrace("timeshift", "update play time (pause) - %"PRId64, mono_now); mono_play_time = mono_now; @@ -949,11 +948,6 @@ void *timeshift_reader ( void *p ) ctrl = NULL; } - /* Flush unwanted */ - } else if (ts->ondemand && cur_file) { - pthread_mutex_lock(&ts->rdwr_mutex); - timeshift_filemgr_flush(ts, cur_file); - pthread_mutex_unlock(&ts->rdwr_mutex); } pthread_mutex_unlock(&ts->state_mutex);