Skip to content

Commit

Permalink
EIT scan messages
Browse files Browse the repository at this point in the history
Improvements for EIT scan messages:
- Added INFO messages with total events processed per multiplex
- Changed message with events per 400ms from INFO to DEBUG
- Added video source identification
- Added multplex ID, channel ID and channel number
No functional changes.
  • Loading branch information
kmdewaal committed Jan 14, 2024
1 parent 634c871 commit 70f0d6b
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 47 deletions.
14 changes: 7 additions & 7 deletions mythtv/libs/libmythtv/eitcache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ event_map_t * EITCache::LoadChannel(uint chanid)
}

if (!eventMap->empty())
LOG(VB_EIT, LOG_INFO, LOC + QString("Loaded %1 entries for chanid %2")
LOG(VB_EIT, LOG_DEBUG, LOC + QString("Loaded %1 entries for chanid %2")
.arg(eventMap->size()).arg(chanid));

m_entryCnt += eventMap->size();
Expand Down Expand Up @@ -303,20 +303,20 @@ bool EITCache::WriteChannelToDB(QStringList &value_clauses, uint chanid)
{
if (m_persistent)
{
LOG(VB_EIT, LOG_INFO, LOC +
LOG(VB_EIT, LOG_DEBUG, LOC +
QString("Writing %1 modified entries of %2 for chanid %3 to database.")
.arg(updated).arg(size).arg(chanid));
}
else
{
LOG(VB_EIT, LOG_INFO, LOC +
LOG(VB_EIT, LOG_DEBUG, LOC +
QString("Updated %1 modified entries of %2 for chanid %3 in cache.")
.arg(updated).arg(size).arg(chanid));
}
}
if (removed)
{
LOG(VB_EIT, LOG_INFO, LOC + QString("Removed %1 old entries of %2 "
LOG(VB_EIT, LOG_DEBUG, LOC + QString("Removed %1 old entries of %2 "
"for chanid %3 from cache.")
.arg(removed).arg(size).arg(chanid));
}
Expand Down Expand Up @@ -362,10 +362,10 @@ bool EITCache::IsNewEIT(uint chanid, uint tableid, uint version,
{
m_accessCnt++;

if ((m_accessCnt < 100000 && (m_accessCnt % 10000 == 0)) ||
(m_accessCnt % 100000 == 0))
if (m_accessCnt % 10000 == 0)
{
LOG(VB_EIT, LOG_INFO, LOC + GetStatistics());
ResetStatistics();
}

// Don't re-add pruned entries
Expand Down Expand Up @@ -434,7 +434,7 @@ bool EITCache::IsNewEIT(uint chanid, uint tableid, uint version,
*/
uint EITCache::PruneOldEntries(uint timestamp)
{
if (VERBOSE_LEVEL_CHECK(VB_EIT, LOG_INFO))
if (VERBOSE_LEVEL_CHECK(VB_EIT, LOG_DEBUG))
{
QDateTime tmptime = MythDate::fromSecsSinceEpoch(timestamp);
LOG(VB_EIT, LOG_INFO,
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/eithelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,14 @@ uint EITHelper::ProcessEvents(void)

if (!m_incompleteEvents.empty())
{
LOG(VB_EIT, LOG_INFO, LOC_ID +
LOG(VB_EIT, LOG_DEBUG, LOC_ID +
QString("Added %1 events -- complete: %2 incomplete: %3")
.arg(insertCount).arg(m_dbEvents.size())
.arg(m_incompleteEvents.size()));
}
else
{
LOG(VB_EIT, LOG_INFO, LOC_ID +
LOG(VB_EIT, LOG_DEBUG, LOC_ID +
QString("Added %1/%2 events, queued: %3")
.arg(insertCount).arg(eventCount).arg(m_dbEvents.size()));
}
Expand Down
83 changes: 46 additions & 37 deletions mythtv/libs/libmythtv/eitscanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ EITScanner::EITScanner(uint cardnum)
QStringList langPref = iso639_get_language_list();
m_eitHelper->SetLanguagePreferences(langPref);

LOG(VB_EIT, LOG_INFO, LOC + "Start EIT scanner thread");
m_sourceid = CardUtil::GetSourceID(m_cardnum);
m_sourceName = SourceUtil::GetSourceName(m_sourceid);
LOG(VB_EIT, LOG_INFO, LOC +
QString("Start EIT scanner thread for source %1 '%2'")
.arg(m_sourceid).arg(m_sourceName));

m_eventThread->start(QThread::IdlePriority);
}

Expand Down Expand Up @@ -76,7 +81,7 @@ void EITScanner::run(void)
m_lock.lock();

MythTimer tsle; // Time since last event or since start of active scan
uint eitCount = 0; // Number of events processed
m_eitCount = 0; // Number of events processed

while (!m_exitThread)
{
Expand All @@ -85,37 +90,30 @@ void EITScanner::run(void)
uint list_size = m_eitHelper->GetListSize();
if (list_size)
{
eitCount += m_eitHelper->ProcessEvents();
m_eitCount += m_eitHelper->ProcessEvents();
tsle.start();
}

// Tell the scheduler to run if we are in passive scan
// and there have been updated events since the last scheduler run
// but not in the last 60 seconds
if (!m_activeScan && eitCount && (tsle.elapsed() > 60s))
if (!m_activeScan && m_eitCount && (tsle.elapsed() > 60s))
{
LOG(VB_EIT, LOG_INFO,
LOC + QString("Added %1 EIT events in passive scan").arg(eitCount));
eitCount = 0;
LOG(VB_EIT, LOG_INFO, LOC +
QString("Added %1 EIT events in passive scan ").arg(m_eitCount) +
QString("source %1 '%2'").arg(m_sourceid).arg(m_sourceName));
m_eitCount = 0;
RescheduleRecordings();
}

// Move to the next transport in active scan when no events
// have been received for 60 seconds or when the scan time is up.
const std::chrono::seconds eventTimeout = 60s;
bool noEvents = tsle.isRunning() && (tsle.elapsed() > eventTimeout);
if (m_activeScan && (noEvents || (MythDate::current() > m_activeScanNextTrig)))
bool scanTimeUp = MythDate::current() > m_activeScanNextTrig;
if (m_activeScan && (noEvents || scanTimeUp))
{
// If there have been any new events, tell scheduler to run.
if (eitCount)
{
LOG(VB_EIT, LOG_INFO,
LOC + QString("Added %1 EIT events in active scan").arg(eitCount));
eitCount = 0;
RescheduleRecordings();
}

if (noEvents)
if (noEvents && !scanTimeUp)
{
LOG(VB_EIT, LOG_INFO, LOC +
QString("No EIT events received in last %1 seconds, move to next transport")
Expand All @@ -132,15 +130,12 @@ void EITScanner::run(void)
EITHelper::WriteEITCache();
if (m_rec->QueueEITChannelChange(*m_activeScanNextChan))
{
uint sourceid = m_rec->GetSourceID();
uint chanid = ChannelUtil::GetChanID(sourceid, *m_activeScanNextChan);
uint chanid = ChannelUtil::GetChanID(m_sourceid, *m_activeScanNextChan);
m_eitHelper->SetChannelID(chanid);

uint mplexid = ChannelUtil::GetMplexID(chanid);
QString sourcename = SourceUtil::GetSourceName(sourceid);
LOG(VB_EIT, LOG_DEBUG, LOC +
QString("Next EIT active scan source %1 '%2' multiplex %3 chanid %4 channel %5")
.arg(sourceid).arg(sourcename).arg(mplexid).arg(chanid).arg(*m_activeScanNextChan));
.arg(m_sourceid).arg(m_sourceName).arg(mplexid).arg(chanid).arg(*m_activeScanNextChan));
}
}

Expand All @@ -164,7 +159,8 @@ void EITScanner::run(void)
}
}

if (eitCount) /* some events have been handled since the last schedule request */
// Some events have been handled since the last schedule request
if (m_eitCount)
{
RescheduleRecordings();
}
Expand Down Expand Up @@ -200,14 +196,12 @@ void EITScanner::StartEITEventProcessing(ChannelBase *channel,
QString channum = m_channel->GetChannelName();
if (chanid > 0)
{
uint sourceid = m_channel->GetSourceID();
uint mplexid = ChannelUtil::GetMplexID(chanid);
QString sourcename = SourceUtil::GetSourceName(sourceid);
m_eitHelper->SetChannelID(chanid);
m_eitHelper->SetSourceID(sourceid);
m_eitHelper->SetSourceID(m_sourceid);
LOG(VB_EIT, LOG_INFO, LOC +
QString("Start EIT %1 scan source %2 '%3' multiplex %4 chanid %5 channel %6")
.arg(m_activeScan ? "active" : "passive").arg(sourceid).arg(sourcename)
.arg(m_activeScan ? "active" : "passive").arg(m_sourceid).arg(m_sourceName)
.arg(mplexid).arg(chanid).arg(channum));
}
else
Expand All @@ -225,6 +219,22 @@ void EITScanner::StopEITEventProcessing(void)
{
QMutexLocker locker(&m_lock);

if (!m_eitSource)
return;

if (m_eitCount)
{
LOG(VB_EIT, LOG_INFO, LOC +
QString("Added %1 EIT events for source %2 '%3'")
.arg(m_eitCount).arg(m_sourceid).arg(m_sourceName));
m_eitCount = 0;
RescheduleRecordings();
}

LOG(VB_EIT, LOG_INFO, LOC +
QString("Stop EIT event processing for source %1 '%2'")
.arg(m_sourceid).arg(m_sourceName));

if (m_eitSource)
{
m_eitSource->SetEITHelper(nullptr);
Expand All @@ -235,15 +245,12 @@ void EITScanner::StopEITEventProcessing(void)
EITHelper::WriteEITCache();
m_eitHelper->SetChannelID(0);
m_eitHelper->SetSourceID(0);
LOG(VB_EIT, LOG_INFO, LOC +
QString("Stop EIT %1 scan")
.arg(m_activeScanStopped ? "passive" : "active"));
}

/** \fn EITScanner::StartActiveScan(TVRec *rec, std::chrono::seconds)
* \brief Start active EIT scan.
*/
void EITScanner::StartActiveScan(TVRec *rec, std::chrono::seconds max_seconds_per_source)
void EITScanner::StartActiveScan(TVRec *rec, std::chrono::seconds max_seconds_per_multiplex)
{
QMutexLocker locker(&m_lock);

Expand Down Expand Up @@ -305,17 +312,15 @@ void EITScanner::StartActiveScan(TVRec *rec, std::chrono::seconds max_seconds_pe

// Add a little randomness to trigger time so multiple
// cards will have a staggered channel changing time.
m_activeScanTrigTime = max_seconds_per_source;
m_activeScanTrigTime = max_seconds_per_multiplex;
m_activeScanTrigTime += std::chrono::seconds(MythRandom(0, 28));

m_activeScanStopped = false;
m_activeScan = true;

uint sourceid = m_rec->GetSourceID();
QString sourcename = SourceUtil::GetSourceName(sourceid);
LOG(VB_EIT, LOG_INFO, LOC +
QString("EIT scan start on source %1 '%2'")
.arg(sourceid).arg(sourcename));
QString("Start EIT active scan on source %1 '%2'")
.arg(m_sourceid).arg(m_sourceName));
}
}

Expand All @@ -334,6 +339,10 @@ void EITScanner::StopActiveScan(void)
StopEITEventProcessing();
locker.relock();

LOG(VB_EIT, LOG_INFO, LOC +
QString("Stop EIT active scan on source %1 '%2'")
.arg(m_sourceid).arg(m_sourceName));

while (!m_activeScan && !m_activeScanStopped)
m_activeScanCond.wait(&m_lock, 100);

Expand Down
5 changes: 4 additions & 1 deletion mythtv/libs/libmythtv/eitscanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ class EITScanner : public QRunnable
QStringList m_activeScanChannels;
QStringList::iterator m_activeScanNextChan;

uint m_cardnum;
uint m_cardnum {0};
uint m_sourceid {0}; // Video source ID
QString m_sourceName; // Video source name
uint m_eitCount {0}; // Processsed EIT events
};

#endif // EITSCANNER_H

0 comments on commit 70f0d6b

Please sign in to comment.