From: ghost Date: Tue, 9 Nov 2010 22:30:14 +0000 (+0100) Subject: filepush.h/cpp: migrate to iDataSource X-Git-Tag: master-2010.12^2~18 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/6855a6ae6701f8d29540551fcff971316b5d49f1 filepush.h/cpp: migrate to iDataSource --- diff --git a/lib/base/filepush.cpp b/lib/base/filepush.cpp index 91f24ba0..0d599f96 100644 --- a/lib/base/filepush.cpp +++ b/lib/base/filepush.cpp @@ -47,7 +47,7 @@ void eFilePushThread::thread() hasStarted(); - source_pos = m_raw_source.lseek(0, SEEK_CUR); + source_pos = m_raw_source->lseek(0, SEEK_CUR); /* m_stop must be evaluated after each syscall. */ while (!m_stop) @@ -141,7 +141,7 @@ void eFilePushThread::thread() ASSERT(!(current_span_remaining % m_blocksize)); if (source_pos != current_span_offset) - source_pos = m_raw_source.lseek(current_span_offset, SEEK_SET); + source_pos = m_raw_source->lseek(current_span_offset, SEEK_SET); bytes_read = 0; } @@ -159,7 +159,7 @@ void eFilePushThread::thread() m_buf_end = 0; if (maxread) - m_buf_end = m_raw_source.read(m_buffer, maxread); + m_buf_end = m_raw_source->read(m_buffer, maxread); if (m_buf_end < 0) { @@ -178,7 +178,7 @@ void eFilePushThread::thread() int d = m_buf_end % m_blocksize; if (d) { - m_raw_source.lseek(-d, SEEK_CUR); + m_raw_source->lseek(-d, SEEK_CUR); m_buf_end -= d; } @@ -218,7 +218,7 @@ void eFilePushThread::thread() } #if 0 eDebug("FILEPUSH: end-of-file! (currently unhandled)"); - if (!m_raw_source.lseek(0, SEEK_SET)) + if (!m_raw_source->lseek(0, SEEK_SET)) { eDebug("(looping)"); continue; @@ -239,20 +239,30 @@ void eFilePushThread::thread() eDebug("FILEPUSH THREAD STOP"); } -void eFilePushThread::start(int fd_source, int fd_dest) +void eFilePushThread::start(int fd, int fd_dest) { - m_raw_source.setfd(fd_source); + eRawFile *f = new eRawFile(); + f->setfd(fd); + m_raw_source = f; m_fd_dest = fd_dest; resume(); } -int eFilePushThread::start(const char *filename, int fd_dest) +int eFilePushThread::start(const char *file, int fd_dest) { - if (m_raw_source.open(filename) < 0) + eRawFile *f = new eRawFile(); + ePtr source = f; + if (f->open(file) < 0) return -1; + start(source, fd_dest); + return 0; +} + +void eFilePushThread::start(ePtr source, int fd_dest) +{ + m_raw_source = source; m_fd_dest = fd_dest; resume(); - return 0; } void eFilePushThread::stop() @@ -275,7 +285,7 @@ void eFilePushThread::pause() void eFilePushThread::seek(int whence, off_t where) { - m_raw_source.lseek(where, whence); + m_raw_source->lseek(where, whence); } void eFilePushThread::resume() diff --git a/lib/base/filepush.h b/lib/base/filepush.h index 71ee9979..75df7ab7 100644 --- a/lib/base/filepush.h +++ b/lib/base/filepush.h @@ -24,7 +24,9 @@ public: void stop(); void start(int sourcefd, int destfd); int start(const char *filename, int destfd); - + + void start(ePtr source, int destfd); + void pause(); void seek(int whence, off_t where); void resume(); @@ -58,10 +60,10 @@ private: int m_stream_mode; int m_blocksize; - eRawFile m_raw_source; - + ePtr m_raw_source; + eFixedMessagePump m_messagepump; - + void recvEvent(const int &evt); };