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 <QtGlobal>
8#if QT_VERSION >= QT_VERSION_CHECK(6,5,0)
9#include <QtSystemDetection>
10#endif
11
12#include <fcntl.h>
13#include <unistd.h>
14#ifndef Q_OS_WINDOWS
15#include <sys/select.h>
16#endif
17
20
21#include "asichannel.h"
22#include "asirecorder.h"
23#include "asisignalmonitor.h"
24#include "asistreamhandler.h"
25#include "mpeg/atscstreamdata.h"
26#include "mpeg/atsctables.h"
27#include "mpeg/mpegtables.h"
28
29#define LOC QString("ASISigMon[%1](%2): ") \
30 .arg(m_inputid).arg(m_channel->GetDevice())
31
47 ASIChannel *_channel,
48 bool _release_stream,
49 uint64_t _flags)
50 : DTVSignalMonitor(db_cardnum, _channel, _release_stream, _flags)
51{
52 LOG(VB_CHANNEL, LOG_INFO, LOC + "ctor");
54}
55
60{
61 LOG(VB_CHANNEL, LOG_INFO, LOC + "dtor");
64}
65
70{
71 LOG(VB_CHANNEL, LOG_INFO, LOC + "Stop() -- begin");
73 if (GetStreamData())
76
77 LOG(VB_CHANNEL, LOG_INFO, LOC + "Stop() -- end");
78}
79
81{
82 return dynamic_cast<ASIChannel*>(m_channel);
83}
84
92{
93 if (!m_running || m_exit)
94 return;
95
97 {
98 EmitStatus();
99 if (IsAllGood())
101
102 // TODO dtv signals...
103
104 m_updateDone = true;
105 return;
106 }
107
108 // Set SignalMonitorValues from info from card.
109 bool isLocked = true;
110 {
111 QMutexLocker locker(&m_statusLock);
114 }
115
116 EmitStatus();
117 if (IsAllGood())
119
120 // Start table monitoring if we are waiting on any table
121 // and we have a lock.
122 if (isLocked && GetStreamData() &&
126 {
129 }
130
131 m_updateDone = true;
132}
#define LOC
Overall structure.
-*- Mode: c++ -*-
Definition: asichannel.h:15
QString GetDevice(void) const override
Returns String representing device, useful for debugging.
Definition: asichannel.h:34
void UpdateValues(void) override
Fills in frontend stats and emits status Qt signals.
~ASISignalMonitor() override
Stops signal monitoring and table monitoring threads.
ASIChannel * GetASIChannel(void)
ASIStreamHandler * m_streamHandler
void Stop(void) override
Stop signal monitoring and table monitoring threads.
static ASIStreamHandler * Get(const QString &devname, int inputid)
void AddListener(MPEGStreamData *data, bool=false, bool=false, const QString &output_file=QString()) override
static void Return(ASIStreamHandler *&ref, int inputid)
This class is intended to detect the presence of needed tables.
bool IsAllGood(void) const override
MPEGStreamData * GetStreamData()
Returns the MPEG stream data if it exists.
void SetValue(int _value)
static const uint64_t kDTVSigMon_WaitForVCT
QRecursiveMutex m_statusLock
volatile bool m_exit
void SendMessageAllGood(void)
SignalMonitorValue m_signalLock
static const uint64_t kDTVSigMon_WaitForNIT
static const uint64_t kDTVSigMon_WaitForSDT
virtual void Stop()
Stop signal monitoring thread.
volatile bool m_running
ChannelBase * m_channel
static const uint64_t kDTVSigMon_WaitForPMT
virtual void EmitStatus(void)
static const uint64_t kDTVSigMon_WaitForPAT
static const uint64_t kDTVSigMon_WaitForMGT
SignalMonitorValue m_signalStrength
bool HasAnyFlag(uint64_t _flags) const
virtual void RemoveListener(MPEGStreamData *data)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39