another try to fix ScanSetup
[enigma2.git] / lib / base / filepush.cpp
index 5ae2f15..73dc519 100644 (file)
@@ -1,3 +1,4 @@
+#include <config.h>
 #include <lib/base/filepush.h>
 #include <lib/base/eerror.h>
 #include <errno.h>
@@ -6,7 +7,7 @@
 eFilePushThread::eFilePushThread()
 {
        m_stop = 0;
-       m_buf_start = m_buf_end = 0;
+       flush();
 }
 
 static void signal_handler(int x)
@@ -34,6 +35,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 +44,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 +83,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 +92,25 @@ void eFilePushThread::stop()
        sendSignal(SIGUSR1);
        kill();
 }
+
+void eFilePushThread::pause()
+{
+       stop();
+}
+
+void eFilePushThread::seek(int whence, off_t where)
+{
+       ::lseek(m_fd_source, where, whence);
+}
+
+void eFilePushThread::resume()
+{
+       m_stop = 0;
+       run();
+}
+
+void eFilePushThread::flush()
+{
+       m_buf_start = m_buf_end = 0;
+}
+