X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/515afae59cacf477dbc07c748aa2268e3d249223..b58a0fa7cab89937586e2d08d79274fab3f14edc:/lib/dvb/dvb.cpp diff --git a/lib/dvb/dvb.cpp b/lib/dvb/dvb.cpp index 9d5a68aa..ad146542 100644 --- a/lib/dvb/dvb.cpp +++ b/lib/dvb/dvb.cpp @@ -52,6 +52,13 @@ RESULT eDVBResourceManager::getInstance(ePtr &ptr) return -1; } +ePtr NewResourceManagerPtr(void) +{ + ePtr ptr; + eDVBResourceManager::getInstance(ptr); + return ptr; +} + eDVBResourceManager::eDVBResourceManager() :m_releaseCachedChannelTimer(eApp) { @@ -78,6 +85,14 @@ eDVBResourceManager::eDVBResourceManager() CONNECT(m_releaseCachedChannelTimer.timeout, eDVBResourceManager::releaseCachedChannel); } +void eDVBResourceManager::feStateChanged() +{ + int mask=0; + for (eSmartPtrList::iterator i(m_frontend.begin()); i != m_frontend.end(); ++i) + if (i->m_inuse) + mask |= ( 1 << i->m_frontend->getID() ); + /* emit */ frontendUseMaskChanged(mask); +} DEFINE_REF(eDVBAdapterLinux); eDVBAdapterLinux::eDVBAdapterLinux(int nr): m_nr(nr) @@ -207,14 +222,28 @@ void eDVBResourceManager::addAdapter(iDVBAdapter *adapter) m_demux.push_back(new eDVBRegisteredDemux(demux, adapter)); } + ePtr prev_dvbt_frontend; for (i=0; i frontend; - if (!adapter->getFrontend(frontend, i)) { + int frontendType=0; + frontend->getFrontendType(frontendType); + eDVBRegisteredFrontend *new_fe = new eDVBRegisteredFrontend(frontend, adapter); + CONNECT(new_fe->stateChanged, eDVBResourceManager::feStateChanged); + m_frontend.push_back(new_fe); frontend->setSEC(m_sec); - m_frontend.push_back(new eDVBRegisteredFrontend(frontend, adapter)); + // we must link all dvb-t frontends ( for active antenna voltage ) + if (frontendType == iDVBFrontend::feTerrestrial) + { + if (prev_dvbt_frontend) + { + prev_dvbt_frontend->m_frontend->setData(eDVBFrontend::LINKED_NEXT_PTR, (int)new_fe); + frontend->setData(eDVBFrontend::LINKED_PREV_PTR, (int)&(*prev_dvbt_frontend)); + } + prev_dvbt_frontend = new_fe; + } } } } @@ -273,12 +302,23 @@ RESULT eDVBResourceManager::allocateDemux(eDVBRegisteredFrontend *fe, ePtr 2) /* assumed to be true, otherwise we have lost anyway */ + { + ++i, ++n; + ++i, ++n; + } + } for (; i != m_demux.end(); ++i, ++n) - if ((!i->m_inuse) && ((!fe) || (i->m_adapter == fe->m_adapter))) + { + int is_decode = n < 2; + + int in_use = is_decode ? (i->m_demux->getRefCount() != 2) : i->m_inuse; + + if ((!in_use) && ((!fe) || (i->m_adapter == fe->m_adapter))) { - if ((cap & iDVBChannel::capDecode) && n) + if ((cap & iDVBChannel::capDecode) && !is_decode) continue; demux = new eDVBAllocatedDemux(i); @@ -288,6 +328,7 @@ RESULT eDVBResourceManager::allocateDemux(eDVBRegisteredFrontend *fe, ePtrget().setSourcePVR(0); return 0; } + } eDebug("demux not found"); return -1; } @@ -477,7 +518,7 @@ RESULT eDVBResourceManager::connectChannelAdded(const Slot1 & return 0; } -bool eDVBResourceManager::canAllocateFrontend(ePtr &feparm) +int eDVBResourceManager::canAllocateFrontend(ePtr &feparm) { ePtr best; int bestval = 0; @@ -490,12 +531,12 @@ bool eDVBResourceManager::canAllocateFrontend(ePtr &fepa bestval = c; } - return bestval>0; + return bestval; } -bool eDVBResourceManager::canAllocateChannel(const eDVBChannelID &channelid, const eDVBChannelID& ignore) +int eDVBResourceManager::canAllocateChannel(const eDVBChannelID &channelid, const eDVBChannelID& ignore) { - bool ret=true; + int ret=30000; if (m_cached_channel) { eDVBChannel *cache_chan = (eDVBChannel*)&(*m_cached_channel); @@ -524,7 +565,11 @@ bool eDVBResourceManager::canAllocateChannel(const eDVBChannelID &channelid, con if (i->m_channel_id == ignore) { eDVBChannel *channel = (eDVBChannel*) &(*i->m_channel); - if (channel == &(*m_cached_channel) ? channel->getUseCount() == 2 : channel->getUseCount() == 1) // channel only used once.. + // one eUsePtr is used in eDVBServicePMTHandler + // another on eUsePtr is used in the eDVBScan instance used in eDVBServicePMTHandler (for SDT scan) + // so we must check here if usecount is 3 (when the channel is equal to the cached channel) + // or 2 when the cached channel is not equal to the compared channel + if (channel == &(*m_cached_channel) ? channel->getUseCount() == 3 : channel->getUseCount() == 2) // channel only used once.. { ePtr fe; if (!i->m_channel->getFrontend(fe)) @@ -577,14 +622,14 @@ bool eDVBResourceManager::canAllocateChannel(const eDVBChannelID &channelid, con if (!m_list) { eDebug("no channel list set!"); - ret = false; + ret = 0; goto error; } if (m_list->getChannelFrontendData(channelid, feparm)) { eDebug("channel not found!"); - ret = false; + ret = 0; goto error; } @@ -997,6 +1042,11 @@ RESULT eDVBChannel::getDemux(ePtr &demux, int cap) demux = *our_demux; /* don't hold a reference to the decoding demux, we don't need it. */ + + /* FIXME: by dropping the 'allocated demux' in favour of the 'iDVBDemux', + the refcount is lost. thus, decoding demuxes are never allocated. + + this poses a big problem for PiP. */ if (cap & capDecode) our_demux = 0; return 0; @@ -1160,7 +1210,7 @@ eCueSheet::eCueSheet() void eCueSheet::seekTo(int relative, const pts_t &pts) { { - eSingleLock l(m_lock); + eSingleLocker l(m_lock); m_seek_requests.push_back(std::pair(relative, pts)); } m_event(evtSeek); @@ -1168,14 +1218,14 @@ void eCueSheet::seekTo(int relative, const pts_t &pts) void eCueSheet::clear() { - eSingleLock l(m_lock); + eSingleLocker l(m_lock); m_spans.clear(); } void eCueSheet::addSourceSpan(const pts_t &begin, const pts_t &end) { { - eSingleLock l(m_lock); + eSingleLocker l(m_lock); m_spans.push_back(std::pair(begin, end)); } } @@ -1188,7 +1238,7 @@ void eCueSheet::commitSpans() void eCueSheet::setSkipmode(const pts_t &ratio) { { - eSingleLock l(m_lock); + eSingleLocker l(m_lock); m_skipmode_ratio = ratio; } m_event(evtSkipmode);