Ticket #10076: 0009-make_EIT_start_at_time.2.patch
File 0009-make_EIT_start_at_time.2.patch, 11.3 KB (added by , 9 years ago) |
---|
-
mythtv/libs/libmythtv/tv_rec.cpp
diff -Naur mythtv-master-20150827-g4a81075-old/mythtv/libs/libmythtv/tv_rec.cpp mythtv-master-20150827-g4a81075-new/mythtv/libs/libmythtv/tv_rec.cpp
old new 95 95 // Configuration variables from database 96 96 transcodeFirst(false), 97 97 earlyCommFlag(false), runJobOnHostOnly(false), 98 eitCrawlIdleStart(60), eitTransportTimeout(5*60), 98 eitCrawlIdleStart(60), eitTransportTimeout(5*60), eitCrawlDuration(240), 99 99 audioSampleRateDB(0), 100 100 overRecordSecNrml(0), overRecordSecCat(0), 101 101 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; … … 1065 1069 { 1066 1070 scanner->StopActiveScan(); 1067 1071 ClearFlags(kFlagEITScannerRunning, __FILE__, __LINE__); 1072 LOG(VB_GENERAL, LOG_INFO, LOC + 1073 "EIT active scanner stopped by Recording or LiveTV"); 1068 1074 } 1069 1075 1070 1076 // Handle different state transitions … … 1113 1119 internalState = nextState; 1114 1120 changeState = false; 1115 1121 1116 eitScanStartTime = MythDate::current();1122 eitScanStartTime = QDateTime::currentDateTime(); 1117 1123 if (scanner && (internalState == kState_None)) 1118 1124 { 1119 eitScanStartTime = eitScanStartTime.addSecs( 1120 eitCrawlIdleStart + eit_start_rand(inputid, eitTransportTimeout)); 1125 int start_delay = eit_start_rand(inputid, eitTransportTimeout); 1126 // If eitCrawlIdleStart is above 3600 then we enter schedulled mode. 1127 // For values 3600 and below we have old behaviour. 1128 if (eitCrawlIdleStart <= 3600) 1129 { 1130 eitScanStartTime = eitScanStartTime.addSecs( 1131 eitCrawlIdleStart + start_delay); 1132 eitScanEndTime = eitScanStartTime.addYears(1); 1133 LOG(VB_GENERAL, LOG_INFO, LOC + 1134 QString("EIT active scan will resume after %1 sec.").arg(eitCrawlIdleStart + start_delay)); 1135 } 1136 else 1137 { 1138 // Check is current event within active EIT scan window. If it is, 1139 // then scanner will be resumed after 60sec. 1140 // If not, set start/end times next nearest window. 1141 if ((QDateTime::currentDateTime() < eitScanStartTime) || 1142 (QDateTime::currentDateTime() > eitScanEndTime)) 1143 { 1144 eitScanStartTime.setTime(QTime(0, 0)); 1145 eitScanStartTime = eitScanStartTime.addSecs(eitCrawlIdleStart); 1146 eitScanEndTime = eitScanStartTime.addSecs(eitCrawlDuration*60); 1147 1148 // distribute scan resume time evenly over eitTransportTimeout 1149 eitScanStartTime = eitScanStartTime.addSecs(start_delay); 1150 1151 // IF we started after window, move start & end 1152 // time to next day 1153 if (QDateTime::currentDateTime() > eitScanEndTime) 1154 { 1155 eitScanStartTime = eitScanStartTime.addDays(1); 1156 eitScanEndTime = eitScanEndTime.addDays(1); 1157 } 1158 LOG(VB_GENERAL, LOG_INFO, LOC + 1159 QString("EIT active scan will resume at:%1").arg(eitScanStartTime.toString(Qt::ISODate))); 1160 } 1161 else 1162 { 1163 eitScanStartTime = eitScanStartTime.addSecs(60 + start_delay); 1164 LOG(VB_GENERAL, LOG_INFO, LOC + 1165 QString("EIT active scan is in %1min. window. If enabled, will (re)start after %2 sec.") 1166 .arg(eitCrawlDuration).arg(60 + start_delay)); 1167 } 1168 } 1121 1169 } 1122 1170 else 1123 1171 eitScanStartTime = eitScanStartTime.addYears(1); … … 1314 1362 SetFlags(kFlagRunMainLoop, __FILE__, __LINE__); 1315 1363 ClearFlags(kFlagExitPlayer | kFlagFinishRecording, __FILE__, __LINE__); 1316 1364 1317 eitScanStartTime = MythDate::current();1365 eitScanStartTime = QDateTime::currentDateTime(); 1318 1366 // check whether we should use the EITScanner in this TVRec instance 1319 1367 if (CardUtil::IsEITCapable(genOpt.inputtype) && 1320 1368 (!GetDTVChannel() || GetDTVChannel()->IsMaster()) && 1321 1369 (dvbOpt.dvb_eitscan || get_use_eit(inputid))) 1322 1370 { 1323 1371 scanner = new EITScanner(inputid); 1324 eitScanStartTime = eitScanStartTime.addSecs( 1325 eitCrawlIdleStart + eit_start_rand(inputid, eitTransportTimeout)); 1372 int start_delay = eit_start_rand(inputid, eitTransportTimeout); 1373 1374 if (eitCrawlIdleStart <= 3600) 1375 { 1376 eitScanStartTime = eitScanStartTime.addSecs(eitCrawlIdleStart + start_delay); 1377 1378 eitScanEndTime = eitScanStartTime.addYears(1); 1379 LOG(VB_GENERAL, LOG_INFO, LOC + 1380 QString("EIT active scan start after %1 sec.").arg(eitCrawlIdleStart + start_delay)); 1381 } 1382 else 1383 { 1384 // Set initial scan start / end times to 1385 // 0:00+eitCrawlIdleStart / eitCrawlIdleStart+eitCrawlDuration. 1386 eitScanStartTime.setTime(QTime(0, 0)); 1387 eitScanStartTime = eitScanStartTime.addSecs(eitCrawlIdleStart + start_delay); 1388 eitScanEndTime = eitScanStartTime.addSecs(eitCrawlDuration*60); 1389 1390 // If we are in scan window then delay and randomize start 1391 if (QDateTime::currentDateTime() > eitScanStartTime && QDateTime::currentDateTime() < eitScanEndTime) 1392 { 1393 eitScanStartTime = QDateTime::currentDateTime(); 1394 eitScanStartTime = eitScanStartTime.addSecs(60 + start_delay); 1395 LOG(VB_GENERAL, LOG_INFO, LOC + 1396 QString("EIT scanner is in window & will start: %1").arg(eitScanStartTime.toString(Qt::ISODate))); 1397 } 1398 1399 // If we are started after scan window, then move start & end 1400 // times to next day 1401 if (QDateTime::currentDateTime() > eitScanEndTime) 1402 { 1403 eitScanStartTime = eitScanStartTime.addDays(1); 1404 eitScanEndTime = eitScanEndTime.addDays(1); 1405 } 1406 1407 LOG(VB_GENERAL, LOG_INFO, LOC + 1408 QString("EIT active scan window: %1").arg(eitScanStartTime.toString(Qt::ISODate)) + 1409 QString(" <--> %1 ").arg(eitScanEndTime.toString(Qt::ISODate)) + QString("(%1min duration)").arg(eitCrawlDuration)); 1410 } 1326 1411 } 1327 1412 else 1413 { 1328 1414 eitScanStartTime = eitScanStartTime.addYears(1); 1415 eitScanEndTime = eitScanStartTime; 1416 } 1329 1417 1330 1418 while (HasFlags(kFlagRunMainLoop)) 1331 1419 { … … 1457 1545 } 1458 1546 1459 1547 if (scanner && channel && 1460 MythDate::current() > eitScanStartTime)1548 (QDateTime::currentDateTime() > eitScanStartTime || QDateTime::currentDateTime() > eitScanEndTime)) 1461 1549 { 1462 1550 if (!dvbOpt.dvb_eitscan) 1463 1551 { 1464 1552 LOG(VB_EIT, LOG_INFO, LOC + 1465 1553 "EIT scanning disabled for this input."); 1466 1554 eitScanStartTime = eitScanStartTime.addYears(1); 1555 eitScanEndTime = eitScanEndTime.addYears(1); 1467 1556 } 1468 1557 else if (!get_use_eit(GetInputId())) 1469 1558 { 1470 1559 LOG(VB_EIT, LOG_INFO, LOC + 1471 1560 "EIT scanning disabled for all sources on this input."); 1472 1561 eitScanStartTime = eitScanStartTime.addYears(1); 1562 eitScanEndTime = eitScanEndTime.addYears(1); 1473 1563 } 1474 1564 else 1475 1565 { 1476 scanner->StartActiveScan(this, eitTransportTimeout); 1477 SetFlags(kFlagEITScannerRunning, __FILE__, __LINE__); 1478 eitScanStartTime = MythDate::current().addYears(1); 1566 if (QDateTime::currentDateTime() > eitScanStartTime && QDateTime::currentDateTime() < eitScanEndTime) 1567 { 1568 scanner->StartActiveScan(this, eitTransportTimeout); 1569 SetFlags(kFlagEITScannerRunning, __FILE__, __LINE__); 1570 eitScanStartTime = MythDate::current().addYears(1); 1571 LOG(VB_GENERAL, LOG_INFO, LOC + 1572 "EIT active scan started."); 1573 } 1574 else if (QDateTime::currentDateTime() > eitScanEndTime && HasFlags(kFlagEITScannerRunning)) 1575 { 1576 scanner->StopActiveScan(); 1577 ClearFlags(kFlagEITScannerRunning, __FILE__, __LINE__); 1578 LOG(VB_GENERAL, LOG_INFO, LOC + 1579 "EIT active scan stopped by reaching time window."); 1580 } 1479 1581 } 1480 1582 } 1481 1583 -
mythtv/libs/libmythtv/tv_rec.h
diff -Naur mythtv-master-20150827-g4a81075-old/mythtv/libs/libmythtv/tv_rec.h mythtv-master-20150827-g4a81075-new/mythtv/libs/libmythtv/tv_rec.h
old new 363 363 bool runJobOnHostOnly; 364 364 int eitCrawlIdleStart; 365 365 int eitTransportTimeout; 366 int eitCrawlDuration; 366 367 int audioSampleRateDB; 367 368 int overRecordSecNrml; 368 369 int overRecordSecCat; … … 392 393 TuningQueue tuningRequests; 393 394 TuningRequest lastTuningRequest; 394 395 QDateTime eitScanStartTime; 396 QDateTime eitScanEndTime; 395 397 mutable QMutex triggerEventLoopLock; 396 398 QWaitCondition triggerEventLoopWait; 397 399 bool triggerEventLoopSignal; -
mythtv/programs/mythtv-setup/backendsettings.cpp
diff -Naur mythtv-master-20150827-g4a81075-old/mythtv/programs/mythtv-setup/backendsettings.cpp mythtv-master-20150827-g4a81075-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 EITCrawDuration or if not defined, 4h time window." 319 ); 317 320 gc->setHelpText(help); 318 321 return gc; 319 322 }