Permalink
Browse files

Optimize reschedules from the EITScanner (low hanging fruit only)

Use watchdog based reschedules only for passive scan. In active scan
we switch to another channel soon enough.
Since [cbb8eb1] reschedules can be limited to changed parts of the
guide. We store the sourceid the EITscanner is active on since
[3c3dd7c], hand it over to the scheduler.
  • Loading branch information...
dekarl committed Dec 17, 2012
1 parent a188374 commit b7bab70ac8b6f03bf277ef2367496c431da5247d
@@ -135,6 +135,12 @@ void EITHelper::SetSourceID(uint _sourceid)
sourceid = _sourceid;
}
uint EITHelper::GetSourceID(void)
{
QMutexLocker locker(&eitList_lock);
return sourceid;
}
void EITHelper::SetChannelID(uint _channelid)
{
QMutexLocker locker(&eitList_lock);
@@ -71,6 +71,7 @@ class EITHelper
void SetFixup(uint atsc_major, uint atsc_minor, uint eitfixup);
void SetLanguagePreferences(const QStringList &langPref);
void SetSourceID(uint _sourceid);
uint GetSourceID(void);
#ifdef USING_BACKEND
void AddEIT(uint atsc_major, uint atsc_minor,
@@ -109,14 +109,16 @@ void EITScanner::run(void)
// If there have been any new events and we haven't
// seen any in a while, tell scheduler to run.
if (eitCount && (t.elapsed() > 60 * 1000))
// But only for passive scan which can sit hours on the same channel.
if (!activeScan && eitCount && (t.elapsed() > 60 * 1000))
{
LOG(VB_EIT, LOG_INFO,
LOC_ID + QString("Added %1 EIT Events").arg(eitCount));
eitCount = 0;
RescheduleRecordings();
}
// Is it time to move to the next transport in active scan?
if (activeScan && (MythDate::current() > activeScanNextTrig))
{
// if there have been any new events, tell scheduler to run.
@@ -163,6 +165,13 @@ void EITScanner::run(void)
activeScanCond.wakeAll();
}
}
if (eitCount) /* some events have been handled since the last schedule request */
{
eitCount = 0;
RescheduleRecordings();
}
activeScanStopped = true;
activeScanCond.wakeAll();
lock.unlock();
@@ -174,7 +183,7 @@ void EITScanner::run(void)
* This implements some very basic rate limiting. If a call is made
* to this within kMinRescheduleInterval of the last call it is ignored.
*/
void EITScanner::RescheduleRecordings(void)
const void EITScanner::RescheduleRecordings(void)
{
if (!resched_lock.tryLock())
return;
@@ -190,7 +199,7 @@ void EITScanner::RescheduleRecordings(void)
MythDate::current().addSecs(kMinRescheduleInterval);
resched_lock.unlock();
ScheduledRecording::RescheduleMatch(0, 0, 0, QDateTime(), "EITScanner");
ScheduledRecording::RescheduleMatch(0, eitHelper->GetSourceID(), 0, QDateTime(), "EITScanner");
}
/** \fn EITScanner::StartPassiveScan(ChannelBase*, EITSource*, bool)
@@ -202,14 +211,14 @@ void EITScanner::StartPassiveScan(ChannelBase *_channel,
{
QMutexLocker locker(&lock);
uint sourceid = _channel->GetCurrentSourceID();
//uint sourceid = _channel->GetCurrentSourceID(); // FIXME why is this 0?
eitSource = _eitSource;
channel = _channel;
eitHelper->SetSourceID(sourceid);
eitSource->SetEITHelper(eitHelper);
eitSource->SetEITRate(1.0f);
eitHelper->SetChannelID(_channel->GetChanID());
eitHelper->SetChannelID(channel->GetChanID());
eitHelper->SetSourceID(ChannelUtil::GetSourceIDForChannel(channel->GetChanID()));
LOG(VB_EIT, LOG_INFO, LOC_ID + "Started passive scan.");
}
@@ -46,7 +46,7 @@ class EITScanner : public QRunnable
private:
void TeardownAll(void);
static void *SpawnEventLoop(void*);
static void RescheduleRecordings(void);
const void RescheduleRecordings(void);
QMutex lock;
ChannelBase *channel;

0 comments on commit b7bab70

Please sign in to comment.