add a blinking point to the infobar
[enigma2.git] / lib / dvb / demux.cpp
index 329eafda2a6bee9586d1327ca71bbd6c95d86840..d7fcaccf31ae3db2518da3e12acdb36d1dcc7201 100644 (file)
@@ -6,7 +6,6 @@
 #include <unistd.h>
 #include <signal.h>
 
-
 #if HAVE_DVB_API_VERSION < 3
 #include <ost/dmx.h>
 #ifndef DMX_SET_NEGFILTER_MASK
@@ -34,8 +33,46 @@ eDVBDemux::~eDVBDemux()
 {
 }
 
+int eDVBDemux::openDemux(void)
+{
+       char filename[128];
+#if HAVE_DVB_API_VERSION < 3
+       snprintf(filename, 128, "/dev/dvb/card%d/demux%d", adapter, demux);
+#else
+       snprintf(filename, 128, "/dev/dvb/adapter%d/demux%d", adapter, demux);
+#endif
+       return ::open(filename, O_RDWR);
+}
+
 DEFINE_REF(eDVBDemux)
 
+RESULT eDVBDemux::setSourceFrontend(int fenum)
+{
+#if HAVE_DVB_API_VERSION >= 3
+       int fd = openDemux();
+       
+       int n = DMX_SOURCE_FRONT0 + fenum;
+       int res = ::ioctl(fd, DMX_SET_SOURCE, &n);
+       if (res)
+               eDebug("DMX_SET_SOURCE failed! - %m");
+       ::close(fd);
+       return res;
+#endif
+       return 0;
+}
+
+RESULT eDVBDemux::setSourcePVR(int pvrnum)
+{
+#if HAVE_DVB_API_VERSION >= 3
+       int fd = openDemux();
+       int n = DMX_SOURCE_DVR0 + pvrnum;
+       int res = ::ioctl(fd, DMX_SET_SOURCE, &n);
+       ::close(fd);
+       return res;
+#endif
+       return 0;
+}
+
 RESULT eDVBDemux::createSectionReader(eMainloop *context, ePtr<iDVBSectionReader> &reader)
 {
        RESULT res;
@@ -61,13 +98,7 @@ RESULT eDVBDemux::getMPEGDecoder(ePtr<iTSMPEGDecoder> &decoder)
 
 RESULT eDVBDemux::getSTC(pts_t &pts)
 {
-       char filename[128];
-#if HAVE_DVB_API_VERSION < 3
-       sprintf(filename, "/dev/dvb/card%d/demux%d", adapter, demux);
-#else
-       sprintf(filename, "/dev/dvb/adapter%d/demux%d", adapter, demux);
-#endif
-       int fd = ::open(filename, O_RDWR);
+       int fd = openDemux();
        
        if (fd < 0)
                return -ENODEV;
@@ -131,14 +162,7 @@ void eDVBSectionReader::data(int)
 eDVBSectionReader::eDVBSectionReader(eDVBDemux *demux, eMainloop *context, RESULT &res): demux(demux)
 {
        char filename[128];
-#if HAVE_DVB_API_VERSION < 3
-       sprintf(filename, "/dev/dvb/card%d/demux%d", demux->adapter, demux->demux);
-#else
-       sprintf(filename, "/dev/dvb/adapter%d/demux%d", demux->adapter, demux->demux);
-#endif
-       fd = ::open(filename, O_RDWR);
-       
-       eDebug("eDVBSectionReader has fd %d", fd);
+       fd = demux->openDemux();
        
        if (fd >= 0)
        {
@@ -192,6 +216,8 @@ RESULT eDVBSectionReader::start(const eDVBSectionFilterMask &mask)
        memcpy(sct.filter.mask, mask.mask, DMX_FILTER_SIZE);
 #if HAVE_DVB_API_VERSION >= 3
        memcpy(sct.filter.mode, mask.mode, DMX_FILTER_SIZE);
+       if (::ioctl(fd, DMX_SET_BUFFER_SIZE, 8192*8) < 0)
+               eDebug("DMX_SET_BUFFER_SIZE failed(%m)");
 #endif
        
        res = ::ioctl(fd, DMX_SET_FILTER, &sct);
@@ -343,16 +369,10 @@ RESULT eDVBTSRecorder::connectEvent(const Slot1<void,int> &event, ePtr<eConnecti
 
 RESULT eDVBTSRecorder::startPID(int pid)
 {
-       char filename[128];
-#if HAVE_DVB_API_VERSION < 3
-       snprintf(filename, 128, "/dev/dvb/card%d/demux%d", m_demux->adapter, m_demux->demux);
-#else
-       snprintf(filename, 128, "/dev/dvb/adapter%d/demux%d", m_demux->adapter, m_demux->demux);
-#endif
-       int fd = ::open(filename, O_RDWR);
+       int fd = m_demux->openDemux();
        if (fd < 0)
        {
-               eDebug("FAILED to open demux (%s) in ts recoder (%m)", filename);
+               eDebug("FAILED to open demux in ts recoder (%m)");
                return -1;
        }