X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/515afae59cacf477dbc07c748aa2268e3d249223..60c8087aa78a5fa24617b0f2ef86fa54f6083101:/lib/dvb/dvb.cpp diff --git a/lib/dvb/dvb.cpp b/lib/dvb/dvb.cpp index 9d5a68aa..bad0ce1a 100644 --- a/lib/dvb/dvb.cpp +++ b/lib/dvb/dvb.cpp @@ -78,6 +78,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) @@ -215,6 +223,7 @@ void eDVBResourceManager::addAdapter(iDVBAdapter *adapter) { frontend->setSEC(m_sec); m_frontend.push_back(new eDVBRegisteredFrontend(frontend, adapter)); + CONNECT(m_frontend.back()->stateChanged, eDVBResourceManager::feStateChanged); } } } @@ -273,12 +282,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 +308,7 @@ RESULT eDVBResourceManager::allocateDemux(eDVBRegisteredFrontend *fe, ePtrget().setSourcePVR(0); return 0; } + } eDebug("demux not found"); return -1; } @@ -524,7 +545,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)) @@ -997,6 +1022,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;