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 18:13:36 (GMT)
commit6e8dae55ef4fd162e78e814e15786a96d83ddcd4 (patch)
tree0d0b58677df1e03d879a116a18f5ff53c1bb1c0c
parentebb095bd3867b8afc7a8d4e877f1569633d2f188 (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 cd3e043..657a798 100644
--- a/mythtv/libs/libmythtv/tv_rec.cpp
+++ b/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);