Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
DVR/EPG: improve the running check conditions, fixes #3268
  • Loading branch information
perexg committed Nov 5, 2015
1 parent 190bdf7 commit c266bce
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
21 changes: 14 additions & 7 deletions src/dvr/dvr_db.c
Expand Up @@ -1624,12 +1624,13 @@ void dvr_event_running(epg_broadcast_t *e, epg_source_t esrc, int running)
continue;
}
if (running && de->de_dvb_eid == e->dvb_eid) {
if (!de->de_running_start)
if (!de->de_running_start) {
tvhdebug("dvr", "dvr entry %s event %s on %s - EPG marking start",
idnode_uuid_as_sstr(&de->de_id),
epg_broadcast_get_title(e, NULL),
channel_get_name(e->channel));
de->de_running_start = dispatch_clock;
de->de_running_start = dispatch_clock;
}
if (dvr_entry_get_start_time(de) > dispatch_clock) {
de->de_start = dispatch_clock;
dvr_entry_set_timer(de);
Expand All @@ -1639,6 +1640,14 @@ void dvr_event_running(epg_broadcast_t *e, epg_source_t esrc, int running)
channel_get_name(e->channel));
}
} else if ((!running && de->de_dvb_eid == e->dvb_eid) || running) {
/*
* make checking more robust
* sometimes, the running bits are parsed randomly for a few moments
* so don't expect that the broacasting has only 5 seconds
*/
if (de->de_running_start + 5 > dispatch_clock)
continue;

srcname = de->de_dvb_eid == e->dvb_eid ? "event" : "other running event";
if (!de->de_running_stop ||
de->de_running_start > de->de_running_stop) {
Expand All @@ -1649,14 +1658,12 @@ void dvr_event_running(epg_broadcast_t *e, epg_source_t esrc, int running)
}
de->de_running_stop = dispatch_clock;
if (de->de_sched_state == DVR_RECORDING && de->de_running_start) {
if (dvr_entry_get_stop_time(de) > dispatch_clock) {
de->de_dont_reschedule = 1;
dvr_stop_recording(de, SM_CODE_OK, 0, 0);
tvhdebug("dvr", "dvr entry %s %s %s on %s - EPG stop",
de->de_dont_reschedule = 1;
dvr_stop_recording(de, SM_CODE_OK, 0, 0);
tvhdebug("dvr", "dvr entry %s %s %s on %s - EPG stop",
idnode_uuid_as_sstr(&de->de_id), srcname,
epg_broadcast_get_title(e, NULL),
channel_get_name(de->de_channel));
}
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions src/epg.c
Expand Up @@ -1689,16 +1689,18 @@ void epg_broadcast_notify_running
{
channel_t *ch;
epg_broadcast_t *now;
int orunning = broadcast->running;

broadcast->running = !!running;
ch = broadcast->channel;
now = ch ? ch->ch_epg_now : NULL;
if (!running) {
broadcast->stop = dispatch_clock - 1;
if (now == broadcast && orunning == broadcast->running)
broadcast->stop = dispatch_clock - 1;
} else {
ch = broadcast->channel;
now = ch ? ch->ch_epg_now : NULL;
if (broadcast != now && now) {
now->running = 0;
dvr_event_running(ch->ch_epg_now, esrc, 0);
dvr_event_running(now, esrc, 0);
}
}
dvr_event_running(broadcast, esrc, running);
Expand Down

0 comments on commit c266bce

Please sign in to comment.