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 QEvent::Type OutputEvent::Playing =
17  (QEvent::Type) QEvent::registerEventType();
18 QEvent::Type OutputEvent::Buffering =
19  (QEvent::Type) QEvent::registerEventType();
20 QEvent::Type OutputEvent::Info =
21  (QEvent::Type) QEvent::registerEventType();
22 QEvent::Type OutputEvent::Paused =
23  (QEvent::Type) QEvent::registerEventType();
24 QEvent::Type OutputEvent::Stopped =
25  (QEvent::Type) QEvent::registerEventType();
26 QEvent::Type OutputEvent::Error =
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::Buffering
static Type Buffering
Definition: output.h:64
OutputEvent
Definition: output.h:31
OutputEvent::Stopped
static Type Stopped
Definition: output.h:67
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::Error
static Type Error
Definition: output.h:68
OutputEvent::Playing
static Type Playing
Definition: output.h:63
OutputListeners::m_visuals
Visuals m_visuals
Definition: output.h:127
OutputEvent::Paused
static Type Paused
Definition: output.h:66
OutputEvent::Info
static Type Info
Definition: output.h:65
OutputListeners::dispatchVisual
void dispatchVisual(uchar *b, unsigned long b_len, std::chrono::milliseconds timecode, int chan, int prec)
Definition: output.cpp:49
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:356
output.h
visual.h