Ticket #5754: activeeit-one-in-eight-hours.diff
File activeeit-one-in-eight-hours.diff, 5.2 KB (added by , 16 years ago) |
---|
-
libs/libmythtv/tv_rec.h
371 371 TuningQueue tuningRequests; 372 372 TuningRequest lastTuningRequest; 373 373 QDateTime eitScanStartTime; 374 QDateTime eitScanStopTime; 375 uint activeScanCycleTime; 376 uint activeScanDuration; 374 377 QWaitCondition triggerEventLoop; 375 378 QWaitCondition triggerEventSleep; 376 379 bool m_switchingBuffer; -
libs/libmythtv/tv_rec.cpp
890 890 // to avoid race condition with it's tuning requests. 891 891 if (HasFlags(kFlagEITScannerRunning)) 892 892 { 893 VERBOSE(VB_EIT, LOC + "Stopping EIT Active Scan due to tuning in TVRec::HandleStateChange."); 893 894 scanner->StopActiveScan(); 894 895 ClearFlags(kFlagEITScannerRunning); 895 896 } … … 1309 1310 SetFlags(kFlagRunMainLoop); 1310 1311 ClearFlags(kFlagExitPlayer | kFlagFinishRecording); 1311 1312 1313 uint ActiveCycleSleepSecs; 1314 bool ScanStopped; 1315 1316 ScanStopped = true; 1317 1312 1318 eitScanStartTime = QDateTime::currentDateTime(); 1313 1319 // check whether we should use the EITScanner in this TVRec instance 1314 1320 if (CardUtil::IsEITCapable(genOpt.cardtype) && … … 1444 1450 ClearFlags(kFlagExitPlayer); 1445 1451 } 1446 1452 1453 1454 // EIT Scanner handling 1447 1455 if (channel && scanner && 1448 1456 QDateTime::currentDateTime() > eitScanStartTime) 1449 1457 { … … 1458 1466 "for all sources on this card."); 1459 1467 eitScanStartTime = eitScanStartTime.addYears(1); 1460 1468 } 1469 // Things are good to start Active Scan 1470 // We now know that currentDateTime > eitScanStartTime but we don't know if 1471 // we have exceeded the eitScanStopTime 1461 1472 else 1462 1473 { 1474 // Following are control variables for the improved active scan 1475 // It stops after a defined period and closes the tuner card, 1476 // the idea is to see if it saves some power. There is usually no need 1477 // to scan for EIT data continuously. 1478 1479 // Set the repeat rate of the active scan to 480 minutes (8 hours) 1480 activeScanCycleTime = 480; 1481 // It would be wise to schedule an EIT scan shortly before a recording, 1482 // to check for re-schedules (To Be Done). 1483 1484 // Set the duration of the active scan to 60 minutes (1 hour) 1485 activeScanDuration = 60 * 60; 1486 1487 eitScanStopTime = eitScanStartTime 1488 .addSecs(activeScanDuration); 1489 1490 // Log some information about the settings 1491 VERBOSE(VB_EIT, LOC + 1492 QString("Improved Active Scan cycle time %1 minutes") 1493 .arg(activeScanCycleTime)); 1494 VERBOSE(VB_EIT, LOC + 1495 QString("Improved Active Scan Duration %1 minutes") 1496 .arg(activeScanDuration/60)); 1497 1498 ScanStopped = false ; 1499 1500 // Active Scan is restarted after a recording uses the tuner, so the 1501 // relative position of the 'window' moves as recordings are made. 1502 // If settings give poor programme guide population, they can be changed 1503 // Ideally there could be a control in mythtv-setup where active scan is enabled 1504 1505 VERBOSE(VB_EIT, LOC + "EIT Active Scan being (re)started."); 1463 1506 scanner->StartActiveScan( 1464 1507 this, eitTransportTimeout, eitIgnoresSource); 1465 1508 SetFlags(kFlagEITScannerRunning); 1509 // This next line prevents multiple entries into this 'if' if scan has started 1466 1510 eitScanStartTime = QDateTime::currentDateTime().addYears(1); 1467 1511 } 1468 1512 } 1513 else if (channel && scanner && 1514 (QDateTime::currentDateTime() > eitScanStopTime) && !ScanStopped ) 1515 { 1516 // Now we catch the same conditions but with eitScanStopTime exceeded 1517 // and we haven't already been here, ie. ScanStopped is still false 1469 1518 1519 VERBOSE(VB_EIT, LOC + "Reached Active Scan Duration, ceasing active scan until next cycle. Flushing cache..."); 1520 scanner->StopActiveScan(); 1521 ScanStopped = true ; 1522 1523 // Now calculate the number of seconds we have to wait to complete the 1524 // Active Scan Cycle. This way, the cycle will always be same length. 1525 // (Apart from recordings which will extend the cycle) 1526 // activeScanCycleTime is in minutes and activeScanDuration is in secs 1527 ActiveCycleSleepSecs = activeScanCycleTime * 60 - activeScanDuration; 1528 VERBOSE(VB_EIT, LOC + 1529 QString("Calculated Active Scan wait time of %1 minutes. Active Scan will resume then.") 1530 .arg(ActiveCycleSleepSecs/60)); 1531 1532 // We have to wait for ActiveCycleSleepSecs. This is easily achieved 1533 // by doing nothing until the appropriate time is reached 1534 eitScanStartTime = QDateTime::currentDateTime().addSecs(ActiveCycleSleepSecs); 1535 } 1536 1470 1537 // We should be no more than a few thousand milliseconds, 1471 1538 // as the end recording code does not have a trigger... 1472 1539 // NOTE: If you change anything here, make sure that