MythTV  master
output.h
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 // Copyright (c) 2000-2001 Brad Hughes <bhughes@trolltech.com>
3 //
4 // Use, modification and distribution is allowed without limitation,
5 // warranty, or liability of any kind.
6 //
7 
8 #ifndef OUTPUT_H
9 #define OUTPUT_H
10 
11 class OutputListeners;
12 class OutputEvent;
13 
14 #include <vector>
15 
16 #include <QMutex>
17 #include <QList>
18 
19 #include "mythobservable.h"
20 #include "mythexp.h"
21 
22 class QObject;
23 class Buffer;
24 
25 namespace MythTV {
26 class Visual;
27 }
28 
30 {
31  public:
32  explicit OutputEvent(Type type) :
33  MythEvent(type) {}
34  OutputEvent(long s, unsigned long w, int b, int f, int p, int c) :
35  MythEvent(Info), m_elaspedSeconds(s), m_writtenBytes(w),
36  m_brate(b), m_freq(f), m_prec(p), m_chan(c) {}
37  explicit OutputEvent(const QString &e) :
38  MythEvent(Error)
39  {
40  QByteArray tmp = e.toUtf8();
41  m_errorMsg = new QString(tmp.constData());
42  }
43 
44  ~OutputEvent() override
45  {
46  delete m_errorMsg;
47  }
48 
49  OutputEvent &operator=(const OutputEvent&) = delete;
50 
51  const QString *errorMessage() const { return m_errorMsg; }
52 
53  const long &elapsedSeconds() const { return m_elaspedSeconds; }
54  const unsigned long &writtenBytes() const { return m_writtenBytes; }
55  const int &bitrate() const { return m_brate; }
56  const int &frequency() const { return m_freq; }
57  const int &precision() const { return m_prec; }
58  const int &channels() const { return m_chan; }
59 
60  MythEvent *clone(void) const override // MythEvent
61  { return new OutputEvent(*this); }
62 
63  static Type Playing;
64  static Type Buffering;
65  static Type Info;
66  static Type Paused;
67  static Type Stopped;
68  static Type Error;
69 
70  private:
72  m_elaspedSeconds(o.m_elaspedSeconds),
73  m_writtenBytes(o.m_writtenBytes),
74  m_brate(o.m_brate), m_freq(o.m_freq),
75  m_prec(o.m_prec), m_chan(o.m_chan)
76  {
77  if (o.m_errorMsg)
78  {
79  m_errorMsg = new QString(*o.m_errorMsg);
80  }
81  }
82 
83  private:
84  QString *m_errorMsg {nullptr};
85 
86  long m_elaspedSeconds {0};
87  unsigned long m_writtenBytes {0};
88  int m_brate {0};
89  int m_freq {0};
90  int m_prec {0};
91  int m_chan {0};
92 };
93 
94 using Visuals = std::vector<MythTV::Visual*>;
95 
97 {
98 public:
99  OutputListeners() = default;
100  ~OutputListeners() override = default;
101 
102  bool hasVisual(void) { return !m_visuals.empty(); }
103  void addVisual(MythTV::Visual *v);
104  void removeVisual(MythTV::Visual *v);
105 
106  QMutex *mutex() { return &m_mtx; }
107 
108  void setBufferSize(unsigned int sz) { m_bufsize = sz; }
109  unsigned int bufferSize() const { return m_bufsize; }
110 
111 protected:
112  void error(const QString &e);
113  void dispatchVisual(uchar *b, unsigned long b_len,
114  unsigned long written, int chan, int prec);
115  void prepareVisuals();
116 
117 private:
118  Q_DISABLE_COPY(OutputListeners)
119 
120  QMutex m_mtx;
121  Visuals m_visuals;
122 
123  unsigned int m_bufsize {0};
124 };
125 
126 
127 #endif // OUTPUT_H
OutputListeners::OutputListeners
OutputListeners()=default
e
QDomElement e
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:1417
MPUBLIC
#define MPUBLIC
Definition: mythexp.h:10
OutputEvent::Buffering
static Type Buffering
Definition: output.h:64
error
static void error(const char *str,...)
Definition: vbi.cpp:42
OutputEvent::elapsedSeconds
const long & elapsedSeconds() const
Definition: output.h:53
OutputEvent
Definition: output.h:30
OutputEvent::OutputEvent
OutputEvent(Type type)
Definition: output.h:32
OutputEvent::Stopped
static Type Stopped
Definition: output.h:67
mythexp.h
MythObservable
Superclass for making an object have a set of listeners.
Definition: mythobservable.h:12
MythEvent
This class is used as a container for messages.
Definition: mythevent.h:17
OutputListeners
Definition: output.h:97
OutputListeners::hasVisual
bool hasVisual(void)
Definition: output.h:102
tmp
static guint32 * tmp
Definition: goom_core.cpp:30
OutputEvent::~OutputEvent
~OutputEvent() override
Definition: output.h:44
MythTV::Visual
Definition: visual.h:17
OutputEvent::Error
static Type Error
Definition: output.h:68
MythTV
Definition: output.h:25
OutputEvent::Playing
static Type Playing
Definition: output.h:63
OutputEvent::precision
const int & precision() const
Definition: output.h:57
OutputEvent::OutputEvent
OutputEvent(const QString &e)
Definition: output.h:37
OutputEvent::clone
MythEvent * clone(void) const override
Definition: output.h:60
hardwareprofile.config.p
p
Definition: config.py:33
OutputEvent::m_errorMsg
QString * m_errorMsg
Definition: output.h:84
OutputListeners::setBufferSize
void setBufferSize(unsigned int sz)
Definition: output.h:108
OutputEvent::OutputEvent
OutputEvent(long s, unsigned long w, int b, int f, int p, int c)
Definition: output.h:34
OutputEvent::errorMessage
const QString * errorMessage() const
Definition: output.h:51
f
QTextStream t & f
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:600
OutputEvent::OutputEvent
OutputEvent(const OutputEvent &o)
Definition: output.h:71
OutputListeners::mutex
QMutex * mutex()
Definition: output.h:106
OutputEvent::Paused
static Type Paused
Definition: output.h:66
OutputEvent::frequency
const int & frequency() const
Definition: output.h:56
Buffer
Definition: MythExternControl.h:37
OutputEvent::bitrate
const int & bitrate() const
Definition: output.h:55
OutputEvent::Info
static Type Info
Definition: output.h:65
Visuals
std::vector< MythTV::Visual * > Visuals
Definition: output.h:94
OutputListeners::bufferSize
unsigned int bufferSize() const
Definition: output.h:109
OutputEvent::writtenBytes
const unsigned long & writtenBytes() const
Definition: output.h:54
OutputEvent::channels
const int & channels() const
Definition: output.h:58
OutputEvent::operator=
OutputEvent & operator=(const OutputEvent &)=delete
OutputListeners::~OutputListeners
~OutputListeners() override=default
mythobservable.h