- add pause/seek/resume functions to filepush
authorFelix Domke <tmbinc@elitedvb.net>
Tue, 25 Oct 2005 21:38:50 +0000 (21:38 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Tue, 25 Oct 2005 21:38:50 +0000 (21:38 +0000)
lib/base/filepush.cpp
lib/base/filepush.h

index 5ae2f15d7408daf277fe9b34b52241f9a59473fb..17b767f837561f27bf9db000263c5f3ad97a5e4b 100644 (file)
@@ -34,6 +34,7 @@ void eFilePushThread::thread()
                {
                                // TODO: take care of boundaries.
                        int w = write(m_fd_dest, m_buffer + m_buf_start, m_buf_end - m_buf_start);
+                       eDebug("wrote %d bytes", w);
                        if (w <= 0)
                        {
                                if (errno == -EINTR)
@@ -42,6 +43,7 @@ void eFilePushThread::thread()
                                // ... we would stop the thread
                        }
 
+                               /* this should flush all written pages to disk. */
                        posix_fadvise(m_fd_dest, dest_pos, w, POSIX_FADV_DONTNEED);
 
                        dest_pos += w;
@@ -80,8 +82,7 @@ void eFilePushThread::start(int fd_source, int fd_dest)
 {
        m_fd_source = fd_source;
        m_fd_dest = fd_dest;
-       m_stop = 0;
-       run();
+       resume();
 }
 
 void eFilePushThread::stop()
@@ -90,3 +91,19 @@ void eFilePushThread::stop()
        sendSignal(SIGUSR1);
        kill();
 }
+
+void eFilePushThread::pause()
+{
+       stop();
+}
+
+void eFilePushThread::seek(off_t where)
+{
+       ::lseek(m_fd_source, where, SEEK_SET);
+}
+
+void eFilePushThread::resume()
+{
+       m_stop = 0;
+       run();
+}
index b8d9f22176ef0f613c31c8cee03ccbee95195556..ed2dc2ebbbb87d63a9cc4993a28a5b9afc9becc5 100644 (file)
@@ -2,6 +2,7 @@
 #define __lib_base_filepush_h
 
 #include <lib/base/thread.h>
+#include <sys/types.h>
 
 class eFilePushThread: public eThread
 {
@@ -10,6 +11,11 @@ public:
        void thread();
        void stop();
        void start(int sourcefd, int destfd);
+       
+       void pause();
+       void seek(off_t where);
+       void resume();
+       
 private:
        int m_stop;
        unsigned char m_buffer[65536];