Skip to content

Commit

Permalink
In EIT passive scan, reschedule recordings every 5 minutes
Browse files Browse the repository at this point in the history
Reschedule recordings every 5 minutes when new EIT events have been
processed while recording (passive scan).
This enables last-minute changes in the guide data when a recording
is already running. This can happen for instance with sports programs.
Previously, in passive scan the rescheduling was done each time
a number of new events were processed.
Also a few minor improvements in the log message texts.
  • Loading branch information
kmdewaal committed Jan 17, 2024
1 parent dd11866 commit 3ded86d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 23 deletions.
5 changes: 3 additions & 2 deletions mythtv/libs/libmythtv/channelutil.cpp
Expand Up @@ -17,6 +17,7 @@
#include "channelutil.h"
#include "mpeg/dvbtables.h"
#include "recorders/HLS/HLSReader.h"
#include "sourceutil.h"

#define LOC QString("ChanUtil: ")

Expand Down Expand Up @@ -1986,8 +1987,8 @@ bool ChannelUtil::GetChannelData(
if (!chanid)
{
LOG(VB_GENERAL, LOG_ERR,
QString("Could not find channel '%1' in DB for source '%2'.")
.arg(channum).arg(sourceid));
QString("Could not find channel '%1' in DB for source %2 '%3'.")
.arg(channum).arg(sourceid).arg(SourceUtil::GetSourceName(sourceid)));
return false;
}

Expand Down
6 changes: 4 additions & 2 deletions mythtv/libs/libmythtv/eithelper.cpp
Expand Up @@ -41,14 +41,16 @@ EITHelper::EITHelper(uint cardnum) :
{
m_chunkSize = gCoreContext->GetNumSetting("EITEventChunkSize", 20);
m_queueSize = std::min(m_chunkSize * 50, kMaxQueueSize);

LOG(VB_EIT, LOG_INFO, LOC_ID +
QString("EIThelper chunk size %1 and queue size %2 events")
QString("EITHelper chunk size %1 and queue size %2 events")
.arg(m_chunkSize).arg(m_queueSize));

// Save EIT cache in database table eit_cache iff true
bool persistent = gCoreContext->GetBoolSetting("EITCachePersistent", true);
s_eitCache->SetPersistent(persistent);
LOG(VB_EIT, LOG_INFO, LOC_ID +
QString("EITCache %1")
.arg(persistent ? "in memory, backup to database" : "in memory only"));

init_fixup(m_fixup);
}
Expand Down
38 changes: 19 additions & 19 deletions mythtv/libs/libmythtv/eitscanner.cpp
Expand Up @@ -81,7 +81,9 @@ void EITScanner::run(void)
m_lock.lock();

MythTimer tsle; // Time since last event or since start of active scan
m_eitCount = 0; // Number of events processed
MythTimer tsrr; // Time since RescheduleRecordings in passive scan
tsrr.start();
m_eitCount = 0; // Number of new events processed

while (!m_exitThread)
{
Expand All @@ -94,16 +96,16 @@ void EITScanner::run(void)
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 && m_eitCount && (tsle.elapsed() > 60s))
// Run the scheduler every 5 minutes if we are in passive scan
// and there have been new events.
if (!m_activeScan && m_eitCount && (tsrr.elapsed() > 5min))
{
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));
QString("for source %1 '%2'").arg(m_sourceid).arg(m_sourceName));
m_eitCount = 0;
RescheduleRecordings();
tsrr.start();
}

// Move to the next transport in active scan when no events
Expand All @@ -116,8 +118,9 @@ void EITScanner::run(void)
if (noEvents && !scanTimeUp)
{
LOG(VB_EIT, LOG_INFO, LOC +
QString("No EIT events received in last %1 seconds, move to next transport")
.arg(eventTimeout.count()));
QString("No new EIT events received in last %1 seconds ").arg(eventTimeout.count()) +
QString("for source %2 '%3' ").arg(m_sourceid).arg(m_sourceName) +
QString("on multiplex %4, move to next multiplex").arg(m_mplexid));
}

if (m_activeScanNextChan == m_activeScanChannels.end())
Expand All @@ -132,10 +135,10 @@ void EITScanner::run(void)
{
uint chanid = ChannelUtil::GetChanID(m_sourceid, *m_activeScanNextChan);
m_eitHelper->SetChannelID(chanid);
uint mplexid = ChannelUtil::GetMplexID(chanid);
m_mplexid = ChannelUtil::GetMplexID(chanid);
LOG(VB_EIT, LOG_DEBUG, LOC +
QString("Next EIT active scan source %1 '%2' multiplex %3 chanid %4 channel %5")
.arg(m_sourceid).arg(m_sourceName).arg(mplexid).arg(chanid).arg(*m_activeScanNextChan));
.arg(m_sourceid).arg(m_sourceName).arg(m_mplexid).arg(chanid).arg(*m_activeScanNextChan));
}
}

Expand Down Expand Up @@ -196,13 +199,13 @@ void EITScanner::StartEITEventProcessing(ChannelBase *channel,
QString channum = m_channel->GetChannelName();
if (chanid > 0)
{
uint mplexid = ChannelUtil::GetMplexID(chanid);
m_mplexid = ChannelUtil::GetMplexID(chanid);
m_eitHelper->SetChannelID(chanid);
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(m_sourceid).arg(m_sourceName)
.arg(mplexid).arg(chanid).arg(channum));
.arg(m_mplexid).arg(chanid).arg(channum));
}
else
{
Expand All @@ -222,19 +225,16 @@ void EITScanner::StopEITEventProcessing(void)
if (!m_eitSource)
return;

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

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 Down
1 change: 1 addition & 0 deletions mythtv/libs/libmythtv/eitscanner.h
Expand Up @@ -66,6 +66,7 @@ class EITScanner : public QRunnable
uint m_sourceid {0}; // Video source ID
QString m_sourceName; // Video source name
uint m_eitCount {0}; // Processsed EIT events
uint m_mplexid {0}; // Transport stream multiplex ID
};

#endif // EITSCANNER_H

0 comments on commit 3ded86d

Please sign in to comment.