From a227ef5f6dad59690ea337d40f451aa4cac3d2fd Mon Sep 17 00:00:00 2001 From: satbaby Date: Fri, 11 May 2012 12:00:52 +0200 Subject: [PATCH] sectionsd.cpp:sort unique search-eventlist --- src/eitd/sectionsd.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/eitd/sectionsd.cpp b/src/eitd/sectionsd.cpp index 3e8246fa3..056a05d5f 100644 --- a/src/eitd/sectionsd.cpp +++ b/src/eitd/sectionsd.cpp @@ -2176,6 +2176,17 @@ printf("SIevent size: %d\n", sizeof(SIevent)); } /* was: commandAllEventsChannelID sendAllEvents */ +inline static bool sortbyEventid (const CChannelEvent& a, const CChannelEvent& b) +{ + return (a.channelID == b.channelID && a.eventID == b.eventID); + +} + +inline static bool sortByDateTime (const CChannelEvent& a, const CChannelEvent& b) +{ + return a.startTime < b.startTime; +} + void sectionsd_getEventsServiceKey(t_channel_id serviceUniqueKey, CChannelEventList &eList, char search = 0, std::string search_text = "") { dprintf("sendAllEvents for " PRINTF_CHANNEL_ID_TYPE "\n", serviceUniqueKey); @@ -2233,7 +2244,11 @@ void sectionsd_getEventsServiceKey(t_channel_id serviceUniqueKey, CChannelEventL else if ( serviceIDfound ) break; // sind nach serviceID und startzeit sortiert -> nicht weiter suchen } - + if(!eList.empty()){ + sort(eList.begin(),eList.end(),sortByDateTime); + unique(eList.begin(),eList.end(),sortbyEventid); + eList.erase(unique(eList.begin(),eList.end(),sortbyEventid),eList.end()); + } unlockEvents(); } }