shutdown channel if tune fails
[enigma2.git] / lib / dvb / dvb.cpp
index ed972bf1d0d2fd7ab9522e480cecd3ec945f2efc..32c7ea31a67d1b06e9ca9e68a996e71cd188e28e 100644 (file)
@@ -233,6 +233,10 @@ RESULT eDVBResourceManager::allocateDemux(eDVBRegisteredFrontend *fe, ePtr<eDVBA
                if ((!i->m_inuse) && ((!fe) || (i->m_adapter == fe->m_adapter)))
                {
                        demux = new eDVBAllocatedDemux(i);
+                       if (fe)
+                               demux->get().setSourceFrontend(fe->m_frontend->getID());
+                       else
+                               demux->get().setSourcePVR(0);
                        eDebug("demux found");
                        return 0;
                }
@@ -487,7 +491,18 @@ RESULT eDVBChannel::setChannel(const eDVBChannelID &channelid)
        m_channel_id = channelid;
        m_mgr->addChannel(channelid, this);
        m_state = state_tuning;
-       return m_frontend->get().tune(*feparm);
+                       /* if tuning fails, shutdown the channel immediately. */
+       int res;
+       res = m_frontend->get().tune(*feparm);
+       
+       if (res)
+       {
+               m_state = state_release;
+               m_stateChanged(this);
+               return res;
+       }
+       
+       return 0;
 }
 
 RESULT eDVBChannel::connectStateChange(const Slot1<void,iDVBChannel*> &stateChange, ePtr<eConnection> &connection)