add stream-mode to filepush, which will retry on eof until stream grows
authorFelix Domke <tmbinc@elitedvb.net>
Tue, 17 Apr 2007 15:45:23 +0000 (15:45 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Tue, 17 Apr 2007 15:45:23 +0000 (15:45 +0000)
lib/base/filepush.cpp
lib/base/filepush.h

index 8424ae4197fd219469d3702b2c7be4f68e60b89f..92c580c22d43c22cb6c05ce2915b507ce6a8cc69 100644 (file)
@@ -11,6 +11,8 @@ eFilePushThread::eFilePushThread(int io_prio_class, int io_prio_level)
 {
        m_stop = 0;
        m_sg = 0;
 {
        m_stop = 0;
        m_sg = 0;
+       m_send_pvr_commit = 0;
+       m_stream_mode = 0;
        flush();
        enablePVRCommit(0);
        CONNECT(m_messagepump.recv_msg, eFilePushThread::recvEvent);
        flush();
        enablePVRCommit(0);
        CONNECT(m_messagepump.recv_msg, eFilePushThread::recvEvent);
@@ -128,7 +130,19 @@ void eFilePushThread::thread()
                                                /* well check again */
                                continue;
                        }
                                                /* well check again */
                                continue;
                        }
+                       
+                               /* in stream_mode, we are sending EOF events 
+                                  over and over until somebody responds.
+                                  
+                                  in stream_mode, think of evtEOF as "buffer underrun occured". */
                        sendEvent(evtEOF);
                        sendEvent(evtEOF);
+
+                       if (m_stream_mode)
+                       {
+                               eDebug("reached EOF, but we are in stream mode. delaying 1 second.");
+                               sleep(1);
+                               continue;
+                       }
 #if 0
                        eDebug("FILEPUSH: end-of-file! (currently unhandled)");
                        if (!m_raw_source.lseek(0, SEEK_SET))
 #if 0
                        eDebug("FILEPUSH: end-of-file! (currently unhandled)");
                        if (!m_raw_source.lseek(0, SEEK_SET))
@@ -214,6 +228,11 @@ void eFilePushThread::enablePVRCommit(int s)
        m_send_pvr_commit = s;
 }
 
        m_send_pvr_commit = s;
 }
 
+void eFilePushThread::setStreamMode(int s)
+{
+       m_stream_mode = s;
+}
+
 void eFilePushThread::setScatterGather(iFilePushScatterGather *sg)
 {
        m_sg = sg;
 void eFilePushThread::setScatterGather(iFilePushScatterGather *sg)
 {
        m_sg = sg;
index 0749cd43d4b3f0c68b19c44e5afd37e7a06b088d..d3f32d75cb3b2bc1d93673562bbe7062bd9d5dd8 100644 (file)
@@ -33,6 +33,9 @@ public:
        void flush();
        void enablePVRCommit(int);
        
        void flush();
        void enablePVRCommit(int);
        
+               /* stream mode will wait on EOF until more data is available. */
+       void setStreamMode(int);
+       
        void setScatterGather(iFilePushScatterGather *);
        
        enum { evtEOF, evtReadError, evtWriteError, evtUser };
        void setScatterGather(iFilePushScatterGather *);
        
        enum { evtEOF, evtReadError, evtWriteError, evtUser };
@@ -52,7 +55,8 @@ private:
        int m_buf_start, m_buf_end;
        int m_fd_dest;
        int m_send_pvr_commit;
        int m_buf_start, m_buf_end;
        int m_fd_dest;
        int m_send_pvr_commit;
-       
+       int m_stream_mode;
+
        eRawFile m_raw_source;
        
        eFixedMessagePump<int> m_messagepump;
        eRawFile m_raw_source;
        
        eFixedMessagePump<int> m_messagepump;