Ticket #10076: 0009-make_EIT_start_at_time.patch
File 0009-make_EIT_start_at_time.patch, 11.5 KB (added by , 9 years ago) |
---|
-
mythtv/libs/libmythtv/tv_rec.cpp
diff -Naur mythtv-master-20150105-g4216e00-old/mythtv/libs/libmythtv/tv_rec.cpp mythtv-master-20150105-g4216e00-new/mythtv/libs/libmythtv/tv_rec.cpp
old new 94 94 // Configuration variables from database 95 95 transcodeFirst(false), 96 96 earlyCommFlag(false), runJobOnHostOnly(false), 97 eitCrawlIdleStart(60), eitTransportTimeout(5*60), 97 eitCrawlIdleStart(60), eitTransportTimeout(5*60), eitCrawlDuration(240), 98 98 audioSampleRateDB(0), 99 99 overRecordSecNrml(0), overRecordSecCat(0), 100 100 overRecordCategory(""), … … 172 172 eitTransportTimeout = 173 173 max(gCoreContext->GetNumSetting("EITTransportTimeout", 5) * 60, 6); 174 174 eitCrawlIdleStart = gCoreContext->GetNumSetting("EITCrawIdleStart", 60); 175 // eitCrawlDuration currently defaulted to 240min. 176 // if user wants diferent value, EITCrawlDuration setting shoud be added to settings table 177 eitCrawlDuration = gCoreContext->GetNumSetting("EITCrawDuration", 240); 178 // eitCrawlDuration = 240; 175 179 audioSampleRateDB = gCoreContext->GetNumSetting("AudioSampleRate"); 176 180 overRecordSecNrml = gCoreContext->GetNumSetting("RecordOverTime"); 177 181 overRecordSecCat = gCoreContext->GetNumSetting("CategoryOverTime") * 60; … … 1060 1064 { 1061 1065 scanner->StopActiveScan(); 1062 1066 ClearFlags(kFlagEITScannerRunning, __FILE__, __LINE__); 1067 LOG(VB_GENERAL, LOG_INFO, LOC + 1068 "EIT active scanner stopped by Recording or LiveTV"); 1063 1069 } 1064 1070 1065 1071 // Handle different state transitions … … 1108 1114 internalState = nextState; 1109 1115 changeState = false; 1110 1116 1111 eitScanStartTime = MythDate::current();1117 eitScanStartTime = QDateTime::currentDateTime(); 1112 1118 if (scanner && (internalState == kState_None)) 1113 1119 { 1114 eitScanStartTime = eitScanStartTime.addSecs( 1115 eitCrawlIdleStart + eit_start_rand(cardid, eitTransportTimeout)); 1120 int start_delay = eit_start_rand(cardid, eitTransportTimeout); 1121 // If eitCrawlIdleStart is above 3600 then we enter schedulled mode. 1122 // For values 3600 and below we have old behaviour. 1123 if (eitCrawlIdleStart <= 3600) 1124 { 1125 eitScanStartTime = eitScanStartTime.addSecs( 1126 eitCrawlIdleStart + start_delay); 1127 eitScanEndAT = eitScanStartTime.addYears(1); 1128 LOG(VB_GENERAL, LOG_INFO, LOC + 1129 QString("EIT active scan will resume after %1 sec.").arg(eitCrawlIdleStart + start_delay)); 1130 } 1131 else 1132 { 1133 // Check is current event within active EIT scan window. If it is, 1134 // then scanner will be resumed after 60sec. 1135 // If not, set start/end times nex nearest window. 1136 if ((QDateTime::currentDateTime() < eitScanStartAT) || 1137 (QDateTime::currentDateTime() > eitScanEndAT)) 1138 { 1139 eitScanStartTime.setTime(QTime(0, 0)); 1140 eitScanStartTime = eitScanStartTime.addSecs(eitCrawlIdleStart); 1141 eitScanEndAT = eitScanStartTime.addSecs(eitCrawlDuration*60); 1142 1143 // distribute scan resume time evenly over eitTransportTimeout 1144 eitScanStartTime = eitScanStartTime.addSecs(start_delay); 1145 1146 eitScanStartAT = eitScanStartTime; 1147 // IF we started after window, move start & end 1148 // time to next day 1149 if (QDateTime::currentDateTime() > eitScanEndAT) 1150 { 1151 eitScanStartTime = eitScanStartTime.addDays(1); 1152 eitScanStartAT = eitScanStartAT.addDays(1); 1153 eitScanEndAT = eitScanEndAT.addDays(1); 1154 } 1155 LOG(VB_GENERAL, LOG_INFO, LOC + 1156 QString("EIT active scan will resume at:%1").arg(eitScanStartTime.toString(Qt::ISODate))); 1157 } 1158 else 1159 { 1160 eitScanStartTime = eitScanStartTime.addSecs(60 + start_delay); 1161 LOG(VB_GENERAL, LOG_INFO, LOC + 1162 QString("EIT active scan is in %1min. window. If enabled, will (re)start after %2 sec.") 1163 .arg(eitCrawlDuration).arg(60 + start_delay)); 1164 } 1165 } 1116 1166 } 1117 1167 else 1118 1168 eitScanStartTime = eitScanStartTime.addYears(1); … … 1289 1339 SetFlags(kFlagRunMainLoop, __FILE__, __LINE__); 1290 1340 ClearFlags(kFlagExitPlayer | kFlagFinishRecording, __FILE__, __LINE__); 1291 1341 1292 eitScanStartTime = MythDate::current();1342 eitScanStartTime = QDateTime::currentDateTime(); 1293 1343 // check whether we should use the EITScanner in this TVRec instance 1294 1344 if (CardUtil::IsEITCapable(genOpt.cardtype) && 1295 1345 (!GetDTVChannel() || GetDTVChannel()->IsMaster()) && 1296 1346 (dvbOpt.dvb_eitscan || get_use_eit(cardid))) 1297 1347 { 1298 1348 scanner = new EITScanner(cardid); 1299 eitScanStartTime = eitScanStartTime.addSecs( 1300 eitCrawlIdleStart + eit_start_rand(cardid, eitTransportTimeout)); 1349 int start_delay = eit_start_rand(cardid, eitTransportTimeout); 1350 1351 if (eitCrawlIdleStart <= 3600) 1352 { 1353 eitScanStartTime = eitScanStartTime.addSecs(eitCrawlIdleStart + start_delay); 1354 1355 eitScanEndAT = eitScanStartTime.addYears(1); 1356 LOG(VB_GENERAL, LOG_INFO, LOC + 1357 QString("EIT active scan start after %1 sec.").arg(eitCrawlIdleStart + start_delay)); 1358 } 1359 else 1360 { 1361 // Set initial scan start / end times to 1362 // 0:00+eitCrawlIdleStart / eitCrawlIdleStart+eitCrawlDuration. 1363 eitScanStartTime.setTime(QTime(0, 0)); 1364 eitScanStartTime = eitScanStartTime.addSecs(eitCrawlIdleStart); 1365 eitScanEndAT = eitScanStartTime.addSecs(eitCrawlDuration*60); 1366 eitScanStartAT = eitScanStartTime.addSecs(start_delay); 1367 1368 // If we are in scan window then delay and randomize start 1369 if (QDateTime::currentDateTime() > eitScanStartAT && QDateTime::currentDateTime() < eitScanEndAT) 1370 { 1371 eitScanStartTime = QDateTime::currentDateTime(); 1372 eitScanStartTime = eitScanStartTime.addSecs(60 + start_delay); 1373 LOG(VB_GENERAL, LOG_INFO, LOC + 1374 QString("EIT scanner is in window & will start: %1").arg(eitScanStartTime.toString(Qt::ISODate))); 1375 } 1376 1377 // If we are started after scan window, then move start & end 1378 // times to next day 1379 if (QDateTime::currentDateTime() > eitScanEndAT) 1380 { 1381 eitScanStartTime = eitScanStartTime.addDays(1); 1382 eitScanStartAT = eitScanStartAT.addDays(1); 1383 eitScanEndAT = eitScanEndAT.addDays(1); 1384 } 1385 1386 LOG(VB_GENERAL, LOG_INFO, LOC + 1387 QString("EIT active scan window: %1").arg(eitScanStartAT.toString(Qt::ISODate)) + 1388 QString(" <--> %1 ").arg(eitScanEndAT.toString(Qt::ISODate)) + QString("(%1min duration)").arg(eitCrawlDuration)); 1389 } 1301 1390 } 1302 1391 else 1392 { 1303 1393 eitScanStartTime = eitScanStartTime.addYears(1); 1394 eitScanEndAT = eitScanStartTime; 1395 } 1304 1396 1305 1397 while (HasFlags(kFlagRunMainLoop)) 1306 1398 { … … 1432 1524 } 1433 1525 1434 1526 if (scanner && channel && 1435 MythDate::current() > eitScanStartTime)1527 (QDateTime::currentDateTime() > eitScanStartTime || QDateTime::currentDateTime() > eitScanEndAT)) 1436 1528 { 1437 1529 if (!dvbOpt.dvb_eitscan) 1438 1530 { 1439 1531 LOG(VB_EIT, LOG_INFO, LOC + 1440 1532 "EIT scanning disabled for this card."); 1441 1533 eitScanStartTime = eitScanStartTime.addYears(1); 1534 eitScanEndAT = eitScanEndAT.addYears(1); 1442 1535 } 1443 1536 else if (!get_use_eit(GetCaptureCardNum())) 1444 1537 { 1445 1538 LOG(VB_EIT, LOG_INFO, LOC + 1446 1539 "EIT scanning disabled for all sources on this card."); 1447 1540 eitScanStartTime = eitScanStartTime.addYears(1); 1541 eitScanEndAT = eitScanEndAT.addYears(1); 1448 1542 } 1449 1543 else 1450 1544 { 1451 scanner->StartActiveScan(this, eitTransportTimeout); 1452 SetFlags(kFlagEITScannerRunning, __FILE__, __LINE__); 1453 eitScanStartTime = MythDate::current().addYears(1); 1545 if (QDateTime::currentDateTime() > eitScanStartTime && QDateTime::currentDateTime() < eitScanEndAT) 1546 { 1547 scanner->StartActiveScan(this, eitTransportTimeout); 1548 SetFlags(kFlagEITScannerRunning, __FILE__, __LINE__); 1549 eitScanStartTime = MythDate::current().addYears(1); 1550 LOG(VB_GENERAL, LOG_INFO, LOC + 1551 "EIT active scan started."); 1552 } 1553 else if (QDateTime::currentDateTime() > eitScanEndAT && HasFlags(kFlagEITScannerRunning)) 1554 { 1555 scanner->StopActiveScan(); 1556 ClearFlags(kFlagEITScannerRunning, __FILE__, __LINE__); 1557 LOG(VB_GENERAL, LOG_INFO, LOC + 1558 "EIT active scan stopped by reaching time window."); 1559 } 1454 1560 } 1455 1561 } 1456 1562 -
mythtv/libs/libmythtv/tv_rec.h
diff -Naur mythtv-master-20150105-g4216e00-old/mythtv/libs/libmythtv/tv_rec.h mythtv-master-20150105-g4216e00-new/mythtv/libs/libmythtv/tv_rec.h
old new 353 353 bool runJobOnHostOnly; 354 354 int eitCrawlIdleStart; 355 355 int eitTransportTimeout; 356 int eitCrawlDuration; 356 357 int audioSampleRateDB; 357 358 int overRecordSecNrml; 358 359 int overRecordSecCat; … … 382 383 TuningQueue tuningRequests; 383 384 TuningRequest lastTuningRequest; 384 385 QDateTime eitScanStartTime; 386 QDateTime eitScanStartAT; 387 QDateTime eitScanEndAT; 385 388 mutable QMutex triggerEventLoopLock; 386 389 QWaitCondition triggerEventLoopWait; 387 390 bool triggerEventLoopSignal; -
mythtv/programs/mythtv-setup/backendsettings.cpp
diff -Naur mythtv-master-20150105-g4216e00-old/mythtv/programs/mythtv-setup/backendsettings.cpp mythtv-master-20150105-g4216e00-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 }