X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/5cdabb1038ec3f628001f26f5d587eb95ca6465d..20fdb2a2af40da98427a702a03a79b1fbec3d7af:/lib/dvb/dvb.cpp diff --git a/lib/dvb/dvb.cpp b/lib/dvb/dvb.cpp index 5315c0e5..4107c22d 100644 --- a/lib/dvb/dvb.cpp +++ b/lib/dvb/dvb.cpp @@ -46,7 +46,7 @@ eDVBResourceManager::eDVBResourceManager() { avail = 1; busy = 0; - m_sec = new eDVBSatelliteEquipmentControl; + m_sec = new eDVBSatelliteEquipmentControl(m_frontend); if (!instance) instance = this; @@ -200,6 +200,8 @@ void eDVBResourceManager::addAdapter(iDVBAdapter *adapter) if (!adapter->getFrontend(frontend, i)) { + frontend->setTone(iDVBFrontend::toneOff); + frontend->setVoltage(iDVBFrontend::voltageOff); frontend->setSEC(m_sec); m_frontend.push_back(new eDVBRegisteredFrontend(frontend, adapter)); } @@ -217,7 +219,7 @@ RESULT eDVBResourceManager::allocateFrontend(ePtr &fe, eP int c = i->m_frontend->isCompatibleWith(feparm); if (c > bestval) { - c = bestval; + bestval = c; best = i; } } @@ -294,7 +296,6 @@ RESULT eDVBResourceManager::getChannelList(ePtr &list) return -ENOENT; } - RESULT eDVBResourceManager::allocateChannel(const eDVBChannelID &channelid, eUsePtr &channel) { /* first, check if a channel is already existing. */ @@ -332,7 +333,7 @@ RESULT eDVBResourceManager::allocateChannel(const eDVBChannelID &channelid, eUse if (allocateFrontend(fe, feparm)) return errNoFrontend; - + RESULT res; ePtr ch; ch = new eDVBChannel(this, fe); @@ -343,8 +344,8 @@ RESULT eDVBResourceManager::allocateChannel(const eDVBChannelID &channelid, eUse channel = 0; return errChidNotFound; } - channel = ch; + return 0; } @@ -405,6 +406,82 @@ RESULT eDVBResourceManager::connectChannelAdded(const Slot1 & return 0; } +bool eDVBResourceManager::canAllocateFrontend(ePtr &feparm, int used_tuner_mask) +{ + eDebug("canAllocateFrontend mask %08x", used_tuner_mask); + ePtr best; + int bestval = 0; + + for (eSmartPtrList::iterator i(m_frontend.begin()); i != m_frontend.end(); ++i) + if ( !(used_tuner_mask & (1<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::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 fe; + if (!i->m_channel->getFrontend(fe)) + { + if (fe) + { + for (eSmartPtrList::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 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)