MythTV  master
fifowriter.h
Go to the documentation of this file.
1 #ifndef FIFOWRITER
2 #define FIFOWRITER
3 
4 // Qt headers
5 #include <QWaitCondition>
6 #include <QString>
7 #include <QMutex>
8 
9 // MythTV headers
10 #include "mythtvexp.h"
11 #include "mthread.h"
12 
13 using namespace std;
14 
15 class FIFOWriter;
16 
17 class FIFOThread : public MThread
18 {
19  public:
20  FIFOThread() : MThread("FIFOThread") {}
21  ~FIFOThread() override { wait(); m_parent = nullptr; m_id = -1; }
22  void SetId(int id) { m_id = id; }
23  void SetParent(FIFOWriter *parent) { m_parent = parent; }
24  void run(void) override; // MThread
25  private:
26  FIFOWriter *m_parent {nullptr};
27  int m_id {-1};
28 };
29 
31 {
32  friend class FIFOThread;
33  public:
34  FIFOWriter(int count, bool sync);
35  FIFOWriter(const FIFOWriter& rhs);
36  ~FIFOWriter(void);
37 
38  bool FIFOInit(int id, const QString& desc, const QString& name, long size, int num_bufs);
39  void FIFOWrite(int id, void *buf, long size);
40  void FIFODrain(void);
41 
42  private:
43  void FIFOWriteThread(int id);
44 
45  struct fifo_buf
46  {
47  struct fifo_buf *next;
48  unsigned char *data;
49  long blksize;
50  };
51  fifo_buf **m_fifoBuf {nullptr};
52  fifo_buf **m_fbInptr {nullptr};
53  fifo_buf **m_fbOutptr {nullptr};
54 
55  FIFOThread *m_fifoThrds {nullptr};
56  QMutex *m_fifoLock {nullptr};
57  QWaitCondition *m_fullCond {nullptr};
58  QWaitCondition *m_emptyCond {nullptr};
59 
60  QString *m_filename {nullptr};
61  QString *m_fbDesc {nullptr};
62 
63  long *m_maxBlkSize {nullptr};
64  int *m_killWr {nullptr};
65  int *m_fbCount {nullptr};
66  int *m_fbMaxCount {nullptr};
67  int m_numFifos {0};
68  bool m_useSync;
69 };
70 
71 #endif
72 
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:46
struct fifo_buf * next
Definition: fifowriter.h:47
#define MTV_PUBLIC
Definition: mythtvexp.h:15
unsigned char * data
Definition: fifowriter.h:48
~FIFOThread() override
Definition: fifowriter.h:21
bool m_useSync
Definition: fifowriter.h:68
void SetParent(FIFOWriter *parent)
Definition: fifowriter.h:23
void SetId(int id)
Definition: fifowriter.h:22