Skip to content
Browse files

Make EITScanner thread only be started when needed

Currently, an EITScanner thread is started for every source that is capable of
doing EIT scans (DVB/HDHomerun) even if EIT is disabled for that source.  This
means we can have several pointless threads that will do us no good.  Rather
than this, let's only start the thread on capable sources that have EIT
enabled.

Also tweaked the conditional use of the scanner to make sure the scanner
exists to preclude possible NULL pointer crashes.  Moved the check for scanner
first to optimize the execution slightly in the non-EIT case.
  • Loading branch information...
1 parent ebb095b commit 6e8dae55ef4fd162e78e814e15786a96d83ddcd4 @Beirdo Beirdo committed Jun 25, 2011
Showing with 8 additions and 7 deletions.
  1. +8 −7 mythtv/libs/libmythtv/tv_rec.cpp
View
15 mythtv/libs/libmythtv/tv_rec.cpp
@@ -946,7 +946,7 @@ void TVRec::HandleStateChange(void)
// Make sure EIT scan is stopped before any tuning,
// to avoid race condition with it's tuning requests.
- if (HasFlags(kFlagEITScannerRunning))
+ if (scanner && HasFlags(kFlagEITScannerRunning))
{
scanner->StopActiveScan();
ClearFlags(kFlagEITScannerRunning);
@@ -991,8 +991,7 @@ void TVRec::HandleStateChange(void)
changeState = false;
eitScanStartTime = QDateTime::currentDateTime();
- if ((internalState == kState_None) &&
- scanner)
+ if (scanner && (internalState == kState_None))
eitScanStartTime = eitScanStartTime.addSecs(eitCrawlIdleStart);
else
eitScanStartTime = eitScanStartTime.addYears(1);
@@ -1186,7 +1185,8 @@ void TVRec::RunTV(void)
eitScanStartTime = QDateTime::currentDateTime();
// check whether we should use the EITScanner in this TVRec instance
if (CardUtil::IsEITCapable(genOpt.cardtype) &&
- (!GetDTVChannel() || GetDTVChannel()->IsMaster()))
+ (!GetDTVChannel() || GetDTVChannel()->IsMaster()) &&
+ (dvbOpt.dvb_eitscan && get_use_eit(cardid)))
{
scanner = new EITScanner(cardid);
uint timeout = eitCrawlIdleStart;
@@ -1334,7 +1334,7 @@ void TVRec::RunTV(void)
ClearFlags(kFlagExitPlayer);
}
- if (channel && scanner &&
+ if (scanner && channel &&
QDateTime::currentDateTime() > eitScanStartTime)
{
if (!dvbOpt.dvb_eitscan)
@@ -3445,7 +3445,8 @@ void TVRec::TuningShutdowns(const TuningRequest &request)
QString channum, inputname;
uint newCardID = TuningCheckForHWChange(request, channum, inputname);
- if (!(request.flags & kFlagEITScan) && HasFlags(kFlagEITScannerRunning))
+ if (scanner && !(request.flags & kFlagEITScan) &&
+ HasFlags(kFlagEITScannerRunning))
{
scanner->StopActiveScan();
ClearFlags(kFlagEITScannerRunning);
@@ -3755,7 +3756,7 @@ MPEGStreamData *TVRec::TuningSignalCheck(void)
newRecStatus = rsFailed;
- if (HasFlags(kFlagEITScannerRunning))
+ if (scanner && HasFlags(kFlagEITScannerRunning))
{
scanner->StopActiveScan();
ClearFlags(kFlagEITScannerRunning);

0 comments on commit 6e8dae5

Please sign in to comment.
Something went wrong with that request. Please try again.