remove workaround
[enigma2.git] / lib / dvb / epgcache.cpp
index fb121ae8e4dbadfe32546891e45ed8ab9a8a31ba..2871880058a31d0713235d8af96ed0fca9d535d8 100644 (file)
@@ -1008,10 +1008,25 @@ RESULT eEPGCache::lookupEventTime(const eServiceReference &service, time_t t, co
        {
                if (!t)
                        t = time(0)+eDVBLocalTimeHandler::getInstance()->difference();
-
-               timeMap::iterator i = It->second.second.lower_bound(t);
-               if ( i != It->second.second.end() && t <= i->first+i->second->getDuration() )
+               timeMap::iterator i = It->second.second.lower_bound(t);  // find > or equal
+               if ( i != It->second.second.end() )
                {
+                       if ( i->second->getStartTime() != t )
+                       {
+                               timeMap::iterator x = i;
+                               --x;
+                               if ( x != It->second.second.end() )
+                               {
+                                       time_t start_time = x->second->getStartTime();
+                                       if (t < start_time)
+                                               return -1;
+                                       if (t > (start_time+x->second->getDuration()))
+                                               return -1;
+                                       i = x;
+                               }
+                               else
+                                       return -1;
+                       }
                        result = i->second;
                        return 0;
                }
@@ -1121,12 +1136,19 @@ RESULT eEPGCache::startTimeQuery(const eServiceReference &service, time_t begin,
                if ( begin != -1 )
                {
                        m_timemap_cursor = It->second.second.lower_bound(begin);
-                       if ( m_timemap_cursor != It->second.second.end() && m_timemap_cursor != It->second.second.begin() )
+                       if ( m_timemap_cursor != It->second.second.end() )
                        {
-                               timeMap::iterator it = m_timemap_cursor;
-                               --it;
-                               if ( (it->second->getStartTime() + it->second->getDuration()) > begin )
-                                       m_timemap_cursor = it;
+                               if ( m_timemap_cursor->second->getStartTime() != begin )
+                               {
+                                       timeMap::iterator x = m_timemap_cursor;
+                                       --x;
+                                       if ( x != It->second.second.end() )
+                                       {
+                                               time_t start_time = x->second->getStartTime();
+                                               if ( begin > start_time && begin < (start_time+x->second->getDuration()))
+                                                       m_timemap_cursor = x;
+                                       }
+                               }
                        }
                }
                else