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 
9 #include <QCoreApplication>
10 
11 #include "output.h"
12 #include "visual.h"
13 
14 class QObject;
15 
16 const QEvent::Type OutputEvent::kPlaying =
17  (QEvent::Type) QEvent::registerEventType();
18 const QEvent::Type OutputEvent::kBuffering =
19  (QEvent::Type) QEvent::registerEventType();
20 const QEvent::Type OutputEvent::kInfo =
21  (QEvent::Type) QEvent::registerEventType();
22 const QEvent::Type OutputEvent::kPaused =
23  (QEvent::Type) QEvent::registerEventType();
24 const QEvent::Type OutputEvent::kStopped =
25  (QEvent::Type) QEvent::registerEventType();
26 const QEvent::Type OutputEvent::kError =
27  (QEvent::Type) QEvent::registerEventType();
28 
29 void OutputListeners::error(const QString &e)
30 {
31  OutputEvent event(e);
32  dispatch(event);
33 }
34 
36 {
37  auto it = std::find(m_visuals.begin(), m_visuals.end(), v);
38  if (it == m_visuals.end())
39  m_visuals.push_back(v);
40 }
41 
43 {
44  auto it = std::find(m_visuals.begin(), m_visuals.end(), v);
45  if (it != m_visuals.end())
46  m_visuals.erase(it);
47 }
48 
49 void OutputListeners::dispatchVisual(uchar *buffer, unsigned long b_len,
50  std::chrono::milliseconds timecode,
51  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, timecode, chan, prec);
60  }
61 }
62 
64 {
65  for (auto & visual : m_visuals)
66  {
67  QMutexLocker locker(visual->mutex());
68  visual->prepare();
69  }
70 }
OutputListeners::addVisual
void addVisual(MythTV::Visual *v)
Definition: output.cpp:35
OutputEvent
Definition: output.h:31
MythObservable::dispatch
void dispatch(const MythEvent &event)
Dispatch an event to all listeners.
Definition: mythobservable.cpp:73
OutputListeners::error
void error(const QString &e)
Definition: output.cpp:29
OutputListeners::removeVisual
void removeVisual(MythTV::Visual *v)
Definition: output.cpp:42
MythTV::Visual
Definition: visual.h:16
OutputEvent::kStopped
static const Type kStopped
Definition: output.h:67
OutputEvent::kInfo
static const Type kInfo
Definition: output.h:65
OutputListeners::m_visuals
Visuals m_visuals
Definition: output.h:127
OutputEvent::kPlaying
static const Type kPlaying
Definition: output.h:63
OutputEvent::kError
static const Type kError
Definition: output.h:68
OutputListeners::dispatchVisual
void dispatchVisual(uchar *b, unsigned long b_len, std::chrono::milliseconds timecode, int chan, int prec)
Definition: output.cpp:49
OutputEvent::kBuffering
static const Type kBuffering
Definition: output.h:64
OutputListeners::prepareVisuals
void prepareVisuals()
Definition: output.cpp:63
find
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)
Definition: dvbstreamhandler.cpp:363
OutputEvent::kPaused
static const Type kPaused
Definition: output.h:66
output.h
visual.h