Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
DVR: change 'warming up' behaviour - do not save anything before real…
… time (start-time minus extra-time-pre) occurs
  • Loading branch information
perexg committed Nov 24, 2015
1 parent 0b8e0a6 commit cae3296
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/dvr/dvr.h
Expand Up @@ -439,7 +439,7 @@ uint32_t dvr_entry_get_rerecord_errors( dvr_entry_t *de );

int dvr_entry_get_epg_running( dvr_entry_t *de );

time_t dvr_entry_get_start_time( dvr_entry_t *de );
time_t dvr_entry_get_start_time( dvr_entry_t *de, int warm );

time_t dvr_entry_get_stop_time( dvr_entry_t *de );

Expand Down
20 changes: 10 additions & 10 deletions src/dvr/dvr_db.c
Expand Up @@ -212,10 +212,10 @@ dvr_entry_warm_time( dvr_entry_t *de )
}

time_t
dvr_entry_get_start_time( dvr_entry_t *de )
dvr_entry_get_start_time( dvr_entry_t *de, int warm )
{
return de->de_start - (60 * dvr_entry_get_extra_time_pre(de)) -
dvr_entry_warm_time(de);
(warm ? dvr_entry_warm_time(de) : 0);
}

time_t
Expand Down Expand Up @@ -313,7 +313,7 @@ dvr_dbus_timer_cb( void *aux )
LIST_FOREACH(de, &dvrentries, de_global_link) {
if (de->de_sched_state != DVR_SCHEDULED)
continue;
start = dvr_entry_get_start_time(de);
start = dvr_entry_get_start_time(de, 1);
if (dispatch_clock < start && start > max)
max = start;
}
Expand All @@ -322,7 +322,7 @@ dvr_dbus_timer_cb( void *aux )
LIST_FOREACH(de, &dvrentries, de_global_link) {
if (de->de_sched_state != DVR_SCHEDULED)
continue;
start = dvr_entry_get_start_time(de);
start = dvr_entry_get_start_time(de, 1);
if (dispatch_clock < start && start < result)
result = start;
}
Expand Down Expand Up @@ -544,7 +544,7 @@ dvr_entry_set_timer(dvr_entry_t *de)

time(&now);

start = dvr_entry_get_start_time(de);
start = dvr_entry_get_start_time(de, 1);
stop = dvr_entry_get_stop_time(de);

if (now >= stop || de->de_dont_reschedule) {
Expand Down Expand Up @@ -809,7 +809,7 @@ dvr_entry_create_(int enabled, const char *config_uuid, epg_broadcast_t *e,
if (de == NULL)
return NULL;

t = dvr_entry_get_start_time(de);
t = dvr_entry_get_start_time(de, 1);
localtime_r(&t, &tm);
if (strftime(tbuf, sizeof(tbuf), "%F %T", &tm) <= 0)
*tbuf = 0;
Expand Down Expand Up @@ -1652,7 +1652,7 @@ void dvr_event_running(epg_broadcast_t *e, epg_source_t esrc, epg_running_t runn
channel_get_name(e->channel));
atomic_exchange_time_t(&de->de_running_start, dispatch_clock);
}
if (dvr_entry_get_start_time(de) > dispatch_clock) {
if (dvr_entry_get_start_time(de, 1) > dispatch_clock) {
atomic_exchange_time_t(&de->de_start, dispatch_clock);
dvr_entry_set_timer(de);
tvhdebug("dvr", "dvr entry %s event %s on %s - EPG start",
Expand Down Expand Up @@ -2465,7 +2465,7 @@ dvr_entry_class_start_real_get(void *o)
{
static time_t tm;
dvr_entry_t *de = (dvr_entry_t *)o;
tm = dvr_entry_get_start_time(de);
tm = dvr_entry_get_start_time(de, 1);
return &tm;
}

Expand All @@ -2484,7 +2484,7 @@ dvr_entry_class_duration_get(void *o)
static time_t tm;
time_t start, stop;
dvr_entry_t *de = (dvr_entry_t *)o;
start = dvr_entry_get_start_time(de);
start = dvr_entry_get_start_time(de, 0);
stop = dvr_entry_get_stop_time(de);
if (stop > start)
tm = stop - start;
Expand Down Expand Up @@ -3051,7 +3051,7 @@ dvr_entry_delete(dvr_entry_t *de, int no_missed_time_resched)
char tbuf[64], *rdir, *postcmd;
int r;

t = dvr_entry_get_start_time(de);
t = dvr_entry_get_start_time(de, 1);
localtime_r(&t, &tm);
if (strftime(tbuf, sizeof(tbuf), "%F %T", &tm) <= 0)
*tbuf = 0;
Expand Down
9 changes: 5 additions & 4 deletions src/dvr/dvr_rec.c
Expand Up @@ -361,7 +361,7 @@ static const char *
dvr_sub_start(const char *id, const void *aux, char *tmp, size_t tmplen)
{
char buf[16];
snprintf(buf, sizeof(buf), "%"PRItime_t, (time_t)dvr_entry_get_start_time((dvr_entry_t *)aux));
snprintf(buf, sizeof(buf), "%"PRItime_t, (time_t)dvr_entry_get_start_time((dvr_entry_t *)aux, 0));
return dvr_do_prefix(id, buf, tmp, tmplen);
}

Expand Down Expand Up @@ -1212,14 +1212,15 @@ dvr_thread(void *aux)
int commercial = COMMERCIAL_UNKNOWN;
int running_disabled;
int64_t packets = 0, dts_offset = PTS_UNSET;
time_t start_time = 0, running_start = 0, running_stop = 0;
time_t real_start, start_time = 0, running_start = 0, running_stop = 0;
char *postproc;

if (!dvr_thread_global_lock(de, &run))
return NULL;
comm_skip = de->de_config->dvr_skip_commercials;
postproc = de->de_config->dvr_postproc ? strdup(de->de_config->dvr_postproc) : NULL;
running_disabled = dvr_entry_get_epg_running(de) <= 0;
real_start = dvr_entry_get_start_time(de, 0);
dvr_thread_global_unlock(de);

TAILQ_INIT(&backlog);
Expand All @@ -1234,7 +1235,7 @@ dvr_thread(void *aux)
streaming_queue_remove(sq, sm);

if (running_disabled) {
epg_running = 1;
epg_running = real_start <= dispatch_clock;
} else if (sm->sm_type == SMT_PACKET || sm->sm_type == SMT_MPEGTS) {
running_start = atomic_add_time_t(&de->de_running_start, 0);
running_stop = atomic_add_time_t(&de->de_running_stop, 0);
Expand All @@ -1249,7 +1250,7 @@ dvr_thread(void *aux)
} else {
if (TAILQ_FIRST(&backlog))
streaming_queue_clear(&backlog);
epg_running = 1;
epg_running = real_start <= dispatch_clock;
}
} else {
epg_running = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/webui/simpleui.c
Expand Up @@ -531,7 +531,7 @@ page_status(http_connection_t *hc,

if (DVR_SCHEDULED == de->de_sched_state)
{
timelefttemp = (int) ((dvr_entry_get_start_time(de) - now) / 60); // output minutes
timelefttemp = (int) ((dvr_entry_get_start_time(de, 0) - now) / 60); // output minutes
if (timelefttemp < timeleft)
timeleft = timelefttemp;
}
Expand Down
4 changes: 2 additions & 2 deletions src/webui/webui.c
Expand Up @@ -853,7 +853,7 @@ http_dvr_list_playlist(http_connection_t *hc, int pltype)
http_access_verify_channel(hc, ACCESS_RECORDER, de->de_channel))
continue;

durration = dvr_entry_get_stop_time(de) - dvr_entry_get_start_time(de);
durration = dvr_entry_get_stop_time(de) - dvr_entry_get_start_time(de, 0);
bandwidth = ((8*fsize) / (durration*1024.0));
strftime(buf, sizeof(buf), "%FT%T%z", localtime_r(&(de->de_start), &tm));

Expand Down Expand Up @@ -898,7 +898,7 @@ http_dvr_playlist(http_connection_t *hc, int pltype, dvr_entry_t *de)
return HTTP_STATUS_NOT_FOUND;

hostpath = http_get_hostpath(hc);
durration = dvr_entry_get_stop_time(de) - dvr_entry_get_start_time(de);
durration = dvr_entry_get_stop_time(de) - dvr_entry_get_start_time(de, 0);
fsize = dvr_get_filesize(de);

if(fsize) {
Expand Down

0 comments on commit cae3296

Please sign in to comment.