filepush: do not loop anymore on eof, but signal an event
authorFelix Domke <tmbinc@elitedvb.net>
Tue, 17 Jan 2006 00:21:01 +0000 (00:21 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Tue, 17 Jan 2006 00:21:01 +0000 (00:21 +0000)
lib/base/filepush.cpp
lib/base/filepush.h

index cb22ea1..7ab8c0d 100644 (file)
@@ -4,10 +4,11 @@
 #include <errno.h>
 #include <fcntl.h>
 
-eFilePushThread::eFilePushThread()
+eFilePushThread::eFilePushThread(): m_messagepump(eApp, 0)
 {
        m_stop = 0;
        flush();
+       CONNECT(m_messagepump.recv_msg, eFilePushThread::recvEvent);
 }
 
 static void signal_handler(int x)
@@ -65,12 +66,16 @@ void eFilePushThread::thread()
                }
                if (m_buf_end == 0)
                {
+                       sendEvent(evtEOF);
+
+#if 0
                        eDebug("FILEPUSH: end-of-file! (currently unhandled)");
                        if (!lseek(m_fd_source, 0, SEEK_SET))
                        {
                                eDebug("(looping)");
                                continue;
                        }
+#endif
                        break;
                }
 //             printf("FILEPUSH: read %d bytes\n", m_buf_end);
@@ -114,3 +119,13 @@ void eFilePushThread::flush()
        m_buf_start = m_buf_end = 0;
 }
 
+
+void eFilePushThread::sendEvent(int evt)
+{
+       m_messagepump.send(evt);
+}
+
+void eFilePushThread::recvEvent(const int &evt)
+{
+       m_event(evt);
+}
index a419d71..7eb7997 100644 (file)
@@ -2,9 +2,11 @@
 #define __lib_base_filepush_h
 
 #include <lib/base/thread.h>
+#include <libsig_comp.h>
+#include <lib/base/message.h>
 #include <sys/types.h>
 
-class eFilePushThread: public eThread
+class eFilePushThread: public eThread, public Object
 {
 public:
        eFilePushThread();
@@ -19,11 +21,19 @@ public:
                /* flushes the internal readbuffer */ 
        void flush();
        
+       enum { evtEOF, evtReadError, evtWriteError };
+       Signal1<void,int> m_event;
+       
 private:
        int m_stop;
        unsigned char m_buffer[65536];
        int m_buf_start, m_buf_end;
        int m_fd_source, m_fd_dest;
+       
+       eFixedMessagePump<int> m_messagepump;
+       
+       void sendEvent(int evt);
+       void recvEvent(const int &evt);
 };
 
 #endif