add channel cache (transponders)
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Mon, 5 Dec 2005 19:15:53 +0000 (19:15 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Mon, 5 Dec 2005 19:15:53 +0000 (19:15 +0000)
lib/dvb/dvb.cpp
lib/dvb/dvb.h

index aa7958126f2a707e3ccbe4279ee7b45f40de4306..8feb3c184f4094293bd07c14f4d3d6ec75f686bc 100644 (file)
@@ -299,7 +299,19 @@ RESULT eDVBResourceManager::getChannelList(ePtr<iDVBChannelList> &list)
 RESULT eDVBResourceManager::allocateChannel(const eDVBChannelID &channelid, eUsePtr<iDVBChannel> &channel)
 {
                /* first, check if a channel is already existing. */
-       
+
+       if (m_cached_channel)
+       {
+               eDVBChannel *cache_chan = (eDVBChannel*)&(*m_cached_channel);
+               if(channelid==cache_chan->getChannelID())
+               {
+                       eDebug("use cached_channel");
+                       channel=m_cached_channel;
+                       return 0;
+               }
+               m_cached_channel=0;
+       }
+
 //     eDebug("allocate channel.. %04x:%04x", channelid.transport_stream_id.get(), channelid.original_network_id.get());
        for (std::list<active_channel>::iterator i(m_active_channels.begin()); i != m_active_channels.end(); ++i)
        {
@@ -344,7 +356,7 @@ RESULT eDVBResourceManager::allocateChannel(const eDVBChannelID &channelid, eUse
                channel = 0;
                return errChidNotFound;
        }
-       channel = ch;
+       m_cached_channel = channel = ch;
 
        return 0;
 }
@@ -444,7 +456,7 @@ bool eDVBResourceManager::canAllocateChannel(const eDVBChannelID &channelid, con
                if (i->m_channel_id == ignore)
                {
                        eDVBChannel *channel = (eDVBChannel*) &(*i->m_channel);
-                       if (channel->getUseCount() == 1)  // channel only used once..
+                       if (channel == &(*m_cached_channel) ? channel->getUseCount() == 2 : channel->getUseCount() == 1)  // channel only used once..
                        {
                                ePtr<iDVBFrontend> fe;
                                if (!i->m_channel->getFrontend(fe))
index ee8ea8ef5afe3df05c53a7db0e63f4bee0a6e13e..ac5946cd6d9dcd0a91eeedd4d94957e4a7fa44ec 100644 (file)
@@ -97,7 +97,9 @@ class eDVBResourceManager: public iObject
 {
        DECLARE_REF(eDVBResourceManager);
        int avail, busy;
-       
+
+       eUsePtr<iDVBChannel> m_cached_channel;
+
        eSmartPtrList<iDVBAdapter> m_adapter;
        
        eSmartPtrList<eDVBRegisteredDemux> m_demux;