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  Visuals::iterator 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  Visuals::iterator 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  Visuals::iterator it = m_visuals.begin();
57  for (; it != m_visuals.end(); ++it)
58  {
59  QMutexLocker locker((*it)->mutex());
60  (*it)->add(buffer, b_len, written, chan, prec);
61  }
62 }
63 
65 {
66  Visuals::iterator it = m_visuals.begin();
67  for (; it != m_visuals.end(); ++it)
68  {
69  QMutexLocker locker((*it)->mutex());
70  (*it)->prepare();
71  }
72 }
static Type Info
Definition: output.h:63
static Type Error
Definition: output.h:66
static Type Playing
Definition: output.h:61
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:64
static Type Buffering
Definition: output.h:62
void dispatchVisual(uchar *b, unsigned long b_len, unsigned long written, int chan, int prec)
Definition: output.cpp:50
void addVisual(MythTV::Visual *)
Definition: output.cpp:36
void removeVisual(MythTV::Visual *)
Definition: output.cpp:43
static Type Paused
Definition: output.h:64
static Type Stopped
Definition: output.h:65