Much simpler and improved algorithm for detecting overlapping events.

This version also solves a problem where the DVR database gets
corrupted when autorecs exist for two sequential events.
This commit is contained in:
Chris 2011-09-28 20:30:14 +10:00
parent c88a64692c
commit 1fe5260368
2 changed files with 16 additions and 10 deletions

View file

@ -747,10 +747,14 @@ dvr_entry_t *
dvr_entry_find_by_event_fuzzy(event_t *e)
{
dvr_entry_t *de;
if (e->e_title == NULL)
return NULL;
LIST_FOREACH(de, &e->e_channel->ch_dvrs, de_channel_link)
if (abs(de->de_start - e->e_start) < 600 && abs(de->de_stop - e->e_stop) < 600)
return de;
if ((abs(de->de_start - e->e_start) < 600) && (abs(de->de_stop - e->e_stop) < 600)) {
return de;
}
return NULL;
}

View file

@ -458,16 +458,18 @@ epg_erase_duplicates(event_t *e, channel_t *ch) {
static int
epg_event_cmp_overlap(event_t *e1, event_t *e2)
{
int dur_a, dur_b, mindur;
if ((e1->e_title == NULL) || (e2->e_title == NULL))
return 0;
if ((e1->e_stop < e2->e_start) || (e2->e_stop < e1->e_start)) {
return 0;
} else {
if ((e1->e_start < e2->e_stop) && (e2->e_start < e1->e_stop)) {
if ((e1->e_stop - e2->e_start) > 60 || (e2->e_stop - e1->e_start) > 60)
return 1;
}
dur_a = e1->e_stop - e1->e_start;
dur_b = e2->e_stop - e2->e_start;
mindur = dur_a < dur_b ? dur_a : dur_b;
if ((abs(e1->e_start - e2->e_start) < mindur) && (abs(e1->e_stop - e2->e_stop) < mindur)) {
return 1;
}
return 0;