remove non working indication of playable services in servicelist
[enigma2.git] / lib / dvb / dvb.cpp
index 9ddc29b3a7caca12ac1200523adb038f7368fc80..4107c22dc89e65fcfd5f82e2850df56f1a4d16ec 100644 (file)
@@ -219,7 +219,7 @@ RESULT eDVBResourceManager::allocateFrontend(ePtr<eDVBAllocatedFrontend> &fe, eP
                        int c = i->m_frontend->isCompatibleWith(feparm);
                        if (c > bestval)
                        {
-                               c = bestval;
+                               bestval = c;
                                best = i;
                        }
                }
@@ -296,7 +296,6 @@ RESULT eDVBResourceManager::getChannelList(ePtr<iDVBChannelList> &list)
                return -ENOENT;
 }
 
-
 RESULT eDVBResourceManager::allocateChannel(const eDVBChannelID &channelid, eUsePtr<iDVBChannel> &channel)
 {
                /* first, check if a channel is already existing. */
@@ -334,7 +333,7 @@ RESULT eDVBResourceManager::allocateChannel(const eDVBChannelID &channelid, eUse
        
        if (allocateFrontend(fe, feparm))
                return errNoFrontend;
-       
+
        RESULT res;
        ePtr<eDVBChannel> ch;
        ch = new eDVBChannel(this, fe);
@@ -345,8 +344,8 @@ RESULT eDVBResourceManager::allocateChannel(const eDVBChannelID &channelid, eUse
                channel = 0;
                return errChidNotFound;
        }
-       
        channel = ch;
+
        return 0;
 }
 
@@ -407,6 +406,82 @@ RESULT eDVBResourceManager::connectChannelAdded(const Slot1<void,eDVBChannel*> &
        return 0;
 }
 
+bool eDVBResourceManager::canAllocateFrontend(ePtr<iDVBFrontendParameters> &feparm, int used_tuner_mask)
+{
+       eDebug("canAllocateFrontend mask %08x", used_tuner_mask);
+       ePtr<eDVBRegisteredFrontend> best;
+       int bestval = 0;
+
+       for (eSmartPtrList<eDVBRegisteredFrontend>::iterator i(m_frontend.begin()); i != m_frontend.end(); ++i)
+               if ( !(used_tuner_mask & (1<<i->m_frontend->getID())) )
+               {
+                       int c = i->m_frontend->isCompatibleWith(feparm);
+                       if (c > bestval)
+                               bestval = c;
+               }
+
+       return bestval>0;
+}
+
+bool eDVBResourceManager::canAllocateChannel(const eDVBChannelID &channelid)
+{
+       return true;
+#if 0
+       int used_tuner_mask=0;
+
+               /* first, check if a channel is already existing. */
+//     eDebug("allocate channel.. %04x:%04x", channelid.transport_stream_id.get(), channelid.original_network_id.get());
+       int cnt=0;
+       for (std::list<active_channel>::iterator i(m_active_channels.begin()); i != m_active_channels.end(); ++i, ++cnt)
+       {
+//             eDebug("available channel.. %04x:%04x", i->m_channel_id.transport_stream_id.get(), i->m_channel_id.original_network_id.get());
+               if (i->m_channel_id == channelid)
+               {
+//                     eDebug("found shared channel..");
+                       return true;
+               }
+
+               eDebug("activeChannel %d, NonDecoderDemux %p, DecoderDemux %p",
+                       cnt, i->m_channel->getNonDecoderDemux(), i->m_channel->getDecoderDemux() );
+               if ( i->m_channel->getNonDecoderDemux() )
+               {
+                       ePtr<iDVBFrontend> fe;
+                       if (!i->m_channel->getFrontend(fe))
+                       {
+                               if (fe)
+                               {
+                                       for (eSmartPtrList<eDVBRegisteredFrontend>::iterator ii(m_frontend.begin()); ii != m_frontend.end(); ++ii)
+                                       {
+                                               if ( &(*fe) == &(*ii->m_frontend) )
+                                               {
+                                                       used_tuner_mask |= (1 << ii->m_frontend->getID());
+                                                       break;
+                                               }
+                                       }
+                               }
+                               else
+                                       eDebug("fe kaputt");
+                       }
+               }
+       }
+
+       if (!m_list)
+       {
+               eDebug("no channel list set!");
+               return false;
+       }
+
+       ePtr<iDVBFrontendParameters> feparm;
+       if (m_list->getChannelFrontendData(channelid, feparm))
+       {
+               eDebug("channel not found!");
+               return false;
+       }
+
+       return canAllocateFrontend(feparm, used_tuner_mask);
+#endif
+}
+
 DEFINE_REF(eDVBChannel);
 
 eDVBChannel::eDVBChannel(eDVBResourceManager *mgr, eDVBAllocatedFrontend *frontend): m_state(state_idle), m_mgr(mgr)