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  virtual ~FIFOThread() { 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  typedef struct fifo_buf
46  {
47  struct fifo_buf *next;
48  unsigned char *data;
49  long blksize;
50  } fifo_buf_t;
51  fifo_buf_t **m_fifo_buf {nullptr};
52  fifo_buf_t **m_fb_inptr {nullptr};
53  fifo_buf_t **m_fb_outptr {nullptr};
54 
55  FIFOThread *m_fifothrds {nullptr};
56  QMutex *m_fifo_lock {nullptr};
57  QWaitCondition *m_full_cond {nullptr};
58  QWaitCondition *m_empty_cond {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};
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
static int run(MythMediaDevice *dev=nullptr, bool startRandomShow=false)
int m_num_fifos
Definition: fifowriter.h:67
#define MTV_PUBLIC
Definition: mythtvexp.h:15
unsigned char * data
Definition: fifowriter.h:48
virtual ~FIFOThread()
Definition: fifowriter.h:21
const char * name
Definition: ParseText.cpp:328
void SetParent(FIFOWriter *parent)
Definition: fifowriter.h:23
bool m_usesync
Definition: fifowriter.h:68
void SetId(int id)
Definition: fifowriter.h:22