X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/5c644fbbceaa79a49501975de16b090771edee29..462ec6f4ad2051551cb91c75ba614d3b7b17c543:/lib/dvb/dvb.cpp diff --git a/lib/dvb/dvb.cpp b/lib/dvb/dvb.cpp index 62899379..8af8bb0e 100644 --- a/lib/dvb/dvb.cpp +++ b/lib/dvb/dvb.cpp @@ -304,7 +304,7 @@ RESULT eDVBResourceManager::allocateChannel(const eDVBChannelID &channelid, eUse if(channelid==cache_chan->getChannelID()) { eDebug("use cached_channel"); - channel=m_cached_channel; + channel = m_cached_channel; return 0; } m_cached_channel=0; @@ -493,19 +493,22 @@ bool eDVBResourceManager::canAllocateChannel(const eDVBChannelID &channelid, con if (!decremented_cached_channel_fe_usecount) { - eDVBChannel *channel = (eDVBChannel*) &(*m_cached_channel); - if (channel->getUseCount() == 1) + if (m_cached_channel) { - ePtr fe; - if (!channel->getFrontend(fe)) + eDVBChannel *channel = (eDVBChannel*) &(*m_cached_channel); + if (channel->getUseCount() == 1) { - for (eSmartPtrList::iterator ii(m_frontend.begin()); ii != m_frontend.end(); ++ii) + ePtr fe; + if (!channel->getFrontend(fe)) { - if ( &(*fe) == &(*ii->m_frontend) ) + for (eSmartPtrList::iterator ii(m_frontend.begin()); ii != m_frontend.end(); ++ii) { - --ii->m_inuse; - decremented_cached_channel_fe_usecount = &ii->m_inuse; - break; + if ( &(*fe) == &(*ii->m_frontend) ) + { + --ii->m_inuse; + decremented_cached_channel_fe_usecount = &ii->m_inuse; + break; + } } } } @@ -588,8 +591,18 @@ void eDVBChannel::frontendStateChanged(iDVBFrontend*fe) ourstate = state_tuning; } else if (state == iDVBFrontend::stateLostLock) { - eDebug("OURSTATE: lost lock"); - ourstate = state_unavailable; + /* on managed channels, we try to retune in order to re-acquire lock. */ + if (m_feparm) + { + eDebug("OURSTATE: lost lock, trying to retune"); + ourstate = state_tuning; + m_frontend->get().tune(*m_feparm); + } else + /* on unmanaged channels, we don't do this. the client will do this. */ + { + eDebug("OURSTATE: lost lock, unavailable now."); + ourstate = state_unavailable; + } } else if (state == iDVBFrontend::stateFailed) { eDebug("OURSTATE: failed"); @@ -604,6 +617,17 @@ void eDVBChannel::frontendStateChanged(iDVBFrontend*fe) } } +void eDVBChannel::pvrEvent(int event) +{ + switch (event) + { + case eFilePushThread::evtEOF: + eDebug("eDVBChannel: End of file!"); + m_event(this, evtEOF); + break; + } +} + void eDVBChannel::AddUse() { ++m_use_count; @@ -638,6 +662,7 @@ RESULT eDVBChannel::setChannel(const eDVBChannelID &channelid, ePtrget().tune(*feparm); + m_feparm = feparm; if (res) { @@ -655,6 +680,12 @@ RESULT eDVBChannel::connectStateChange(const Slot1 &stateChan return 0; } +RESULT eDVBChannel::connectEvent(const Slot2 &event, ePtr &connection) +{ + connection = new eConnection((iDVBChannel*)this, m_event.connect(event)); + return 0; +} + RESULT eDVBChannel::getState(int &state) { state = m_state; @@ -668,7 +699,6 @@ RESULT eDVBChannel::setCIRouting(const eDVBCIRouting &routing) RESULT eDVBChannel::getDemux(ePtr &demux, int cap) { - eDebug("get %d demux", cap); ePtr &our_demux = (cap & capDecode) ? m_decoder_demux : m_demux; if (!our_demux) @@ -677,14 +707,12 @@ RESULT eDVBChannel::getDemux(ePtr &demux, int cap) if (m_mgr->allocateDemux(m_frontend ? (eDVBRegisteredFrontend*)*m_frontend : (eDVBRegisteredFrontend*)0, our_demux, cap)) return -1; - } demux = *our_demux; + /* don't hold a reference to the decoding demux, we don't need it. */ if (cap & capDecode) - { our_demux = 0; - } return 0; } @@ -732,7 +760,9 @@ RESULT eDVBChannel::playFile(const char *file) m_stateChanged(this); m_pvr_thread = new eFilePushThread(); + m_pvr_thread->enablePVRCommit(1); m_pvr_thread->start(m_pvr_fd_src, m_pvr_fd_dst); + CONNECT(m_pvr_thread->m_event, eDVBChannel::pvrEvent); return 0; }