diff -Naur mythtv-master-20201010-g68e85b9-old/mythtv/libs/libmythtv/tv_rec.cpp mythtv-master-20201010-g68e85b9-new/mythtv/libs/libmythtv/tv_rec.cpp
old
|
new
|
|
157 | 157 | m_eitTransportTimeout = |
158 | 158 | std::max(gCoreContext->GetNumSetting("EITTransportTimeout", 5) * 60, 6); |
159 | 159 | m_eitCrawlIdleStart = gCoreContext->GetNumSetting("EITCrawIdleStart", 60); |
| 160 | // EITCrawlDuration currently defaulted to 240min. |
| 161 | // if user wants diferent value, EITCrawlDuration setting shoud be added to settings table |
| 162 | m_eitCrawlDuration = gCoreContext->GetNumSetting("EITCrawDuration", 240); |
| 163 | // m_eitCrawlDuration = 240; |
160 | 164 | m_audioSampleRateDB = gCoreContext->GetNumSetting("AudioSampleRate"); |
161 | 165 | m_overRecordSecNrml = gCoreContext->GetNumSetting("RecordOverTime"); |
162 | 166 | m_overRecordSecCat = gCoreContext->GetNumSetting("CategoryOverTime") * 60; |
… |
… |
|
1051 | 1055 | ClearFlags(kFlagEITScannerRunning, __FILE__, __LINE__); |
1052 | 1056 | m_eitScanStartTime = MythDate::current().addSecs( |
1053 | 1057 | m_eitCrawlIdleStart + eit_start_rand(m_inputId, m_eitTransportTimeout)); |
| 1058 | LOG(VB_GENERAL, LOG_INFO, LOC + |
| 1059 | "EIT active scanner stopped by Recording or LiveTV"); |
1054 | 1060 | } |
1055 | 1061 | |
1056 | 1062 | // Handle different state transitions |
… |
… |
|
1103 | 1109 | m_internalState = nextState; |
1104 | 1110 | m_changeState = false; |
1105 | 1111 | |
1106 | | m_eitScanStartTime = MythDate::current(); |
| 1112 | m_eitScanStartTime = QDateTime::currentDateTime(); |
1107 | 1113 | if (m_scanner && (m_internalState == kState_None)) |
1108 | 1114 | { |
1109 | | m_eitScanStartTime = m_eitScanStartTime.addSecs( |
1110 | | m_eitCrawlIdleStart + eit_start_rand(m_inputId, m_eitTransportTimeout)); |
| 1115 | int start_delay = eit_start_rand(m_inputId, m_eitTransportTimeout); |
| 1116 | // If eitCrawlIdleStart is above 3600 then we enter schedulled mode. |
| 1117 | // For values 3600 and below we have old behaviour. |
| 1118 | if (m_eitCrawlIdleStart <= 3600) |
| 1119 | { |
| 1120 | m_eitScanStartTime = m_eitScanStartTime.addSecs( |
| 1121 | m_eitCrawlIdleStart + start_delay); |
| 1122 | m_eitScanEndTime = m_eitScanStartTime.addYears(10); |
| 1123 | LOG(VB_GENERAL, LOG_INFO, LOC + |
| 1124 | QString("EIT active scan will resume after %1 sec.").arg(m_eitCrawlIdleStart + start_delay)); |
| 1125 | } |
| 1126 | else |
| 1127 | { |
| 1128 | // Check is current event within active EIT scan window. If it is, |
| 1129 | // then scanner will be resumed after 60sec. |
| 1130 | // If not, set start/end times next nearest window. |
| 1131 | if ((QDateTime::currentDateTime() < m_eitScanStartTime) || |
| 1132 | (QDateTime::currentDateTime() > m_eitScanEndTime)) |
| 1133 | { |
| 1134 | m_eitScanStartTime.setTime(QTime(0, 0)); |
| 1135 | m_eitScanStartTime = m_eitScanStartTime.addSecs(m_eitCrawlIdleStart); |
| 1136 | m_eitScanEndTime = m_eitScanStartTime.addSecs(m_eitCrawlDuration*60); |
| 1137 | |
| 1138 | // distribute scan resume time evenly over m_eitTransportTimeout |
| 1139 | m_eitScanStartTime = m_eitScanStartTime.addSecs(start_delay); |
| 1140 | |
| 1141 | // IF we started after window, move start & end |
| 1142 | // time to next day |
| 1143 | if (QDateTime::currentDateTime() > m_eitScanEndTime) |
| 1144 | { |
| 1145 | m_eitScanStartTime = m_eitScanStartTime.addDays(1); |
| 1146 | m_eitScanEndTime = m_eitScanEndTime.addDays(1); |
| 1147 | } |
| 1148 | LOG(VB_GENERAL, LOG_INFO, LOC + |
| 1149 | QString("EIT active scan will resume at:%1").arg(m_eitScanStartTime.toString(Qt::ISODate))); |
| 1150 | } |
| 1151 | else |
| 1152 | { |
| 1153 | m_eitScanStartTime = m_eitScanStartTime.addSecs(60 + start_delay); |
| 1154 | LOG(VB_GENERAL, LOG_INFO, LOC + |
| 1155 | QString("EIT active scan is in %1min. window. If enabled, will (re)start after %2 sec.") |
| 1156 | .arg(m_eitCrawlDuration).arg(60 + start_delay)); |
| 1157 | } |
| 1158 | } |
1111 | 1159 | } |
1112 | 1160 | else |
1113 | 1161 | { |
… |
… |
|
1309 | 1357 | SetFlags(kFlagRunMainLoop, __FILE__, __LINE__); |
1310 | 1358 | ClearFlags(kFlagExitPlayer | kFlagFinishRecording, __FILE__, __LINE__); |
1311 | 1359 | |
1312 | | m_eitScanStartTime = MythDate::current(); |
| 1360 | m_eitScanStartTime = QDateTime::currentDateTime(); |
1313 | 1361 | |
1314 | 1362 | // Check whether we should use the EITScanner in this TVRec instance |
1315 | 1363 | if (CardUtil::IsEITCapable(m_genOpt.m_inputType) && // Card type capable of receiving EIT? |
1316 | 1364 | (!GetDTVChannel() || GetDTVChannel()->IsMaster()) && // Card is master and not a multirec instance |
1317 | 1365 | (m_dvbOpt.m_dvbEitScan || get_use_eit(m_inputId))) // EIT is selected for card OR EIT is selected for video source |
1318 | 1366 | { |
1319 | 1367 | m_scanner = new EITScanner(m_inputId); |
1320 | | m_eitScanStartTime = m_eitScanStartTime.addSecs( |
| 1368 | int start_delay = eit_start_rand(m_inputId, m_eitTransportTimeout); |
| 1369 | |
| 1370 | if (m_eitCrawlIdleStart <= 3600) |
| 1371 | { |
| 1372 | m_eitScanStartTime = m_eitScanStartTime.addSecs(m_eitCrawlIdleStart + start_delay); |
| 1373 | |
| 1374 | m_eitScanEndTime = m_eitScanStartTime.addYears(10); |
| 1375 | LOG(VB_GENERAL, LOG_INFO, LOC + |
| 1376 | QString("EIT active scan start after %1 sec.").arg(m_eitCrawlIdleStart + start_delay)); |
| 1377 | } |
| 1378 | else |
| 1379 | { |
| 1380 | // Set initial scan start / end times to |
| 1381 | // 0:00+eitCrawlIdleStart / eitCrawlIdleStart+m_eitCrawlDuration. |
| 1382 | m_eitScanStartTime.setTime(QTime(0, 0)); |
| 1383 | m_eitScanStartTime = m_eitScanStartTime.addSecs(m_eitCrawlIdleStart + start_delay); |
| 1384 | m_eitScanEndTime = m_eitScanStartTime.addSecs(m_eitCrawlDuration*60); |
| 1385 | |
| 1386 | // If we are in scan window then delay and randomize start |
| 1387 | if (QDateTime::currentDateTime() > m_eitScanStartTime && QDateTime::currentDateTime() < m_eitScanEndTime) |
| 1388 | { |
| 1389 | m_eitScanStartTime = QDateTime::currentDateTime(); |
| 1390 | m_eitScanStartTime = m_eitScanStartTime.addSecs(60 + start_delay); |
| 1391 | LOG(VB_GENERAL, LOG_INFO, LOC + |
| 1392 | QString("EIT scanner is in window & will start: %1").arg(m_eitScanStartTime.toString(Qt::ISODate))); |
| 1393 | } |
| 1394 | |
| 1395 | // If we are started after scan window, then move start & end |
| 1396 | // times to next day |
| 1397 | if (QDateTime::currentDateTime() > m_eitScanEndTime) |
| 1398 | { |
| 1399 | m_eitScanStartTime = m_eitScanStartTime.addDays(1); |
| 1400 | m_eitScanEndTime = m_eitScanEndTime.addDays(1); |
| 1401 | } |
| 1402 | |
| 1403 | LOG(VB_GENERAL, LOG_INFO, LOC + |
| 1404 | QString("EIT active scan window: %1").arg(m_eitScanStartTime.toString(Qt::ISODate)) + |
| 1405 | QString(" <--> %1 ").arg(m_eitScanEndTime.toString(Qt::ISODate)) + QString("(%1min duration)").arg(m_eitCrawlDuration)); |
| 1406 | } m_eitScanStartTime = m_eitScanStartTime.addSecs( |
1321 | 1407 | m_eitCrawlIdleStart + eit_start_rand(m_inputId, m_eitTransportTimeout)); |
1322 | 1408 | } |
1323 | 1409 | else |
1324 | 1410 | { |
1325 | 1411 | m_eitScanStartTime = m_eitScanStartTime.addYears(10); |
| 1412 | m_eitScanEndTime = m_eitScanStartTime; |
1326 | 1413 | } |
1327 | 1414 | |
while (HasFlags(kFlagRunMainLoop))
@@ -1462,46 +1549,61 @@
// Start active EIT scan
if (m_scanner && m_channel &&
- MythDate::current() > m_eitScanStartTime)
+ (QDateTime::currentDateTime() > m_eitScanStartTime || QDateTime::currentDateTime() > m_eitScanEndTime))
{
if (!m_dvbOpt.m_dvbEitScan)
{
LOG(VB_EIT, LOG_INFO, LOC +
"EIT scanning disabled for this input.");
m_eitScanStartTime = m_eitScanStartTime.addYears(10);
+ m_eitScanEndTime = m_eitScanEndTime.addYears(10);
}
else if (!get_use_eit(GetInputId()))
{
LOG(VB_EIT, LOG_INFO, LOC +
"EIT scanning disabled for all channels on this input.");
m_eitScanStartTime = m_eitScanStartTime.addYears(10);
+ m_eitScanEndTime = m_eitScanEndTime.addYears(10);
}
else
{
- // Check if another card in the same input group is
- // busy. This could be either virtual DVB-devices or
- // a second tuner on a single card
- s_inputsLock.lockForRead();
- bool allow_eit = true;
- vector<uint> inputids =
- CardUtil::GetConflictingInputs(m_inputId);
- InputInfo busy_input;
- for (uint i = 0; i < inputids.size() && allow_eit; ++i)
- allow_eit = !RemoteIsBusy(inputids[i], busy_input);
- if (allow_eit)
- {
- m_scanner->StartActiveScan(this, m_eitTransportTimeout);
- SetFlags(kFlagEITScannerRunning, __FILE__, __LINE__);
- m_eitScanStartTime =
- QDateTime::currentDateTime().addYears(10);
- }
- else
+
+ if (QDateTime::currentDateTime() > m_eitScanStartTime && QDateTime::currentDateTime() < m_eitScanEndTime)
{
- LOG(VB_EIT, LOG_INFO, LOC + QString(
+
+ // Check if another card in the same input group is
+ // busy. This could be either virtual DVB-devices or
+ // a second tuner on a single card
+ s_inputsLock.lockForRead();
+ bool allow_eit = true;
+ vector<uint> inputids =
+ CardUtil::GetConflictingInputs(m_inputId);
+ InputInfo busy_input;
+ for (uint i = 0; i < inputids.size() && allow_eit; ++i)
+ allow_eit = !RemoteIsBusy(inputids[i], busy_input);
+ if (allow_eit)
+ {
+ m_scanner->StartActiveScan(this, m_eitTransportTimeout);
+ SetFlags(kFlagEITScannerRunning, __FILE__, __LINE__);
+ m_eitScanStartTime = MythDate::current().addYears(10);
+ LOG(VB_GENERAL, LOG_INFO, LOC +
+ "EIT active scan started.");
+ }
+ else
+ {
+ LOG(VB_GENERAL, LOG_INFO, LOC + QString(
"Postponing EIT scan on input [%1] "
"because input %2 is busy")
- .arg(m_inputId).arg(busy_input.m_inputId));
- m_eitScanStartTime = m_eitScanStartTime.addSecs(300);
+ .arg(m_inputId).arg(busy_input.m_inputId));
+ m_eitScanStartTime = m_eitScanStartTime.addSecs(300);
+ }
+ }
+ else if (QDateTime::currentDateTime() > m_eitScanEndTime && HasFlags(kFlagEITScannerRunning))
+ {
+ m_scanner->StopActiveScan();
+ ClearFlags(kFlagEITScannerRunning, __FILE__, __LINE__);
+ LOG(VB_GENERAL, LOG_INFO, LOC +
+ "EIT active scan stopped by reaching time window.");
}
s_inputsLock.unlock();
}
diff -Naur mythtv-master-20201010-g68e85b9-old/mythtv/libs/libmythtv/tv_rec.h mythtv-master-20201010-g68e85b9-new/mythtv/libs/libmythtv/tv_rec.h
old
|
new
|
|
360 | 360 | bool m_runJobOnHostOnly {false}; |
361 | 361 | int m_eitCrawlIdleStart {60}; |
362 | 362 | int m_eitTransportTimeout {5*60}; |
| 363 | int m_eitCrawlDuration {240}; |
363 | 364 | int m_audioSampleRateDB {0}; |
364 | 365 | int m_overRecordSecNrml {0}; |
365 | 366 | int m_overRecordSecCat {0}; |
… |
… |
|
390 | 391 | TuningQueue m_tuningRequests; |
391 | 392 | TuningRequest m_lastTuningRequest {0}; |
392 | 393 | QDateTime m_eitScanStartTime; |
| 394 | QDateTime m_eitScanEndTime; |
393 | 395 | mutable QMutex m_triggerEventLoopLock {QMutex::NonRecursive}; |
394 | 396 | QWaitCondition m_triggerEventLoopWait; |
395 | 397 | bool m_triggerEventLoopSignal {false}; |
diff -Naur mythtv-master-20201010-g68e85b9-old/mythtv/programs/mythtv-setup/backendsettings.cpp mythtv-master-20201010-g68e85b9-new/mythtv/programs/mythtv-setup/backendsettings.cpp
old
|
new
|
|
381 | 381 | |
382 | 382 | static GlobalSpinBoxSetting *EITCrawIdleStart() |
383 | 383 | { |
384 | | auto *gc = new GlobalSpinBoxSetting("EITCrawIdleStart", 30, 7200, 30); |
| 384 | auto *gc = new GlobalSpinBoxSetting("EITCrawIdleStart", 30, 86400, 20); |
385 | 385 | gc->setLabel(QObject::tr("Backend idle before EIT crawl (secs)")); |
386 | 386 | gc->setValue(60); |
387 | 387 | QString help = QObject::tr( |
388 | | "The minimum number of seconds after a recorder becomes idle " |
389 | | "to wait before MythTV begins collecting EIT listings data."); |
| 388 | "The number of seconds for idle recorders when collecting EIT listings begins. " |
| 389 | "If this value is higher than 3600 sec, MythTV will switch to schedulled mode" |
| 390 | " where collecting starts this number of seconds after midnight and will go" |
| 391 | " for EITCrawDuration or if not defined, 4h time window." |
| 392 | ); |
390 | 393 | gc->setHelpText(help); |
391 | 394 | return gc; |
392 | 395 | } |