make refcount value volatile
[enigma2.git] / lib / base / filepush.h
1 #ifndef __lib_base_filepush_h
2 #define __lib_base_filepush_h
3
4 #include <lib/base/thread.h>
5 #include <lib/base/ioprio.h>
6 #include <libsig_comp.h>
7 #include <lib/base/message.h>
8 #include <sys/types.h>
9 #include <lib/base/rawfile.h>
10
11 class iFilePushScatterGather
12 {
13 public:
14         virtual void getNextSourceSpan(off_t current_offset, size_t bytes_read, off_t &start, size_t &size)=0;
15         virtual ~iFilePushScatterGather() {}
16 };
17
18 class eFilePushThread: public eThread, public Object
19 {
20         int prio_class, prio;
21 public:
22         eFilePushThread(int prio_class=IOPRIO_CLASS_BE, int prio_level=0);
23         void thread();
24         void stop();
25         void start(int sourcefd, int destfd);
26         int start(const char *filename, int destfd);
27         
28         void pause();
29         void seek(int whence, off_t where);
30         void resume();
31         
32                 /* flushes the internal readbuffer */ 
33         void flush();
34         void enablePVRCommit(int);
35         
36         void setScatterGather(iFilePushScatterGather *);
37         
38         enum { evtEOF, evtReadError, evtWriteError, evtUser };
39         Signal1<void,int> m_event;
40
41         void installSigUSR1Handler();
42         void before_set_thread_alive();
43
44                 /* you can send private events if you want */
45         void sendEvent(int evt);
46 protected:
47         virtual void filterRecordData(const unsigned char *data, int len);
48 private:
49         iFilePushScatterGather *m_sg;
50         int m_stop;
51         unsigned char m_buffer[65536];
52         int m_buf_start, m_buf_end;
53         int m_fd_dest;
54         int m_send_pvr_commit;
55         
56         eRawFile m_raw_source;
57         
58         eFixedMessagePump<int> m_messagepump;
59         
60         void recvEvent(const int &evt);
61 };
62
63 #endif