diff options
| author | Andreas Monzner <andreas.monzner@multimedia-labs.de> | 2006-01-04 23:18:09 +0000 |
|---|---|---|
| committer | Andreas Monzner <andreas.monzner@multimedia-labs.de> | 2006-01-04 23:18:09 +0000 |
| commit | 025ad01a86542cba4eaceabdde5bed9bf72c4344 (patch) | |
| tree | 049c7f81b8170316a8da6414c4dded332a537d11 /lib/dvb/epgcache.cpp | |
| parent | 9fac5ff7371972cef663d456b96c68f51b5c2c01 (diff) | |
| download | enigma2-025ad01a86542cba4eaceabdde5bed9bf72c4344.tar.gz enigma2-025ad01a86542cba4eaceabdde5bed9bf72c4344.zip | |
fix lookupEvent.. now we can query previous and next event
Diffstat (limited to 'lib/dvb/epgcache.cpp')
| -rw-r--r-- | lib/dvb/epgcache.cpp | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/lib/dvb/epgcache.cpp b/lib/dvb/epgcache.cpp index 60eee05a..13b0bf2e 100644 --- a/lib/dvb/epgcache.cpp +++ b/lib/dvb/epgcache.cpp @@ -1004,7 +1004,7 @@ void eEPGCache::channel_data::readData( const __u8 *data) } } -RESULT eEPGCache::lookupEventTime(const eServiceReference &service, time_t t, const eventData *&result ) +RESULT eEPGCache::lookupEventTime(const eServiceReference &service, time_t t, const eventData *&result, int direction) // if t == -1 we search the current event... { singleLock s(cache_lock); @@ -1016,20 +1016,24 @@ RESULT eEPGCache::lookupEventTime(const eServiceReference &service, time_t t, co { if (t==-1) t = time(0)+eDVBLocalTimeHandler::getInstance()->difference(); - timeMap::iterator i = It->second.second.lower_bound(t); // find > or equal + timeMap::iterator i = direction <= 0 ? It->second.second.lower_bound(t) : // find > or equal + It->second.second.upper_bound(t); // just > if ( i != It->second.second.end() ) { - if ( i->second->getStartTime() != t ) + if ( direction < 0 || (direction == 0 && 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; + if (direction >= 0) + { + if (t < start_time) + return -1; + if (t > (start_time+x->second->getDuration())) + return -1; + } i = x; } else @@ -1042,31 +1046,31 @@ RESULT eEPGCache::lookupEventTime(const eServiceReference &service, time_t t, co return -1; } -RESULT eEPGCache::lookupEventTime(const eServiceReference &service, time_t t, const eit_event_struct *&result ) +RESULT eEPGCache::lookupEventTime(const eServiceReference &service, time_t t, const eit_event_struct *&result, int direction) { singleLock s(cache_lock); const eventData *data=0; - RESULT ret = lookupEventTime(service, t, data); + RESULT ret = lookupEventTime(service, t, data, direction); if ( !ret && data ) result = data->get(); return ret; } -RESULT eEPGCache::lookupEventTime(const eServiceReference &service, time_t t, Event *& result ) +RESULT eEPGCache::lookupEventTime(const eServiceReference &service, time_t t, Event *& result, int direction) { singleLock s(cache_lock); const eventData *data=0; - RESULT ret = lookupEventTime(service, t, data); + RESULT ret = lookupEventTime(service, t, data, direction); if ( !ret && data ) result = new Event((uint8_t*)data->get()); return ret; } -RESULT eEPGCache::lookupEventTime(const eServiceReference &service, time_t t, ePtr<eServiceEvent> &result ) +RESULT eEPGCache::lookupEventTime(const eServiceReference &service, time_t t, ePtr<eServiceEvent> &result, int direction) { singleLock s(cache_lock); const eventData *data=0; - RESULT ret = lookupEventTime(service, t, data); + RESULT ret = lookupEventTime(service, t, data, direction); if ( !ret && data ) { Event ev((uint8_t*)data->get()); @@ -1391,7 +1395,7 @@ PyObject *eEPGCache::lookupEvent(PyObject *list, PyObject *convertFunc) } case 1: type=PyInt_AsLong(entry); - if (type < 0 || type > 1) + if (type < -1 || type > 2) { eDebug("unknown type %d", type); continue; @@ -1454,10 +1458,10 @@ PyObject *eEPGCache::lookupEvent(PyObject *list, PyObject *convertFunc) ePtr<eServiceEvent> ptr; if (stime) { - if (type == 0) - lookupEventTime(ref, stime, ptr); - else // type == 1 + if (type == 2) lookupEventId(ref, event_id, ptr); + else + lookupEventTime(ref, stime, ptr, type); } PyObject *ret = handleEvent(ptr, dest_list, argstring, argcount, service, nowTime, service_name, convertFunc, convertFuncArgs); if (ret) |
