Ticket #10076: 0021-make_EIT_start_at_time.patch
File 0021-make_EIT_start_at_time.patch, 11.3 KB (added by , 10 years ago) |
---|
-
mythtv/libs/libmythtv/tv_rec.cpp
diff -Naur mythtv-0.27-20131116-g4ca9300-old/mythtv/libs/libmythtv/tv_rec.cpp mythtv-0.27-20131116-g4ca9300-new/mythtv/libs/libmythtv/tv_rec.cpp
old new 93 93 // Configuration variables from database 94 94 transcodeFirst(false), 95 95 earlyCommFlag(false), runJobOnHostOnly(false), 96 eitCrawlIdleStart(60), eitTransportTimeout(5*60), 96 eitCrawlIdleStart(60), eitTransportTimeout(5*60), eitCrawlDuration(240), 97 97 audioSampleRateDB(0), 98 98 overRecordSecNrml(0), overRecordSecCat(0), 99 99 overRecordCategory(""), … … 169 169 eitTransportTimeout = 170 170 max(gCoreContext->GetNumSetting("EITTransportTimeout", 5) * 60, 6); 171 171 eitCrawlIdleStart = gCoreContext->GetNumSetting("EITCrawIdleStart", 60); 172 // eitCrawlDuration currently hardcoded to 240min as I don't want to change DB schema 173 // by introdution of new setting. 174 // eitCrawlDuration = gCoreContext->GetNumSetting("EITCrawDuration", 240); 175 eitCrawlDuration = 240; 172 176 audioSampleRateDB = gCoreContext->GetNumSetting("AudioSampleRate"); 173 177 overRecordSecNrml = gCoreContext->GetNumSetting("RecordOverTime"); 174 178 overRecordSecCat = gCoreContext->GetNumSetting("CategoryOverTime") * 60; … … 1040 1044 { 1041 1045 scanner->StopActiveScan(); 1042 1046 ClearFlags(kFlagEITScannerRunning); 1047 LOG(VB_GENERAL, LOG_INFO, LOC + 1048 "EIT active scanner stopped by Recording or LiveTV"); 1043 1049 } 1044 1050 1045 1051 // Handle different state transitions … … 1088 1094 internalState = nextState; 1089 1095 changeState = false; 1090 1096 1091 eitScanStartTime = MythDate::current();1097 eitScanStartTime = QDateTime::currentDateTime(); 1092 1098 if (scanner && (internalState == kState_None)) 1093 1099 { 1094 eitScanStartTime = eitScanStartTime.addSecs( 1095 eitCrawlIdleStart + eit_start_rand(cardid, eitTransportTimeout)); 1100 int start_delay = eit_start_rand(cardid, eitTransportTimeout); 1101 // If eitCrawlIdleStart is above 3600 then we enter schedulled mode. 1102 // For values 3600 and below we have old behaviour. 1103 if (eitCrawlIdleStart <= 3600) 1104 { 1105 eitScanStartTime = eitScanStartTime.addSecs( 1106 eitCrawlIdleStart + start_delay); 1107 eitScanEndAT = eitScanStartTime.addYears(1); 1108 LOG(VB_GENERAL, LOG_INFO, LOC + 1109 QString("EIT active scan will resume after %1 sec.").arg(eitCrawlIdleStart + start_delay)); 1110 } 1111 else 1112 { 1113 // Check is current event within active EIT scan window. If it is, 1114 // then scanner will be resumed after 60sec. 1115 // If not, set start/end times nex nearest window. 1116 if ((QDateTime::currentDateTime() < eitScanStartAT) || 1117 (QDateTime::currentDateTime() > eitScanEndAT)) 1118 { 1119 eitScanStartTime.setTime(QTime(0, 0)); 1120 eitScanStartTime = eitScanStartTime.addSecs(eitCrawlIdleStart); 1121 eitScanEndAT = eitScanStartTime.addSecs(eitCrawlDuration*60); 1122 1123 // distribute scan resume time evenly over eitTransportTimeout 1124 eitScanStartTime = eitScanStartTime.addSecs(start_delay); 1125 1126 eitScanStartAT = eitScanStartTime; 1127 // IF we started after window, move start & end 1128 // time to next day 1129 if (QDateTime::currentDateTime() > eitScanEndAT) 1130 { 1131 eitScanStartTime = eitScanStartTime.addDays(1); 1132 eitScanStartAT = eitScanStartAT.addDays(1); 1133 eitScanEndAT = eitScanEndAT.addDays(1); 1134 } 1135 LOG(VB_GENERAL, LOG_INFO, LOC + 1136 QString("EIT active scan will resume at:%1").arg(eitScanStartTime.toString(Qt::ISODate))); 1137 } 1138 else 1139 { 1140 eitScanStartTime = eitScanStartTime.addSecs(60 + start_delay); 1141 LOG(VB_GENERAL, LOG_INFO, LOC + 1142 QString("EIT active scan is in %1min. window. If enabled, will (re)start after %2 sec.") 1143 .arg(eitCrawlDuration).arg(60 + start_delay)); 1144 } 1145 } 1096 1146 } 1097 1147 else 1098 1148 eitScanStartTime = eitScanStartTime.addYears(1); … … 1266 1316 SetFlags(kFlagRunMainLoop); 1267 1317 ClearFlags(kFlagExitPlayer | kFlagFinishRecording); 1268 1318 1269 eitScanStartTime = MythDate::current();1319 eitScanStartTime = QDateTime::currentDateTime(); 1270 1320 // check whether we should use the EITScanner in this TVRec instance 1271 1321 if (CardUtil::IsEITCapable(genOpt.cardtype) && 1272 1322 (!GetDTVChannel() || GetDTVChannel()->IsMaster()) && 1273 1323 (dvbOpt.dvb_eitscan || get_use_eit(cardid))) 1274 1324 { 1275 1325 scanner = new EITScanner(cardid); 1276 eitScanStartTime = eitScanStartTime.addSecs( 1277 eitCrawlIdleStart + eit_start_rand(cardid, eitTransportTimeout)); 1326 int start_delay = eit_start_rand(cardid, eitTransportTimeout); 1327 1328 if (eitCrawlIdleStart <= 3600) 1329 { 1330 eitScanStartTime = eitScanStartTime.addSecs(eitCrawlIdleStart + start_delay); 1331 1332 eitScanEndAT = eitScanStartTime.addYears(1); 1333 LOG(VB_GENERAL, LOG_INFO, LOC + 1334 QString("EIT active scan start after %1 sec.").arg(eitCrawlIdleStart + start_delay)); 1335 } 1336 else 1337 { 1338 // Set initial scan start / end times to 1339 // 0:00+eitCrawlIdleStart / eitCrawlIdleStart+eitCrawlDuration. 1340 eitScanStartTime.setTime(QTime(0, 0)); 1341 eitScanStartTime = eitScanStartTime.addSecs(eitCrawlIdleStart); 1342 eitScanEndAT = eitScanStartTime.addSecs(eitCrawlDuration*60); 1343 eitScanStartAT = eitScanStartTime.addSecs(start_delay); 1344 1345 // If we are in scan window then delay and randomize start 1346 if (QDateTime::currentDateTime() > eitScanStartAT && QDateTime::currentDateTime() < eitScanEndAT) 1347 { 1348 eitScanStartTime = QDateTime::currentDateTime(); 1349 eitScanStartTime = eitScanStartTime.addSecs(60 + start_delay); 1350 LOG(VB_GENERAL, LOG_INFO, LOC + 1351 QString("EIT scanner is in window & will start: %1").arg(eitScanStartTime.toString(Qt::ISODate))); 1352 } 1353 1354 // If we are started after scan window, then move start & end 1355 // times to next day 1356 if (QDateTime::currentDateTime() > eitScanEndAT) 1357 { 1358 eitScanStartTime = eitScanStartTime.addDays(1); 1359 eitScanStartAT = eitScanStartAT.addDays(1); 1360 eitScanEndAT = eitScanEndAT.addDays(1); 1361 } 1362 1363 LOG(VB_GENERAL, LOG_INFO, LOC + 1364 QString("EIT active scan window: %1").arg(eitScanStartAT.toString(Qt::ISODate)) + 1365 QString(" <--> %1 ").arg(eitScanEndAT.toString(Qt::ISODate))); 1366 } 1278 1367 } 1279 1368 else 1369 { 1280 1370 eitScanStartTime = eitScanStartTime.addYears(1); 1371 eitScanEndAT = eitScanStartTime; 1372 } 1281 1373 1282 1374 while (HasFlags(kFlagRunMainLoop)) 1283 1375 { … … 1408 1500 } 1409 1501 1410 1502 if (scanner && channel && 1411 MythDate::current() > eitScanStartTime)1503 (QDateTime::currentDateTime() > eitScanStartTime || QDateTime::currentDateTime() > eitScanEndAT)) 1412 1504 { 1413 1505 if (!dvbOpt.dvb_eitscan) 1414 1506 { 1415 1507 LOG(VB_EIT, LOG_INFO, LOC + 1416 1508 "EIT scanning disabled for this card."); 1417 1509 eitScanStartTime = eitScanStartTime.addYears(1); 1510 eitScanEndAT = eitScanEndAT.addYears(1); 1418 1511 } 1419 1512 else if (!get_use_eit(GetCaptureCardNum())) 1420 1513 { 1421 1514 LOG(VB_EIT, LOG_INFO, LOC + 1422 1515 "EIT scanning disabled for all sources on this card."); 1423 1516 eitScanStartTime = eitScanStartTime.addYears(1); 1517 eitScanEndAT = eitScanEndAT.addYears(1); 1424 1518 } 1425 1519 else 1426 1520 { 1427 scanner->StartActiveScan(this, eitTransportTimeout); 1428 SetFlags(kFlagEITScannerRunning); 1429 eitScanStartTime = MythDate::current().addYears(1); 1521 if (QDateTime::currentDateTime() > eitScanStartTime && QDateTime::currentDateTime() < eitScanEndAT) 1522 { 1523 scanner->StartActiveScan(this, eitTransportTimeout); 1524 SetFlags(kFlagEITScannerRunning); 1525 eitScanStartTime = MythDate::current().addYears(1); 1526 LOG(VB_GENERAL, LOG_INFO, LOC + 1527 "EIT active scan started."); 1528 } 1529 else if (QDateTime::currentDateTime() > eitScanEndAT && HasFlags(kFlagEITScannerRunning)) 1530 { 1531 scanner->StopActiveScan(); 1532 ClearFlags(kFlagEITScannerRunning); 1533 LOG(VB_GENERAL, LOG_INFO, LOC + 1534 "EIT active scan stopped by reaching time window."); 1535 } 1430 1536 } 1431 1537 } 1432 1538 -
mythtv/libs/libmythtv/tv_rec.h
diff -Naur mythtv-0.27-20131116-g4ca9300-old/mythtv/libs/libmythtv/tv_rec.h mythtv-0.27-20131116-g4ca9300-new/mythtv/libs/libmythtv/tv_rec.h
old new 344 344 bool runJobOnHostOnly; 345 345 int eitCrawlIdleStart; 346 346 int eitTransportTimeout; 347 int eitCrawlDuration; 347 348 int audioSampleRateDB; 348 349 int overRecordSecNrml; 349 350 int overRecordSecCat; … … 371 372 TuningQueue tuningRequests; 372 373 TuningRequest lastTuningRequest; 373 374 QDateTime eitScanStartTime; 375 QDateTime eitScanStartAT; 376 QDateTime eitScanEndAT; 374 377 mutable QMutex triggerEventLoopLock; 375 378 QWaitCondition triggerEventLoopWait; 376 379 bool triggerEventLoopSignal; -
mythtv/programs/mythtv-setup/backendsettings.cpp
diff -Naur mythtv-0.27-20131116-g4ca9300-old/mythtv/programs/mythtv-setup/backendsettings.cpp mythtv-0.27-20131116-g4ca9300-new/mythtv/programs/mythtv-setup/backendsettings.cpp
old new 308 308 309 309 static GlobalSpinBox *EITCrawIdleStart() 310 310 { 311 GlobalSpinBox *gc = new GlobalSpinBox("EITCrawIdleStart", 30, 7200, 30);311 GlobalSpinBox *gc = new GlobalSpinBox("EITCrawIdleStart", 30, 86400, 20); 312 312 gc->setLabel(QObject::tr("Backend idle before EIT crawl (secs)")); 313 313 gc->setValue(60); 314 314 QString help = QObject::tr( 315 "The minimum number of seconds after a recorder becomes idle " 316 "to wait before MythTV begins collecting EIT listings data."); 315 "The number of seconds for idle recorders when collecting EIT listings begins. " 316 "If this value is higher than 3600 sec, MythTV will switch to schedulled mode" 317 " where collecting starts this number of seconds after midnight and will go" 318 " for 4h time window." 319 ); 317 320 gc->setHelpText(help); 318 321 return gc; 319 322 }