MythTV  master
output.cpp
Go to the documentation of this file.
1 // Copyright (c) 2000-2001 Brad Hughes <bhughes@trolltech.com>
2 //
3 // Use, modification and distribution is allowed without limitation,
4 // warranty, or liability of any kind.
5 //
6 
7 #include <algorithm>
8 using namespace std;
9 
10 #include <QCoreApplication>
11 
12 #include "output.h"
13 #include "visual.h"
14 
15 class QObject;
16 
17 QEvent::Type OutputEvent::Playing =
18  (QEvent::Type) QEvent::registerEventType();
19 QEvent::Type OutputEvent::Buffering =
20  (QEvent::Type) QEvent::registerEventType();
21 QEvent::Type OutputEvent::Info =
22  (QEvent::Type) QEvent::registerEventType();
23 QEvent::Type OutputEvent::Paused =
24  (QEvent::Type) QEvent::registerEventType();
25 QEvent::Type OutputEvent::Stopped =
26  (QEvent::Type) QEvent::registerEventType();
27 QEvent::Type OutputEvent::Error =
28  (QEvent::Type) QEvent::registerEventType();
29 
30 void OutputListeners::error(const QString &e)
31 {
32  OutputEvent event(e);
33  dispatch(event);
34 }
35 
37 {
38  auto it = std::find(m_visuals.begin(), m_visuals.end(), v);
39  if (it == m_visuals.end())
40  m_visuals.push_back(v);
41 }
42 
44 {
45  auto it = std::find(m_visuals.begin(), m_visuals.end(), v);
46  if (it != m_visuals.end())
47  m_visuals.erase(it);
48 }
49 
50 void OutputListeners::dispatchVisual(uchar *buffer, unsigned long b_len,
51  unsigned long written, int chan, int prec)
52 {
53  if (! buffer)
54  return;
55 
56  for (auto & visual : m_visuals)
57  {
58  QMutexLocker locker(visual->mutex());
59  visual->add(buffer, b_len, written, chan, prec);
60  }
61 }
62 
64 {
65  for (auto & visual : m_visuals)
66  {
67  QMutexLocker locker(visual->mutex());
68  visual->prepare();
69  }
70 }
static Type Info
Definition: output.h:65
static Type Error
Definition: output.h:68
static Type Playing
Definition: output.h:63
void error(const QString &e)
Definition: output.cpp:30
static pid_list_t::iterator find(const PIDInfoMap &map, pid_list_t &list, pid_list_t::iterator begin, pid_list_t::iterator end, bool find_open)
void prepareVisuals()
Definition: output.cpp:63
static Type Buffering
Definition: output.h:64
void addVisual(MythTV::Visual *v)
Definition: output.cpp:36
void dispatchVisual(uchar *b, unsigned long b_len, unsigned long written, int chan, int prec)
Definition: output.cpp:50
void removeVisual(MythTV::Visual *v)
Definition: output.cpp:43
static Type Paused
Definition: output.h:66
static Type Stopped
Definition: output.h:67