- add double buffering, flip, sync grc opcode, add render-idle-notify.\n - add ...
[enigma2.git] / lib / dvb / dvb.cpp
index cfb32d09e7f771a2cf57bc81d25f53c439924237..3e4c7bdc8ea4fc53c47e8ff020d0baac7fd3c4fc 100644 (file)
@@ -552,14 +552,39 @@ RESULT eDVBChannel::getLength(pts_t &len)
 
 RESULT eDVBChannel::getCurrentPosition(pts_t &pos)
 {
-#if 0
        off_t begin = 0;
                /* getPTS for offset 0 is cached, so it doesn't harm. */
        int r = m_tstools.getPTS(begin, pos);
        if (r)
+       {
+               eDebug("tstools getpts(0) failed!");
                return r;
+       }
+       
+       pts_t now;
+       
+       r = m_demux->get().getSTC(now);
+
+       if (r)
+       {
+               eDebug("demux getSTC failed");
+               return -1;
+       }
+       
+       eDebug("STC: %08llx PTS: %08llx, diff %lld", now, pos, now - pos);
+       
+               /* when we are less than 10 seconds before the start, return 0. */
+               /* (we're just waiting for the timespam to start) */
+       if ((now < pos) && ((pos - now) < 90000 * 10))
+       {
+               pos = 0;
+               return 0;
+       }
+       
+       if (now < pos) /* wrap around */
+               pos = now + ((pts_t)1)<<33 - pos;
+       else
+               pos = now - pos;
        
-       // DMX_GET_STC 
-#endif
        return 0;
 }