aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFelix Domke <tmbinc@elitedvb.net>2006-01-20 23:39:33 +0000
committerFelix Domke <tmbinc@elitedvb.net>2006-01-20 23:39:33 +0000
commitad2bab318ec1271ae520606259c962382a519f0d (patch)
tree510729f472ebf9b65efb68cf5e9a0df49cf15cb3 /lib
parent32f4b90e3513e3cb4365e0ad1160de6e093f45d9 (diff)
downloadenigma2-ad2bab318ec1271ae520606259c962382a519f0d.tar.gz
enigma2-ad2bab318ec1271ae520606259c962382a519f0d.zip
filepush: scatter/gather support
Diffstat (limited to 'lib')
-rw-r--r--lib/base/filepush.cpp29
-rw-r--r--lib/base/filepush.h9
2 files changed, 35 insertions, 3 deletions
diff --git a/lib/base/filepush.cpp b/lib/base/filepush.cpp
index 60dc78ee..b99896fc 100644
--- a/lib/base/filepush.cpp
+++ b/lib/base/filepush.cpp
@@ -10,6 +10,7 @@
eFilePushThread::eFilePushThread(): m_messagepump(eApp, 0)
{
m_stop = 0;
+ m_sg = 0;
flush();
enablePVRCommit(0);
CONNECT(m_messagepump.recv_msg, eFilePushThread::recvEvent);
@@ -22,6 +23,10 @@ static void signal_handler(int x)
void eFilePushThread::thread()
{
off_t dest_pos = 0;
+ size_t bytes_read = 0;
+
+ off_t current_span_offset;
+ size_t current_span_remaining = 0;
int already_empty = 0;
eDebug("FILEPUSH THREAD START");
@@ -59,10 +64,29 @@ void eFilePushThread::thread()
m_buf_start += w;
continue;
}
-
+
/* now fill our buffer. */
+
+ if (m_sg && !current_span_remaining)
+ {
+ m_sg->getNextSourceSpan(bytes_read, current_span_offset, current_span_remaining);
+ bytes_read = 0;
+ }
+
+ size_t maxread = sizeof(m_buffer);
+
+ /* if we have a source span, don't read past the end */
+ if (m_sg && maxread < current_span_remaining)
+ maxread = current_span_remaining;
+
m_buf_start = 0;
- m_buf_end = read(m_fd_source, m_buffer, sizeof(m_buffer));
+ m_buf_end = 0;
+
+ if (maxread)
+ m_buf_end = read(m_fd_source, m_buffer, maxread);
+
+ bytes_read += m_buf_end;
+
if (m_buf_end < 0)
{
m_buf_end = 0;
@@ -84,7 +108,6 @@ void eFilePushThread::thread()
continue;
}
sendEvent(evtEOF);
-
#if 0
eDebug("FILEPUSH: end-of-file! (currently unhandled)");
if (!lseek(m_fd_source, 0, SEEK_SET))
diff --git a/lib/base/filepush.h b/lib/base/filepush.h
index f2bd98be..7e16fa02 100644
--- a/lib/base/filepush.h
+++ b/lib/base/filepush.h
@@ -6,6 +6,12 @@
#include <lib/base/message.h>
#include <sys/types.h>
+class iFilePushScatterGather
+{
+public:
+ virtual void getNextSourceSpan(size_t bytes_read, off_t &start, size_t &size)=0;
+};
+
class eFilePushThread: public eThread, public Object
{
public:
@@ -22,10 +28,13 @@ public:
void flush();
void enablePVRCommit(int);
+ void setSG(iFilePushScatterGather *);
+
enum { evtEOF, evtReadError, evtWriteError };
Signal1<void,int> m_event;
private:
+ iFilePushScatterGather *m_sg;
int m_stop;
unsigned char m_buffer[65536];
int m_buf_start, m_buf_end;