summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Hanisch <dvb@flensrocker.de>2011-09-21 23:38:24 +0200
committerLars Hanisch <dvb@flensrocker.de>2011-09-22 00:11:01 +0200
commit835f90524b4d86e1e572cda3ca751509457ba285 (patch)
treecbaf7a7ae789bbec1a35b0701df1b0b4a116a266
parentb130eca01d7c3ae0e4e8ce1475448958e86a8bcc (diff)
downloadvdr-plugin-dynamite-835f90524b4d86e1e572cda3ca751509457ba285.tar.gz
vdr-plugin-dynamite-835f90524b4d86e1e572cda3ca751509457ba285.tar.bz2
add SVDRP/Service commands SetIdleTimeout and SetIdleWakeup to modify the values on the fly
-rw-r--r--HISTORY4
-rw-r--r--README22
-rw-r--r--dynamicdevice.c13
-rw-r--r--dynamite.c61
4 files changed, 89 insertions, 11 deletions
diff --git a/HISTORY b/HISTORY
index 0d57fba..703d524 100644
--- a/HISTORY
+++ b/HISTORY
@@ -188,3 +188,7 @@ VDR Plugin 'dynamite' Revision History
2011-09-04: Version 0.0.8
- add patch for vdr 1.7.21
+
+2011-09-21: Version 0.0.8a
+
+- add SVDRP/Service commands SetIdleTimeout and SetIdleWakeup to modify the values on the fly
diff --git a/README b/README
index 282d825..459b5f2 100644
--- a/README
+++ b/README
@@ -168,6 +168,18 @@ SetGetTSTimeoutHandlerArg /dev/path/to/device arg
CallGetTSTimeoutHandler arg
Calls the timout handler program with the given arguments.
+"dynamite-SetIdleTimeout-v0.1"
+SIDT minutes
+ Sets the timeout for an used device to be switched into idle mode,
+ a value of 0 will deactivate the auto-idle-mode.
+ alternate command: SetIdleTimeout
+
+"dynamite-SetIdleWakeup-v0.1"
+SIDW hours
+ Sets the timeout for an idle device to be reactivated,
+ a lower interval than 1 hour is not possible.
+ alternate command: SetIdleWakeup
+
Don't forget to prefix them with "plug dynamite"...
Controlling dynamite with the OSD
@@ -227,12 +239,20 @@ method SetIdleDevice. E.g. cDvbDevice will close its frontend so the driver
can enable a power-save mode. And it has been observed that some tuners are
a lot cooler, so it must be good. :-)
An idle device will be ignored by the EIT scanner but will be reactivated
-if it must be used for a recording etc.
+if it's needed for a recording etc.
You can set a programm to be called on every idle-switch. It will receive
the parameters
--idle=[on|off]
--device=/dev/path/to/device
+If you have set an idle-timeout and idle-wakeup value greater than 0, dynamite
+will try to deactivate unused devices on its own. In sporadic intervals it will
+test all devices if their "CloseDvr" was last called "idle-minutes" ago (or
+OpenDvr got called at all).
+After a minimum of "idle-wakeup" hours the device will be reactivated so it can
+be used by the EIT scanner or similar modules. The wakeup cannot be disabled,
+only a minimum of one hour can be specified.
+
"GetTS" watchdog
----------------
Some DVB cards are known to be unstable - sometimes their driver just hangs
diff --git a/dynamicdevice.c b/dynamicdevice.c
index ce4db50..a5817c7 100644
--- a/dynamicdevice.c
+++ b/dynamicdevice.c
@@ -343,21 +343,22 @@ void cDynamicDevice::AutoIdle(void)
cMutexLock lock(&arrayMutex);
time_t now = time(NULL);
bool wokeupSomeDevice = false;
+ int seconds = 0;
for (int i = 0; i < numDynamicDevices; i++) {
if (dynamicdevice[i]->devpath != NULL) {
if (dynamicdevice[i]->IsIdle()) {
- int hours = (now - dynamicdevice[i]->idleSince) / 3600;
- if ((dynamicdevice[i]->idleSince > 0) && (hours >= idleWakeupHours)) {
- isyslog("dynamite: device %s idle for %d hours, waking up", dynamicdevice[i]->GetDevPath(), hours);
+ seconds = now - dynamicdevice[i]->idleSince;
+ if ((dynamicdevice[i]->idleSince > 0) && (seconds >= (idleWakeupHours * 3600))) {
+ isyslog("dynamite: device %s idle for %d hours, waking up", dynamicdevice[i]->GetDevPath(), seconds / 3600);
cDynamicDeviceProbe::QueueDynamicDeviceCommand(ddpcService, *cString::sprintf("dynamite-SetNotIdle-v0.1 %s", dynamicdevice[i]->GetDevPath()));
wokeupSomeDevice = true;
}
}
else {
- int minutes = (now - dynamicdevice[i]->lastCloseDvr) / 60;
- if ((dynamicdevice[i]->lastCloseDvr > 0) && (minutes >= idleTimeoutMinutes)) {
+ seconds = now - dynamicdevice[i]->lastCloseDvr;
+ if ((dynamicdevice[i]->lastCloseDvr > 0) && (seconds >= (idleTimeoutMinutes * 60))) {
if (dynamicdevice[i]->lastCloseDvr > 0)
- isyslog("dynamite: device %s unused for %d minutes, set to idle", dynamicdevice[i]->GetDevPath(), minutes);
+ isyslog("dynamite: device %s unused for %d minutes, set to idle", dynamicdevice[i]->GetDevPath(), seconds / 60);
else
isyslog("dynamite: device %s never used , set to idle", dynamicdevice[i]->GetDevPath());
cDynamicDeviceProbe::QueueDynamicDeviceCommand(ddpcService, *cString::sprintf("dynamite-SetIdle-v0.1 %s", dynamicdevice[i]->GetDevPath()));
diff --git a/dynamite.c b/dynamite.c
index 968d144..374cde9 100644
--- a/dynamite.c
+++ b/dynamite.c
@@ -10,7 +10,7 @@
#include "menu.h"
#include "monitor.h"
-static const char *VERSION = "0.0.8";
+static const char *VERSION = "0.0.8a";
static const char *DESCRIPTION = tr("attach/detach devices on the fly");
static const char *MAINMENUENTRY = NULL;
@@ -133,7 +133,7 @@ const char *cPluginDynamite::CommandLineHelp(void)
" --idle-hook=/path/to/program\n"
" set program to be called on SetIdle and reactivation\n"
" --idle-timeout=m\n"
- " if a device is unused for m minutes set it to idle\n"
+ " if a device is unused for m minutes set it to idle, 0 disables auto-idle (default)\n"
" --idle-wakeup=h\n"
" if a device is idle for h hours wake it up (e.g. for EPG scan)";
}
@@ -214,8 +214,13 @@ bool cPluginDynamite::ProcessArgs(int argc, char *argv[])
{
if ((optarg != NULL) && isnumber(optarg)) {
int tmp = strtol(optarg, NULL, 10);
- if (tmp >= 0)
+ if (tmp >= 0) {
cDynamicDevice::idleTimeoutMinutes = tmp;
+ if (tmp == 0)
+ isyslog("dynamite: disable auto-idle-mode");
+ else
+ isyslog("dynamite: setting auto-idle-timeout to %d minute%s", cDynamicDevice::idleTimeoutMinutes, (cDynamicDevice::idleTimeoutMinutes > 1) ? "s" : "");
+ }
}
break;
}
@@ -223,8 +228,10 @@ bool cPluginDynamite::ProcessArgs(int argc, char *argv[])
{
if ((optarg != NULL) && isnumber(optarg)) {
int tmp = strtol(optarg, NULL, 10);
- if (tmp >= 0)
+ if (tmp > 0) {
cDynamicDevice::idleWakeupHours = tmp;
+ isyslog("dynamite: setting auto-idle-wakeup to %d hour%s", cDynamicDevice::idleWakeupHours, (cDynamicDevice::idleWakeupHours > 1) ? "s" : "");
+ }
}
break;
}
@@ -451,6 +458,20 @@ bool cPluginDynamite::Service(const char *Id, void *Data)
}
return true;
}
+ if (strcmp(Id, "dynamite-SetIdleTimeout-v0.1") == 0) {
+ if (Data != NULL) {
+ int replyCode;
+ SVDRPCommand("SetIdleTimeout", (const char*)Data, replyCode);
+ }
+ return true;
+ }
+ if (strcmp(Id, "dynamite-SetIdleWakeup-v0.1") == 0) {
+ if (Data != NULL) {
+ int replyCode;
+ SVDRPCommand("SetIdleWakeup", (const char*)Data, replyCode);
+ }
+ return true;
+ }
return false;
}
@@ -522,6 +543,14 @@ const char **cPluginDynamite::SVDRPHelpPages(void)
" Sets the argument for the timout handler program.",
"CallGetTSTimeoutHandler arg\n"
" Calls the timout handler program with the given arguments.",
+ "SIDT minutes\n"
+ " Sets the timeout for an used device to be switched into idle mode,\n"
+ " a value of 0 will deactivate the auto-idle-mode.\n"
+ " alternate command: SetIdleTimeout",
+ "SIDW hours\n"
+ " Sets the timeout for an idle device to be reactivated,\n"
+ " a lower interval than 1 hour is not possible.\n"
+ " alternate command: SetIdleWakeup",
NULL
};
return HelpPages;
@@ -681,6 +710,30 @@ cString cPluginDynamite::SVDRPCommand(const char *Command, const char *Option, i
return msg;
}
+ if ((strcasecmp(Command, "SIDT") == 0) || (strcasecmp(Command, "SetIdleTimeout") == 0)) {
+ if (isnumber(Option)) {
+ int minutes = strtol(Option, NULL, 10);
+ if (minutes >= 0) {
+ cDynamicDevice::idleTimeoutMinutes = minutes;
+ return cString::sprintf("set Idle-Timeout to %d minutes", minutes);
+ }
+ ReplyCode = 550;
+ return cString::sprintf("minutes must be greater than or equal to 0");
+ }
+ }
+
+ if ((strcasecmp(Command, "SIDW") == 0) || (strcasecmp(Command, "SetIdleWakeup") == 0)) {
+ if (isnumber(Option)) {
+ int hours = strtol(Option, NULL, 10);
+ if (hours > 0) {
+ cDynamicDevice::idleWakeupHours = hours;
+ return cString::sprintf("set Idle-Wakeup to %d hours", hours);
+ }
+ ReplyCode = 550;
+ return cString::sprintf("hours must be greater than 0");
+ }
+ }
+
return NULL;
}