MythTV  master
asisignalmonitor.cpp
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 // Copyright (c) 2006, Daniel Thor Kristjansson
3 
4 #include <cerrno>
5 #include <cstring>
6 
7 #include <fcntl.h>
8 #include <unistd.h>
9 #ifndef _WIN32
10 #include <sys/select.h>
11 #endif
12 
13 #include "mythlogging.h"
14 #include "mythdbcon.h"
15 #include "asisignalmonitor.h"
16 #include "atscstreamdata.h"
17 #include "mpegtables.h"
18 #include "atsctables.h"
19 
20 #include "asichannel.h"
21 #include "asirecorder.h"
22 #include "asistreamhandler.h"
23 
24 #define LOC QString("ASISigMon[%1](%2): ") \
25  .arg(m_inputid).arg(m_channel->GetDevice())
26 
42  ASIChannel *_channel,
43  bool _release_stream,
44  uint64_t _flags)
45  : DTVSignalMonitor(db_cardnum, _channel, _release_stream, _flags)
46 {
47  LOG(VB_CHANNEL, LOG_INFO, LOC + "ctor");
49 }
50 
55 {
56  LOG(VB_CHANNEL, LOG_INFO, LOC + "dtor");
59 }
60 
65 {
66  LOG(VB_CHANNEL, LOG_INFO, LOC + "Stop() -- begin");
68  if (GetStreamData())
70  m_streamHandlerStarted = false;
71 
72  LOG(VB_CHANNEL, LOG_INFO, LOC + "Stop() -- end");
73 }
74 
76 {
77  return dynamic_cast<ASIChannel*>(m_channel);
78 }
79 
87 {
88  if (!m_running || m_exit)
89  return;
90 
92  {
93  EmitStatus();
94  if (IsAllGood())
96 
97  // TODO dtv signals...
98 
99  m_updateDone = true;
100  return;
101  }
102 
103  // Set SignalMonitorValues from info from card.
104  bool isLocked = true;
105  {
106  QMutexLocker locker(&m_statusLock);
109  }
110 
111  EmitStatus();
112  if (IsAllGood())
114 
115  // Start table monitoring if we are waiting on any table
116  // and we have a lock.
117  if (isLocked && GetStreamData() &&
121  {
123  m_streamHandlerStarted = true;
124  }
125 
126  m_updateDone = true;
127 }
LOC
#define LOC
Definition: asisignalmonitor.cpp:24
SignalMonitorValue::SetValue
void SetValue(int _value)
Definition: signalmonitorvalue.h:74
ASISignalMonitor::GetASIChannel
ASIChannel * GetASIChannel(void)
Definition: asisignalmonitor.cpp:75
ASISignalMonitor::~ASISignalMonitor
~ASISignalMonitor() override
Stops signal monitoring and table monitoring threads.
Definition: asisignalmonitor.cpp:54
SignalMonitor::m_channel
ChannelBase * m_channel
Definition: signalmonitor.h:202
SignalMonitor::kDTVSigMon_WaitForMGT
static const uint64_t kDTVSigMon_WaitForMGT
Definition: signalmonitor.h:182
SignalMonitor::m_exit
volatile bool m_exit
Definition: signalmonitor.h:226
mythdbcon.h
DTVSignalMonitor::GetStreamData
MPEGStreamData * GetStreamData()
Returns the MPEG stream data if it exists.
Definition: dtvsignalmonitor.h:59
atscstreamdata.h
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
SignalMonitor::m_running
volatile bool m_running
Definition: signalmonitor.h:225
SignalMonitor::HasAnyFlag
bool HasAnyFlag(uint64_t _flags) const
Definition: signalmonitor.cpp:282
StreamHandler::RemoveListener
virtual void RemoveListener(MPEGStreamData *data)
Definition: streamhandler.cpp:78
asistreamhandler.h
asirecorder.h
ASISignalMonitor::m_streamHandler
ASIStreamHandler * m_streamHandler
Definition: asisignalmonitor.h:31
SignalMonitor::m_signalStrength
SignalMonitorValue m_signalStrength
Definition: signalmonitor.h:218
mythlogging.h
SignalMonitor::m_inputid
int m_inputid
Definition: signalmonitor.h:204
ASIStreamHandler::Get
static ASIStreamHandler * Get(const QString &devname, int inputid)
Definition: asistreamhandler.cpp:33
SignalMonitor::m_signalLock
SignalMonitorValue m_signalLock
Definition: signalmonitor.h:217
SignalMonitor::SendMessageAllGood
void SendMessageAllGood(void)
Definition: signalmonitor.cpp:467
SignalMonitor::kDTVSigMon_WaitForPMT
static const uint64_t kDTVSigMon_WaitForPMT
Definition: signalmonitor.h:181
SignalMonitor::kDTVSigMon_WaitForPAT
static const uint64_t kDTVSigMon_WaitForPAT
Definition: signalmonitor.h:180
SignalMonitor::m_updateDone
bool m_updateDone
Definition: signalmonitor.h:209
SignalMonitor::kDTVSigMon_WaitForNIT
static const uint64_t kDTVSigMon_WaitForNIT
Definition: signalmonitor.h:184
SignalMonitor::EmitStatus
virtual void EmitStatus(void)
Definition: signalmonitor.cpp:474
SignalMonitor::kDTVSigMon_WaitForSDT
static const uint64_t kDTVSigMon_WaitForSDT
Definition: signalmonitor.h:185
ASIStreamHandler::Return
static void Return(ASIStreamHandler *&ref, int inputid)
Definition: asistreamhandler.cpp:66
ASIChannel::GetDevice
QString GetDevice(void) const override
Returns String representing device, useful for debugging.
Definition: asichannel.h:34
mpegtables.h
ASISignalMonitor::UpdateValues
void UpdateValues(void) override
Fills in frontend stats and emits status Qt signals.
Definition: asisignalmonitor.cpp:86
asisignalmonitor.h
ASIStreamHandler::AddListener
void AddListener(MPEGStreamData *data, bool=false, bool=false, const QString &output_file=QString()) override
Definition: asistreamhandler.h:49
asichannel.h
ASISignalMonitor::Stop
void Stop(void) override
Stop signal monitoring and table monitoring threads.
Definition: asisignalmonitor.cpp:64
ASISignalMonitor::m_streamHandlerStarted
bool m_streamHandlerStarted
Definition: asisignalmonitor.h:30
ASIChannel
-*- Mode: c++ -*-
Definition: asichannel.h:15
SignalMonitor::m_statusLock
QMutex m_statusLock
Definition: signalmonitor.h:228
DTVSignalMonitor
This class is intended to detect the presence of needed tables.
Definition: dtvsignalmonitor.h:19
atsctables.h
Overall structure.
ASISignalMonitor::ASISignalMonitor
ASISignalMonitor(void)
SignalMonitor::Stop
virtual void Stop()
Stop signal monitoring thread.
Definition: signalmonitor.cpp:306
DTVSignalMonitor::IsAllGood
bool IsAllGood(void) const override
Definition: dtvsignalmonitor.cpp:564
SignalMonitor::kDTVSigMon_WaitForVCT
static const uint64_t kDTVSigMon_WaitForVCT
Definition: signalmonitor.h:183