enable playback of multifile (split) movies
[enigma2.git] / lib / dvb / dvb.cpp
index 5bd8fe6af44eeb3ca232db164ae6eb0784bc0e03..f8f9527694498e37b77b15a8f8d10cc585bdce5f 100644 (file)
@@ -767,9 +767,9 @@ void eDVBChannel::getNextSourceSpan(off_t current_offset, size_t bytes_read, off
                int relative = seek.first;
                pts_t pts = seek.second;
 
+               pts_t now = 0;
                if (relative)
                {
-                       pts_t now;
                        if (!m_cue->m_decoder)
                        {
                                eDebug("no decoder - can't seek relative");
@@ -785,11 +785,29 @@ void eDVBChannel::getNextSourceSpan(off_t current_offset, size_t bytes_read, off
                                eDebug("seekTo: getCurrentPosition failed!");
                                continue;
                        }
-                       pts += now;
                }
+               
+               if (relative == 1) /* pts relative */
+                       pts += now;
 
-               if (pts < 0)
-                       pts = 0;
+               if (relative != 2)
+                       if (pts < 0)
+                               pts = 0;
+               
+               if (relative == 2) /* AP relative */
+               {
+                       eDebug("AP relative seeking: %lld, at %lld", pts, now);
+                       pts_t nextap;
+                       if (m_tstools.getNextAccessPoint(nextap, now, pts))
+                       {
+                               pts = now;
+                               eDebug("AP relative seeking failed!");
+                       } else
+                       {
+                               eDebug("next ap is %llx\n", pts);
+                               pts = nextap;
+                       }
+               }
                
                off_t offset = 0;
                if (m_tstools.getOffset(offset, pts))
@@ -854,9 +872,6 @@ void eDVBChannel::getNextSourceSpan(off_t current_offset, size_t bytes_read, off
        start = current_offset;
        size = max;
        eDebug("END OF CUESHEET. (%08llx, %d)", start, size);
-       
-       if (size < 4096)
-               eFatal("blub");
        return;
 }
 
@@ -993,14 +1008,6 @@ RESULT eDVBChannel::playFile(const char *file)
                return -ENODEV;
        }
        
-       m_pvr_fd_src = open(file, O_RDONLY|O_LARGEFILE);
-       if (m_pvr_fd_src < 0)
-       {
-               eDebug("can't open PVR m_pvr_fd_src file %s (%m)", file);
-               close(m_pvr_fd_dst);
-               return -ENOENT;
-       }
-       
        m_state = state_ok;
        m_stateChanged(this);
        
@@ -1008,7 +1015,13 @@ RESULT eDVBChannel::playFile(const char *file)
        m_pvr_thread->enablePVRCommit(1);
        m_pvr_thread->setScatterGather(this);
 
-       m_pvr_thread->start(m_pvr_fd_src, m_pvr_fd_dst);
+       if (m_pvr_thread->start(file, m_pvr_fd_dst))
+       {
+               delete m_pvr_thread;
+               m_pvr_thread = 0;
+               eDebug("can't open PVR file %s (%m)", file);
+               return -ENOENT;
+       }
        CONNECT(m_pvr_thread->m_event, eDVBChannel::pvrEvent);
 
        return 0;
@@ -1019,7 +1032,6 @@ void eDVBChannel::stopFile()
        if (m_pvr_thread)
        {
                m_pvr_thread->stop();
-               ::close(m_pvr_fd_src);
                ::close(m_pvr_fd_dst);
                delete m_pvr_thread;
                m_pvr_thread = 0;