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;
}
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;