use refcount for decoding demuxes to check if they are in use
authorFelix Domke <tmbinc@elitedvb.net>
Thu, 13 Apr 2006 00:52:31 +0000 (00:52 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Thu, 13 Apr 2006 00:52:31 +0000 (00:52 +0000)
lib/dvb/dvb.cpp

index 18765ad..2a188ee 100644 (file)
@@ -282,9 +282,14 @@ RESULT eDVBResourceManager::allocateDemux(eDVBRegisteredFrontend *fe, ePtr<eDVBA
        }
        
        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 >= 2))
+                       if ((cap & iDVBChannel::capDecode) && !is_decode)
                                continue;
                        
                        demux = new eDVBAllocatedDemux(i);
@@ -294,6 +299,7 @@ RESULT eDVBResourceManager::allocateDemux(eDVBRegisteredFrontend *fe, ePtr<eDVBA
                                demux->get().setSourcePVR(0);
                        return 0;
                }
+       }
        eDebug("demux not found");
        return -1;
 }