set frontend state to stateTuning when tuneloop starts.. ( to avoid false lostlock...
[enigma2.git] / lib / dvb / demux.cpp
index 6c783d38024aebe91ff0f771f24bcc23228ed8b6..384a77e15872e4e280be0062ad60593760d1d8eb 100644 (file)
@@ -8,9 +8,21 @@
 
 #if HAVE_DVB_API_VERSION < 3
 #include <ost/dmx.h>
+
 #ifndef DMX_SET_NEGFILTER_MASK
        #define DMX_SET_NEGFILTER_MASK   _IOW('o',48,uint8_t *)
 #endif
+
+#ifndef DMX_GET_STC
+       struct dmx_stc
+       {
+               unsigned int num;       /* input : which STC? O..N */
+               unsigned int base;      /* output: divisor for stc to get 90 kHz clock */
+               unsigned long long stc; /* output: src in 'base'*90 kHz units */
+       };
+       #define DMX_GET_STC             _IOR('o', 50, struct dmx_stc)
+#endif
+
 #else
 #include <linux/dvb/dmx.h>
 #endif
@@ -50,7 +62,11 @@ RESULT eDVBDemux::setSourceFrontend(int fenum)
 {
 #if HAVE_DVB_API_VERSION >= 3
        int fd = openDemux();
-       int res = ::ioctl(fd, DMX_SET_SOURCE, DMX_SOURCE_FRONT0 + fenum);
+       
+       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
@@ -61,7 +77,8 @@ RESULT eDVBDemux::setSourcePVR(int pvrnum)
 {
 #if HAVE_DVB_API_VERSION >= 3
        int fd = openDemux();
-       int res = ::ioctl(fd, DMX_SET_SOURCE, DMX_SOURCE_DVR0 + pvrnum);
+       int n = DMX_SOURCE_DVR0 + pvrnum;
+       int res = ::ioctl(fd, DMX_SET_SOURCE, &n);
        ::close(fd);
        return res;
 #endif
@@ -91,7 +108,7 @@ RESULT eDVBDemux::getMPEGDecoder(ePtr<iTSMPEGDecoder> &decoder)
        return 0;
 }
 
-RESULT eDVBDemux::getSTC(pts_t &pts)
+RESULT eDVBDemux::getSTC(pts_t &pts, int num)
 {
        int fd = openDemux();
        
@@ -99,7 +116,7 @@ RESULT eDVBDemux::getSTC(pts_t &pts)
                return -ENODEV;
 
        struct dmx_stc stc;
-       stc.num = 0;
+       stc.num = num;
        stc.base = 1;
        
        if (ioctl(fd, DMX_GET_STC, &stc) < 0)
@@ -401,6 +418,7 @@ RESULT eDVBTSRecorder::startPID(int pid)
 
 void eDVBTSRecorder::stopPID(int pid)
 {
-       ::close(m_pids[pid]);
+       if (m_pids[pid] != -1)
+               ::close(m_pids[pid]);
        m_pids[pid] = -1;
 }