summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGavin Hurlbut <ghurlbut@mythtv.org>2011-06-25 23:00:07 (GMT)
committer Gavin Hurlbut <ghurlbut@mythtv.org>2011-06-28 21:04:14 (GMT)
commit5e67f945d1ce3b15c0be9c44c5bb8e4d2bb9bdd5 (patch)
treec98097de4680f226229fe0bf3d6a93b75ca24b22
parentef3922514267e53c774ecaeda52d2aa071a1ecf2 (diff)
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.
-rw-r--r--mythtv/libs/libmythtv/tv_rec.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/mythtv/libs/libmythtv/tv_rec.cpp b/mythtv/libs/libmythtv/tv_rec.cpp
index b885eaa..a7e246c 100644
--- a/mythtv/libs/libmythtv/tv_rec.cpp
+++ b/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);