00001 #ifndef FIFOWRITER
00002 #define FIFOWRITER
00003
00004
00005 #include <pthread.h>
00006
00007
00008 #include <qstring.h>
00009 #include <qmutex.h>
00010 #include <qptrqueue.h>
00011
00012
00013 #include "mythexp.h"
00014
00015 using namespace std;
00016
00017 class MPUBLIC FIFOWriter
00018 {
00019 public:
00020 FIFOWriter(int count, bool sync);
00021 ~FIFOWriter();
00022
00023 int FIFOInit(int id, QString desc, QString name, long size, int num_bufs);
00024 void FIFOWrite(int id, void *buf, long size);
00025 void FIFODrain(void);
00026
00027 private:
00028 void FIFOWriteThread(void);
00029 static void *FIFOStartThread(void *param);
00030
00031 struct fifo_buf
00032 {
00033 struct fifo_buf *next;
00034 unsigned char *data;
00035 long blksize;
00036 } **fifo_buf, **fb_inptr, **fb_outptr;
00037
00038 pthread_t *fifothrds;
00039 pthread_mutex_t *fifo_lock;
00040 pthread_cond_t *full_cond, *empty_cond;
00041
00042 QString *filename, *fbdesc;
00043
00044 long *maxblksize;
00045 int *killwr, *fbcount;
00046 int num_fifos;
00047 bool usesync;
00048 int cur_id;
00049 };
00050
00051 #endif
00052