save config (if changed) by "quit" from infobar
[enigma2.git] / lib / dvb / dvb.cpp
index cfb32d09e7f771a2cf57bc81d25f53c439924237..90df72677b8d7e67713189e01cfbf6cf2fe85f47 100644 (file)
@@ -552,14 +552,38 @@ 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;
 }