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 ef39225 commit 5e67f945d1ce3b15c0be9c44c5bb8e4d2bb9bdd5 @Beirdo Beirdo committed
Showing with 8 additions and 7 deletions.
  1. +8 −7 mythtv/libs/libmythtv/tv_rec.cpp
View
15 mythtv/libs/libmythtv/tv_rec.cpp
@@ -942,7 +942,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);
@@ -987,8 +987,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);
@@ -1398,7 +1397,8 @@ void TVRec::RunTV(void)
eitScanStartTime = QDateTime::currentDateTime();
// check whether we should use the EITScanner in this TVRec instance
if (CardUtil::IsEITCapable(genOpt.cardtype) &&
- (!GetDVBChannel() || GetDVBChannel()->IsMaster()))
+ (!GetDTVChannel() || GetDTVChannel()->IsMaster()) &&
+ (dvbOpt.dvb_eitscan && get_use_eit(cardid)))
{
scanner = new EITScanner(cardid);
uint timeout = eitCrawlIdleStart;
@@ -1560,7 +1560,7 @@ void TVRec::RunTV(void)
ClearFlags(kFlagExitPlayer);
}
- if (channel && scanner &&
+ if (scanner && channel &&
QDateTime::currentDateTime() > eitScanStartTime)
{
if (!dvbOpt.dvb_eitscan)
@@ -3637,7 +3637,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);
@@ -3908,7 +3909,7 @@ MPEGStreamData *TVRec::TuningSignalCheck(void)
if (curRecording)
curRecording->SetRecordingStatus(rsFailed);
- if (HasFlags(kFlagEITScannerRunning))
+ if (scanner && HasFlags(kFlagEITScannerRunning))
{
scanner->StopActiveScan();
ClearFlags(kFlagEITScannerRunning);

0 comments on commit 5e67f94

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