Skip to content

Commit

Permalink
Updated code to determine capture card tuning capabilities
Browse files Browse the repository at this point in the history
Replaced macro-based code that determines the capture card tuning capabilities
and that gives messages about the presence or absence of these capabilities
with more verbose and less obfuscated code.
No functional changes.
  • Loading branch information
kmdewaal committed Jul 24, 2022
1 parent 88c7d97 commit 337c89c
Showing 1 changed file with 52 additions and 19 deletions.
71 changes: 52 additions & 19 deletions mythtv/libs/libmythtv/recorders/dvbsignalmonitor.cpp
Expand Up @@ -90,27 +90,60 @@ DVBSignalMonitor::DVBSignalMonitor(int db_cardnum, DVBChannel* _channel,
// in practice, however this is correct for the 4.0 DVB API
m_signalStrength.SetRange(0, 65535);

// Determine the signal monitoring capabilities from the card and
// do not use the capabilities that are not present.
uint64_t rmflags = 0;

// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define DVB_IO(FLAG, METHOD, MSG) \
do { if (HasFlags(FLAG)) { bool mok; _channel->METHOD(&mok); \
if (!mok) { \
LOG(VB_GENERAL, LOG_WARNING, LOC+"Cannot "+(MSG)+ENO); \
rmflags |= (FLAG); } \
else { \
LOG(VB_CHANNEL, LOG_INFO, LOC + "Can " + (MSG)); } } } while (false)

DVB_IO(kSigMon_WaitForSig, GetSignalStrength,
"measure Signal Strength");
DVB_IO(kDVBSigMon_WaitForSNR, GetSNR,
"measure S/N");
DVB_IO(kDVBSigMon_WaitForBER, GetBitErrorRate,
"measure Bit Error Rate");
DVB_IO(kDVBSigMon_WaitForUB, GetUncorrectedBlockCount,
"count Uncorrected Blocks");

#undef DVB_IO
auto log_message = [](bool ok, QString loc, QString msg)
{
if (ok)
LOG(VB_CHANNEL, LOG_INFO, loc + "Can " + msg);
else
LOG(VB_GENERAL, LOG_WARNING, loc + "Cannot " + msg + ENO);
};

auto update_rmflags = [&](bool ok, uint64_t flag)
{
if (!ok)
rmflags |= flag;
};

// Signal strength
auto flag = kSigMon_WaitForSig;
bool mok;
if (HasFlags(flag))
{
_channel->GetSignalStrength(&mok);
update_rmflags(mok, flag);
log_message(mok, LOC, "measure Signal Strength");
}

// Signal/Noise ratio
flag = kDVBSigMon_WaitForSNR;
if (HasFlags(flag))
{
_channel->GetSNR(&mok);
update_rmflags(mok, flag);
log_message(mok, LOC, "measure S/N");
}

// Bit error rate
flag = kDVBSigMon_WaitForBER;
if (HasFlags(flag))
{
_channel->GetBitErrorRate(&mok);
update_rmflags(mok, flag);
log_message(mok, LOC, "measure Bit Error Rate");
}

// Uncorrected block count
flag = kDVBSigMon_WaitForUB;
if (HasFlags(flag))
{
_channel->GetUncorrectedBlockCount(&mok);
update_rmflags(mok, flag);
log_message(mok, LOC, "count Uncorrected Blocks");
}

RemoveFlags(rmflags);

Expand Down

0 comments on commit 337c89c

Please sign in to comment.