Unused devices can now be put into a power save mode

This commit is contained in:
Klaus Schmidinger 2024-07-06 11:19:21 +02:00
parent 749ba57dcc
commit e7ea087a6e
7 changed files with 60 additions and 7 deletions

View File

@ -2571,6 +2571,7 @@ Markus Ehrnsperger <markus.ehrnsperger@googlemail.com>
for making logging event status changes also show the previous status
for making a device always being kept occupied if a timer is in VPS margin or needs the
transponder
for suggesting to enable unused devices to be put into a power save mode
Werner Färber <w.faerber@gmx.de>
for reporting a bug in handling the cPluginManager::Active() result when pressing

View File

@ -9919,7 +9919,7 @@ Video Disk Recorder Revision History
- A device is now always kept occupied if a timer is in VPS margin or needs the
transponder (thanks to Markus Ehrnsperger).
2024-06-27:
2024-07-06:
- Updated the Italian OSD texts (thanks to Diego Pierotto).
- Fixed a possible access of a deleted object in the EIT scanner.
@ -9932,3 +9932,6 @@ Video Disk Recorder Revision History
- Removed leftover cMenuRecordings::SetPath().
- The EIT scanner now checks whether there is a proper device before adding a
channel to the scan list.
- Unused devices can now be put into a power save mode (suggested by Markus
Ehrnsperger). Device plugins need to implement the new function
cDevice::SetPowerSaveMode() to make this work.

View File

@ -2117,6 +2117,17 @@ new cMyDeviceHook;
</pre></td></tr></table><p>
and shall not delete this object. It will be automatically deleted when the program ends.
<p>
<b>Power management</b>
<p>
A device that can be put into a power save mode can implement the function
<p><table><tr><td class="code"><pre>
virtual void SetPowerSaveMode(bool On);
</pre></td></tr></table><p>
If On is true, power save mode shall be activated, if it is false,
normal operating mode shall be restored.
<hr><h2><a name="Positioners">Positioners</a></h2>

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: device.c 5.13 2024/03/29 21:46:50 kls Exp $
* $Id: device.c 5.14 2024/07/06 11:19:21 kls Exp $
*/
#include "device.h"
@ -812,6 +812,16 @@ bool cDevice::MaySwitchTransponder(const cChannel *Channel) const
return !Occupied() && !Receiving() && !(pidHandles[ptAudio].pid || pidHandles[ptVideo].pid || pidHandles[ptDolby].pid);
}
void cDevice::SetPowerSaveMode(bool On)
{
}
void cDevice::SetPowerSaveIfUnused(void)
{
if (!Occupied() && !Receiving() && !(pidHandles[ptAudio].pid || pidHandles[ptVideo].pid || pidHandles[ptDolby].pid))
SetPowerSaveMode(true);
}
bool cDevice::SwitchChannel(const cChannel *Channel, bool LiveView)
{
if (LiveView) {
@ -916,6 +926,7 @@ eSetChannelResult cDevice::SetChannel(const cChannel *Channel, bool LiveView)
// channel to it, for possible later decryption:
if (camSlot)
camSlot->AddChannel(Channel);
SetPowerSaveMode(false);
if (SetChannelDevice(Channel, LiveView)) {
// Start section handling:
if (sectionHandler) {
@ -962,8 +973,10 @@ void cDevice::ForceTransferMode(void)
{
if (!cTransferControl::ReceiverDevice()) {
LOCK_CHANNELS_READ;
if (const cChannel *Channel = Channels->GetByNumber(CurrentChannel()))
if (const cChannel *Channel = Channels->GetByNumber(CurrentChannel())) {
SetPowerSaveMode(false);
SetChannelDevice(Channel, false); // this implicitly starts Transfer Mode
}
}
}

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: device.h 5.4 2024/03/29 21:46:50 kls Exp $
* $Id: device.h 5.5 2024/07/06 11:19:21 kls Exp $
*/
#ifndef __DEVICE_H
@ -346,6 +346,14 @@ public:
///< device, without disturbing any other activities. If an occupied timeout
///< has been set for this device, and that timeout has not yet expired,
///< this function returns false.
virtual void SetPowerSaveMode(bool On);
///< Puts the device into power save mode, if applicable.
///< If On is true, power save mode shall be activated, if it is false,
///< normal operating mode shall be restored.
///< The default implementation does nothing.
void SetPowerSaveIfUnused(void);
///< Sets this device into a power save mode if it is not currently used and
///< has implemented SetPowerSaveMode().
bool SwitchChannel(const cChannel *Channel, bool LiveView);
///< Switches the device to the given Channel, initiating transfer mode
///< if necessary.

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: eitscan.c 5.5 2024/06/27 10:49:34 kls Exp $
* $Id: eitscan.c 5.6 2024/07/06 11:19:21 kls Exp $
*/
#include "eitscan.h"
@ -105,6 +105,7 @@ cEITScanner EITScanner;
cEITScanner::cEITScanner(void)
{
paused = false;
lastScan = 0;
lastActivity = time(NULL);
currentChannel = 0;
@ -145,8 +146,23 @@ void cEITScanner::Process(void)
if (Setup.EPGScanTimeout || !lastActivity) { // !lastActivity means a scan was forced
time_t now = time(NULL);
if (now - lastScan > ScanTimeout && now - lastActivity > ActivityTimeout) {
if (Setup.EPGPauseAfterScan && scanList->Count() == 0 && lastActivity && lastScan && now - lastScan < Setup.EPGScanTimeout * 3600)
if (Setup.EPGPauseAfterScan && scanList->Count() == 0 && lastActivity && lastScan && now - lastScan < Setup.EPGScanTimeout * 3600) {
if (!paused) {
dsyslog("pause EPG scan");
paused = true;
}
// Allow unused devices to go into power save mode:
for (int i = 0; i < cDevice::NumDevices(); i++) {
if (cDevice *Device = cDevice::GetDevice(i))
Device->SetPowerSaveIfUnused();
}
lastScan = time(NULL); // let's not do this too often
return; // pause for Setup.EPGScanTimeout hours
}
else if (paused) {
dsyslog("start EPG scan");
paused = false;
}
cStateKey StateKey;
if (const cChannels *Channels = cChannels::GetChannelsRead(StateKey, 10)) {
if (scanList->Count() == 0) {

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: eitscan.h 2.1 2012/03/07 14:16:57 kls Exp $
* $Id: eitscan.h 5.1 2024/07/06 11:19:21 kls Exp $
*/
#ifndef __EITSCAN_H
@ -23,6 +23,7 @@ private:
enum { ActivityTimeout = 60,
ScanTimeout = 20
};
bool paused;
time_t lastScan, lastActivity;
int currentChannel;
cScanList *scanList;