From: James Hutchinson Date: Sun, 26 Sep 2021 18:30:40 +0000 (+0100) Subject: opentv: fix incorrect summaries for skyuk epg, fixes #5995 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ee9c5b9cc516d37cb55a9d924a4ca854a64f720;p=thirdparty%2Ftvheadend.git opentv: fix incorrect summaries for skyuk epg, fixes #5995 Events within the OpenTV SkyUK data can contain the same Event ID as another event on a different channel. This resulted in missing or incorrect summary data, since matching was based solely on the Event ID. This commit adjusts the opentv _entry_cmp function to match based on a combination of Event ID and Channel ID. This enables the RB_FIND & RB_INSERT_SORTED functions used within the OpenTV module to reliably insert and uniquely find the correct entry. --- diff --git a/src/epggrab/module/opentv.c b/src/epggrab/module/opentv.c index fa73927c6..308e49d8c 100644 --- a/src/epggrab/module/opentv.c +++ b/src/epggrab/module/opentv.c @@ -140,6 +140,7 @@ typedef struct opentv_event char *desc; ///< Event description uint8_t cat; ///< Event category uint16_t serieslink; ///< Series link ID + int cid; ///< Channel ID } opentv_event_t; /* Queued (unresolved) event entry */ @@ -202,20 +203,28 @@ static void _opentv_event_free(opentv_event_t *ev) free(ev->desc); } -/* Compare event id codes */ +/* Compare event id and channel id codes */ static int _entry_cmp ( void *a, void *b ) { - return (int)(((opentv_entry_t*)a)->event.eid) - - (int)(((opentv_entry_t*)b)->event.eid); + int eid_cmp, cid_cmp; + + eid_cmp = (int)(((opentv_entry_t*)a)->event.eid) - + (int)(((opentv_entry_t*)b)->event.eid); + + cid_cmp = ((opentv_entry_t*)a)->event.cid - + ((opentv_entry_t*)b)->event.cid; + + return eid_cmp != 0 ? eid_cmp : cid_cmp; } /* Find event entry */ -static opentv_entry_t *opentv_find_entry(opentv_status_t *sta, uint16_t eid) +static opentv_entry_t *opentv_find_entry(opentv_status_t *sta, uint16_t eid, int cid) { opentv_entry_t *oe, _tmp; if (sta == NULL) return NULL; _tmp.event.eid = eid; + _tmp.event.cid = cid; oe = RB_FIND(&sta->os_entries, &_tmp, link, _entry_cmp); return oe; } @@ -341,6 +350,7 @@ static int _opentv_parse_event } ev->eid = ((uint16_t)buf[0] << 8) | buf[1]; + ev->cid = cid; /* Process records */ while (i < slen+4) { @@ -503,7 +513,7 @@ opentv_parse_event_section_one if (ebc) { save |= opentv_do_event(mod, ebc, &ev, ch, lang, &changes); if (!merge) { - entry = opentv_find_entry(mod->sta, ev.eid); + entry = opentv_find_entry(mod->sta, ev.eid, cid); if (entry) { save |= opentv_do_event(mod, ebc, &entry->event, ch, lang, &changes); opentv_remove_entry(mod->sta, entry);