fix channel state handling
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Sat, 17 Dec 2005 15:25:32 +0000 (15:25 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Sat, 17 Dec 2005 15:25:32 +0000 (15:25 +0000)
lib/dvb/dvbtime.cpp
lib/dvb/dvbtime.h
lib/dvb/epgcache.cpp
lib/dvb/epgcache.h

index 12e52a9f80c85a4e56185a2674851e7ff9b6b519..3bd0a78dfbaa66eaea937c929617c5b822a86cd9 100644 (file)
@@ -370,6 +370,7 @@ void eDVBLocalTimeHandler::DVBChannelAdded(eDVBChannel *chan)
                        m_knownChannels.insert( std::pair<iDVBChannel*, channel_data>(chan, channel_data()) );
                tmp.first->second.tdt = NULL;
                tmp.first->second.channel = chan;
                        m_knownChannels.insert( std::pair<iDVBChannel*, channel_data>(chan, channel_data()) );
                tmp.first->second.tdt = NULL;
                tmp.first->second.channel = chan;
+               tmp.first->second.m_prevChannelState = -1;
                chan->connectStateChange(slot(*this, &eDVBLocalTimeHandler::DVBChannelStateChanged), tmp.first->second.m_stateChangedConn);
        }
 }
                chan->connectStateChange(slot(*this, &eDVBLocalTimeHandler::DVBChannelStateChanged), tmp.first->second.m_stateChangedConn);
        }
 }
@@ -382,18 +383,24 @@ void eDVBLocalTimeHandler::DVBChannelStateChanged(iDVBChannel *chan)
        {
                int state=0;
                chan->getState(state);
        {
                int state=0;
                chan->getState(state);
-               switch (state)
+               if ( state != it->second.m_prevChannelState )
                {
                {
-                       case iDVBChannel::state_ok:
-                               eDebug("[eDVBLocalTimerHandler] channel %p running", chan);
-                               it->second.tdt = new TDT(it->second.channel);
-                               it->second.tdt->start();
-                               break;
-                       case iDVBChannel::state_release:
-                               eDebug("[eDVBLocalTimerHandler] remove channel %p", chan);
-                               delete it->second.tdt;
-                               m_knownChannels.erase(it);
-                               break;
+                       switch (state)
+                       {
+                               case iDVBChannel::state_ok:
+                                       eDebug("[eDVBLocalTimerHandler] channel %p running", chan);
+                                       it->second.tdt = new TDT(it->second.channel);
+                                       it->second.tdt->start();
+                                       break;
+                               case iDVBChannel::state_release:
+                                       eDebug("[eDVBLocalTimerHandler] remove channel %p", chan);
+                                       delete it->second.tdt;
+                                       m_knownChannels.erase(it);
+                                       break;
+                               default: // ignore all other events
+                                       return;
+                       }
+                       it->second.m_prevChannelState = state;
                }
        }
 }
                }
        }
 }
index 8f75ab7f51dcea4425fe2c5cca507a9b43f5418d..34c5d5f68a42c655adcae27cdbafa5b9ebfaa551 100644 (file)
@@ -40,6 +40,7 @@ class eDVBLocalTimeHandler: public Object
                TDT *tdt;
                ePtr<eDVBChannel> channel;
                ePtr<eConnection> m_stateChangedConn;
                TDT *tdt;
                ePtr<eDVBChannel> channel;
                ePtr<eConnection> m_stateChangedConn;
+               int m_prevChannelState;
        };
        friend class TDT;
        DECLARE_REF(eDVBLocalTimeHandler)
        };
        friend class TDT;
        DECLARE_REF(eDVBLocalTimeHandler)
index 2871880058a31d0713235d8af96ed0fca9d535d8..6d81119417b1996f80ab05a0dcd1acefdccca273 100644 (file)
@@ -191,6 +191,7 @@ void eEPGCache::DVBChannelAdded(eDVBChannel *chan)
 //             eDebug("[eEPGCache] add channel %p", chan);
                channel_data *data = new channel_data(this);
                data->channel = chan;
 //             eDebug("[eEPGCache] add channel %p", chan);
                channel_data *data = new channel_data(this);
                data->channel = chan;
+               data->prevChannelState = -1;
                singleLock s(channel_map_lock);
                m_knownChannels.insert( std::pair<iDVBChannel*, channel_data* >(chan, data) );
                chan->connectStateChange(slot(*this, &eEPGCache::DVBChannelStateChanged), data->m_stateChangedConn);
                singleLock s(channel_map_lock);
                m_knownChannels.insert( std::pair<iDVBChannel*, channel_data* >(chan, data) );
                chan->connectStateChange(slot(*this, &eEPGCache::DVBChannelStateChanged), data->m_stateChangedConn);
@@ -256,25 +257,31 @@ void eEPGCache::DVBChannelStateChanged(iDVBChannel *chan)
        {
                int state=0;
                chan->getState(state);
        {
                int state=0;
                chan->getState(state);
-               switch (state)
+               if ( it->second->prevChannelState != state )
                {
                {
-                       case iDVBChannel::state_ok:
+                       switch (state)
                        {
                        {
-                               eDebug("[eEPGCache] channel %p running", chan);
-                               DVBChannelRunning(chan);
-                               break;
-                       }
-                       case iDVBChannel::state_release:
-                       {
-                               eDebug("[eEPGCache] remove channel %p", chan);
-                               messages.send(Message(Message::leaveChannel, chan));
-                               while(!it->second->can_delete)
-                                       usleep(1000);
-                               delete it->second;
-                               m_knownChannels.erase(it);
-                               // -> gotMessage -> abortEPG
-                               break;
+                               case iDVBChannel::state_ok:
+                               {
+                                       eDebug("[eEPGCache] channel %p running", chan);
+                                       DVBChannelRunning(chan);
+                                       break;
+                               }
+                               case iDVBChannel::state_release:
+                               {
+                                       eDebug("[eEPGCache] remove channel %p", chan);
+                                       messages.send(Message(Message::leaveChannel, chan));
+                                       while(!it->second->can_delete)
+                                               usleep(1000);
+                                       delete it->second;
+                                       m_knownChannels.erase(it);
+                                       // -> gotMessage -> abortEPG
+                                       break;
+                               }
+                               default: // ignore all other events
+                                       return;
                        }
                        }
+                       it->second->prevChannelState = state;
                }
        }
 }
                }
        }
 }
index fe461d9db1a46f90aaf5591f320986f9e315b8de..eec08cc83f4883430d9973d6d05442242bb8a4fe 100644 (file)
@@ -142,6 +142,7 @@ class eEPGCache: public eMainloop, private eThread, public Object
                channel_data(eEPGCache*);
                eEPGCache *cache;
                eTimer abortTimer, zapTimer;
                channel_data(eEPGCache*);
                eEPGCache *cache;
                eTimer abortTimer, zapTimer;
+               int prevChannelState;
                __u8 state, isRunning, haveData, can_delete;
                ePtr<eDVBChannel> channel;
                ePtr<eConnection> m_stateChangedConn, m_NowNextConn, m_ScheduleConn, m_ScheduleOtherConn;
                __u8 state, isRunning, haveData, can_delete;
                ePtr<eDVBChannel> channel;
                ePtr<eConnection> m_stateChangedConn, m_NowNextConn, m_ScheduleConn, m_ScheduleOtherConn;