code cleanup
[enigma2.git] / lib / dvb / epgcache.cpp
index 974e9f7bdc57c443281b3f6e98ffec2c7b75e9ae..1867eb9732ae147e9cbc68d37d48ecc3c9cabd0b 100644 (file)
@@ -286,7 +286,7 @@ void eEPGCache::DVBChannelStateChanged(iDVBChannel *chan)
                                {
                                        eDebug("[eEPGCache] remove channel %p", chan);
                                        messages.send(Message(Message::leaveChannel, chan));
-                                       while(!it->second->can_delete)
+                                       while(!it->second->canDelete())
                                                usleep(1000);
                                        delete it->second;
                                        m_knownChannels.erase(it);
@@ -983,7 +983,7 @@ void eEPGCache::save()
 eEPGCache::channel_data::channel_data(eEPGCache *ml)
        :cache(ml)
        ,abortTimer(ml), zapTimer(ml),state(0)
-       ,isRunning(0), haveData(0), can_delete(1)
+       ,isRunning(0), haveData(0)
        ,startPrivateTimer(ml)
 {
        CONNECT(zapTimer.timeout, eEPGCache::channel_data::startEPG);
@@ -1005,10 +1005,6 @@ bool eEPGCache::channel_data::finishEPG()
                }
                singleLock l(cache->cache_lock);
                cache->channelLastUpdated[channel->getChannelID()] = eDVBLocalTimeHandler::getInstance()->nowTime();
-#ifdef ENABLE_PRIVATE_EPG
-               if (seenPrivateSections.empty())
-#endif
-               can_delete=1;
                return true;
        }
        return false;
@@ -1019,7 +1015,6 @@ void eEPGCache::channel_data::startEPG()
        eDebug("[EPGC] start caching events(%ld)", eDVBLocalTimeHandler::getInstance()->nowTime());
        state=0;
        haveData=0;
-       can_delete=0;
        for (int i=0; i < 3; ++i)
        {
                seenSections[i].clear();
@@ -1056,21 +1051,21 @@ void eEPGCache::channel_data::abortNonAvail()
 {
        if (!state)
        {
-               if ( !(haveData&eEPGCache::NOWNEXT) && (isRunning&eEPGCache::NOWNEXT) )
+               if ( !(haveData&NOWNEXT) && (isRunning&NOWNEXT) )
                {
                        eDebug("[EPGC] abort non avail nownext reading");
-                       isRunning &= ~eEPGCache::NOWNEXT;
+                       isRunning &= ~NOWNEXT;
                        m_NowNextReader->stop();
                        m_NowNextConn=0;
                }
-               if ( !(haveData&eEPGCache::SCHEDULE) && (isRunning&eEPGCache::SCHEDULE) )
+               if ( !(haveData&SCHEDULE) && (isRunning&SCHEDULE) )
                {
                        eDebug("[EPGC] abort non avail schedule reading");
                        isRunning &= ~SCHEDULE;
                        m_ScheduleReader->stop();
                        m_ScheduleConn=0;
                }
-               if ( !(haveData&eEPGCache::SCHEDULE_OTHER) && (isRunning&eEPGCache::SCHEDULE_OTHER) )
+               if ( !(haveData&SCHEDULE_OTHER) && (isRunning&SCHEDULE_OTHER) )
                {
                        eDebug("[EPGC] abort non avail schedule_other reading");
                        isRunning &= ~SCHEDULE_OTHER;
@@ -1087,10 +1082,6 @@ void eEPGCache::channel_data::abortNonAvail()
                                seenSections[i].clear();
                                calcedSections[i].clear();
                        }
-#ifdef ENABLE_PRIVATE_EPG
-                       if (seenPrivateSections.empty())
-#endif
-                       can_delete=1;
                }
        }
        ++state;
@@ -1124,21 +1115,21 @@ void eEPGCache::channel_data::abortEPG()
        if (isRunning)
        {
                eDebug("[EPGC] abort caching events !!");
-               if (isRunning & eEPGCache::SCHEDULE)
+               if (isRunning & SCHEDULE)
                {
-                       isRunning &= ~eEPGCache::SCHEDULE;
+                       isRunning &= ~SCHEDULE;
                        m_ScheduleReader->stop();
                        m_ScheduleConn=0;
                }
-               if (isRunning & eEPGCache::NOWNEXT)
+               if (isRunning & NOWNEXT)
                {
-                       isRunning &= ~eEPGCache::NOWNEXT;
+                       isRunning &= ~NOWNEXT;
                        m_NowNextReader->stop();
                        m_NowNextConn=0;
                }
                if (isRunning & SCHEDULE_OTHER)
                {
-                       isRunning &= ~eEPGCache::SCHEDULE_OTHER;
+                       isRunning &= ~SCHEDULE_OTHER;
                        m_ScheduleOtherReader->stop();
                        m_ScheduleOtherConn=0;
                }
@@ -1149,7 +1140,6 @@ void eEPGCache::channel_data::abortEPG()
        if (m_PrivateConn)
                m_PrivateConn=0;
 #endif
-       can_delete=1;
 }
 
 void eEPGCache::channel_data::readData( const __u8 *data)
@@ -1165,17 +1155,17 @@ void eEPGCache::channel_data::readData( const __u8 *data)
                {
                        case 0x4E ... 0x4F:
                                reader=m_NowNextReader;
-                               source=eEPGCache::NOWNEXT;
+                               source=NOWNEXT;
                                map=0;
                                break;
                        case 0x50 ... 0x5F:
                                reader=m_ScheduleReader;
-                               source=eEPGCache::SCHEDULE;
+                               source=SCHEDULE;
                                map=1;
                                break;
                        case 0x60 ... 0x6F:
                                reader=m_ScheduleOtherReader;
-                               source=eEPGCache::SCHEDULE_OTHER;
+                               source=SCHEDULE_OTHER;
                                map=2;
                                break;
                        default:
@@ -1189,15 +1179,15 @@ void eEPGCache::channel_data::readData( const __u8 *data)
                        eDebugNoNewLine("[EPGC] ");
                        switch (source)
                        {
-                               case eEPGCache::NOWNEXT:
+                               case NOWNEXT:
                                        m_NowNextConn=0;
                                        eDebugNoNewLine("nownext");
                                        break;
-                               case eEPGCache::SCHEDULE:
+                               case SCHEDULE:
                                        m_ScheduleConn=0;
                                        eDebugNoNewLine("schedule");
                                        break;
-                               case eEPGCache::SCHEDULE_OTHER:
+                               case SCHEDULE_OTHER:
                                        m_ScheduleOtherConn=0;
                                        eDebugNoNewLine("schedule other");
                                        break;
@@ -2384,7 +2374,7 @@ void eEPGCache::privateSectionRead(const uniqueEPGKey &current_service, const __
                event[0] = (event_id & 0xFF00) >> 8;
                event[1] = (event_id & 0xFF);
                time_event_map[it->first.tm]=std::pair<time_t, __u16>(stime, event_id);
-               eventData *d = new eventData( ev_struct, bptr, eEPGCache::PRIVATE );
+               eventData *d = new eventData( ev_struct, bptr, PRIVATE );
                evMap[event_id] = d;
                tmMap[stime] = d;
        }
@@ -2406,7 +2396,8 @@ void eEPGCache::channel_data::startPrivateReader()
                mask.mode[3] = 0x3E;
        }
        seenPrivateSections.clear();
-       m_PrivateReader->connectRead(slot(*this, &eEPGCache::channel_data::readPrivateData), m_PrivateConn);
+       if (!m_PrivateConn)
+               m_PrivateReader->connectRead(slot(*this, &eEPGCache::channel_data::readPrivateData), m_PrivateConn);
        m_PrivateReader->start(mask);
 }
 
@@ -2418,28 +2409,12 @@ void eEPGCache::channel_data::readPrivateData( const __u8 *data)
        {
                if ( seenPrivateSections.find( data[6] ) == seenPrivateSections.end() )
                {
-#ifdef NEED_DEMUX_WORKAROUND
-                       int version = data[5];
-                       version = ((version & 0x3E) >> 1);
-                       can_delete = 0;
-                       if ( m_PrevVersion != version )
-                       {
-                               cache->privateSectionRead(m_PrivateService, data);
-                               seenPrivateSections.insert(data[6]);
-                       }
-                       else
-                               eDebug("ignore");
-#else
-                       can_delete = 0;
                        cache->privateSectionRead(m_PrivateService, data);
                        seenPrivateSections.insert(data[6]);
-#endif
                }
                if ( seenPrivateSections.size() == (unsigned int)(data[7] + 1) )
                {
                        eDebug("[EPGC] private finished");
-                       if (!isRunning)
-                               can_delete = 1;
                        m_PrevVersion = (data[5] & 0x3E) >> 1;
                        startPrivateReader();
                }