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
15
16#include "asichannel.h"
17#include "asirecorder.h"
18#include "asisignalmonitor.h"
19#include "asistreamhandler.h"
20#include "mpeg/atscstreamdata.h"
21#include "mpeg/atsctables.h"
22#include "mpeg/mpegtables.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())
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 {
124 }
125
126 m_updateDone = true;
127}
#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