diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 3cd5b95c..d1bf201e 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -2571,6 +2571,7 @@ Markus Ehrnsperger 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 for reporting a bug in handling the cPluginManager::Active() result when pressing diff --git a/HISTORY b/HISTORY index 725dcc59..d76f8c74 100644 --- a/HISTORY +++ b/HISTORY @@ -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. diff --git a/PLUGINS.html b/PLUGINS.html index deb5a313..9bac2a91 100644 --- a/PLUGINS.html +++ b/PLUGINS.html @@ -2117,6 +2117,17 @@ new cMyDeviceHook;

and shall not delete this object. It will be automatically deleted when the program ends. +

+Power management +

+A device that can be put into a power save mode can implement the function + +

+virtual void SetPowerSaveMode(bool On);
+

+ +If On is true, power save mode shall be activated, if it is false, +normal operating mode shall be restored.


Positioners

diff --git a/device.c b/device.c index f1aa6a98..b9c52190 100644 --- a/device.c +++ b/device.c @@ -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 + } } } diff --git a/device.h b/device.h index 061d43c9..9354b163 100644 --- a/device.h +++ b/device.h @@ -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. diff --git a/eitscan.c b/eitscan.c index 395414e2..a44a39d2 100644 --- a/eitscan.c +++ b/eitscan.c @@ -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) { diff --git a/eitscan.h b/eitscan.h index 128b0b0a..d6807421 100644 --- a/eitscan.h +++ b/eitscan.h @@ -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;