added default language for lang code "tha". refs #687
[enigma2.git] / lib / dvb / dvb.cpp
index 656b6da0111493d9d6ace0d2bf10dabbd412de9a..c2ddb4099f35de7d73aa093f4b588a4ee9029b17 100644 (file)
@@ -96,6 +96,10 @@ eDVBResourceManager::eDVBResourceManager()
                m_boxtype = DM800;
        else if (!strncmp(tmp, "dm500hd\n", rd))
                m_boxtype = DM500HD;
+       else if (!strncmp(tmp, "dm800se\n", rd))
+               m_boxtype = DM800SE;
+       else if (!strncmp(tmp, "dm7020hd\n", rd))
+               m_boxtype = DM7020HD;
        else {
                eDebug("boxtype detection via /proc/stb/info not possible... use fallback via demux count!\n");
                if (m_demux.size() == 3)
@@ -106,7 +110,7 @@ eDVBResourceManager::eDVBResourceManager()
                        m_boxtype = DM8000;
        }
 
-       eDebug("found %d adapter, %d frontends(%d sim) and %d demux, boxtype %d",
+       eDebug("found %zd adapter, %zd frontends(%zd sim) and %zd demux, boxtype %d",
                m_adapter.size(), m_frontend.size(), m_simulate_frontend.size(), m_demux.size(), m_boxtype);
 
        eDVBCAService::registerChannelCallback(this);
@@ -318,27 +322,34 @@ PyObject *eDVBResourceManager::setFrontendSlotInformations(ePyObject list)
                PyErr_SetString(PyExc_StandardError, "eDVBResourceManager::setFrontendSlotInformations argument should be a python list");
                return NULL;
        }
-       if ((unsigned int)PyList_Size(list) != m_frontend.size())
+       unsigned int assigned=0;
+       for (eSmartPtrList<eDVBRegisteredFrontend>::iterator i(m_frontend.begin()); i != m_frontend.end(); ++i)
        {
+               int pos=0;
+               while (pos < PyList_Size(list)) {
+                       ePyObject obj = PyList_GET_ITEM(list, pos++);
+                       if (!i->m_frontend->setSlotInfo(obj))
+                               continue;
+                       ++assigned;
+                       break;
+               }
+       }
+       if (assigned != m_frontend.size()) {
                char blasel[256];
-               sprintf(blasel, "eDVBResourceManager::setFrontendSlotInformations list size incorrect %d frontends avail, but %d entries in slotlist",
-                       m_frontend.size(), PyList_Size(list));
+               sprintf(blasel, "eDVBResourceManager::setFrontendSlotInformations .. assigned %zd socket informations, but %d registered frontends!",
+                       m_frontend.size(), assigned);
                PyErr_SetString(PyExc_StandardError, blasel);
                return NULL;
        }
-       int pos=0;
-       for (eSmartPtrList<eDVBRegisteredFrontend>::iterator i(m_frontend.begin()); i != m_frontend.end(); ++i)
-       {
-               ePyObject obj = PyList_GET_ITEM(list, pos++);
-               if (!i->m_frontend->setSlotInfo(obj))
-                       return NULL;
-       }
-       pos=0;
        for (eSmartPtrList<eDVBRegisteredFrontend>::iterator i(m_simulate_frontend.begin()); i != m_simulate_frontend.end(); ++i)
        {
-               ePyObject obj = PyList_GET_ITEM(list, pos++);
-               if (!i->m_frontend->setSlotInfo(obj))
-                       return NULL;
+               int pos=0;
+               while (pos < PyList_Size(list)) {
+                       ePyObject obj = PyList_GET_ITEM(list, pos++);
+                       if (!i->m_frontend->setSlotInfo(obj))
+                               continue;
+                       break;
+               }
        }
        Py_RETURN_NONE;
 }
@@ -455,7 +466,7 @@ RESULT eDVBResourceManager::allocateDemux(eDVBRegisteredFrontend *fe, ePtr<eDVBA
 
        ePtr<eDVBRegisteredDemux> unused;
 
-       if (m_boxtype == DM800 || m_boxtype == DM500HD) // dm800 / 500hd
+       if (m_boxtype == DM800 || m_boxtype == DM500HD || m_boxtype == DM800SE) // dm800 / 500hd
        {
                cap |= capHoldDecodeReference; // this is checked in eDVBChannel::getDemux
                for (; i != m_demux.end(); ++i, ++n)
@@ -511,7 +522,7 @@ RESULT eDVBResourceManager::allocateDemux(eDVBRegisteredFrontend *fe, ePtr<eDVBA
                        }
                }
        }
-       else if (m_boxtype == DM8000)
+       else if (m_boxtype == DM8000 || m_boxtype == DM7020HD)
        {
                cap |= capHoldDecodeReference; // this is checked in eDVBChannel::getDemux
                for (; i != m_demux.end(); ++i, ++n)
@@ -1479,7 +1490,7 @@ void eDVBChannel::getNextSourceSpan(off_t current_offset, size_t bytes_read, off
                                size = max;
                        else
                                size = aligned_end - current_offset;
-                       eDebug("HIT, %lld < %lld < %lld, size: %d", i->first, current_offset, i->second, size);
+                       eDebug("HIT, %lld < %lld < %lld, size: %zd", i->first, current_offset, i->second, size);
                        return;
                }
                if (current_offset < aligned_start)
@@ -1520,10 +1531,10 @@ void eDVBChannel::getNextSourceSpan(off_t current_offset, size_t bytes_read, off
                                        len = aligned_end - aligned_start;
 
                                start = aligned_end - len;
-                               eDebug("skipping to %llx, %d", start, len);
+                               eDebug("skipping to %llx, %zd", start, len);
                        }
 
-                       eDebug("result: %llx, %x (%llx %llx)", start, size, aligned_start, aligned_end);
+                       eDebug("result: %llx, %zx (%llx %llx)", start, size, aligned_start, aligned_end);
                        return;
                }
        }
@@ -1539,7 +1550,7 @@ void eDVBChannel::getNextSourceSpan(off_t current_offset, size_t bytes_read, off
        {
                start = current_offset;
                size = max;
-               eDebug("NO CUESHEET. (%08llx, %d)", start, size);
+               eDebug("NO CUESHEET. (%08llx, %zd)", start, size);
        } else
        {
                start = current_offset;
@@ -1657,6 +1668,18 @@ void eDVBChannel::SDTready(int result)
        m_SDT = 0;
 }
 
+int eDVBChannel::reserveDemux()
+{
+       ePtr<iDVBDemux> dmx;
+       if (!getDemux(dmx, 0))
+       {
+               uint8_t id;
+               if (!dmx->getCADemuxID(id))
+                       return id;
+       }
+       return -1;
+}
+
 RESULT eDVBChannel::requestTsidOnid(ePyObject callback)
 {
        if (PyCallable_Check(callback))
@@ -1730,6 +1753,20 @@ RESULT eDVBChannel::getCurrentFrontendParameters(ePtr<iDVBFrontendParameters> &p
 }
 
 RESULT eDVBChannel::playFile(const char *file)
+{
+       eRawFile *f = new eRawFile();
+       ePtr<iTsSource> source = f;
+
+       if (f->open(file) < 0)
+       {
+               eDebug("can't open PVR file %s (%m)", file);
+               return -ENOENT;
+       }
+
+       return playSource(source, file);
+}
+
+RESULT eDVBChannel::playSource(ePtr<iTsSource> &source, const char *streaminfo_file)
 {
        ASSERT(!m_frontend);
        if (m_pvr_thread)
@@ -1739,7 +1776,13 @@ RESULT eDVBChannel::playFile(const char *file)
                m_pvr_thread = 0;
        }
 
-       m_tstools.openFile(file);
+       if (!source->valid())
+       {
+               eDebug("PVR source is not valid!");
+               return -ENOENT;
+       }
+
+       m_tstools.setSource(source, streaminfo_file);
 
                /* DON'T EVEN THINK ABOUT FIXING THIS. FIX THE ATI SOURCES FIRST,
                   THEN DO A REAL FIX HERE! */
@@ -1764,15 +1807,9 @@ RESULT eDVBChannel::playFile(const char *file)
        m_pvr_thread->setStreamMode(1);
        m_pvr_thread->setScatterGather(this);
 
-       if (m_pvr_thread->start(file, m_pvr_fd_dst))
-       {
-               delete m_pvr_thread;
-               m_pvr_thread = 0;
-               ::close(m_pvr_fd_dst);
-               m_pvr_fd_dst = -1;
-               eDebug("can't open PVR file %s (%m)", file);
-               return -ENOENT;
-       }
+       m_event(this, evtPreStart);
+
+       m_pvr_thread->start(source, m_pvr_fd_dst);
        CONNECT(m_pvr_thread->m_event, eDVBChannel::pvrEvent);
 
        m_state = state_ok;
@@ -1781,7 +1818,7 @@ RESULT eDVBChannel::playFile(const char *file)
        return 0;
 }
 
-void eDVBChannel::stopFile()
+void eDVBChannel::stopSource()
 {
        if (m_pvr_thread)
        {
@@ -1791,6 +1828,13 @@ void eDVBChannel::stopFile()
        }
        if (m_pvr_fd_dst >= 0)
                ::close(m_pvr_fd_dst);
+       ePtr<iTsSource> d;
+       m_tstools.setSource(d);
+}
+
+void eDVBChannel::stopFile()
+{
+       stopSource();
 }
 
 void eDVBChannel::setCueSheet(eCueSheet *cuesheet)