diff options
-rw-r--r-- | HISTORY | 6 | ||||
-rw-r--r-- | README | 19 | ||||
-rw-r--r-- | dynamicdevice.c | 18 | ||||
-rw-r--r-- | dynamicdevice.h | 1 | ||||
-rw-r--r-- | dynamite.c | 29 |
5 files changed, 68 insertions, 5 deletions
@@ -156,3 +156,9 @@ VDR Plugin 'dynamite' Revision History 2011-07-03: Version 0.0.6f - don't attach devices at probe-time, just queue them + +2011-07-13: Version 0.0.6g + +- add italian translations (thanks to Diego Pierotto) +- add commandline arg --idle-hook=/path/to/program + and as parameter "dynamite.IdleHook = /path/to/program" at setup.conf @@ -195,6 +195,7 @@ Parameters in setup.conf dynamite.DefaultGetTSTimeout = 0 dynamite.GetTSTimeoutHandler = /path/to/program dynamite.FreeDeviceSlots = 0 +dynamite.IdleHook = /path/to/program Commandline Arguments --------------------- @@ -209,6 +210,22 @@ Commandline Arguments -f, --free-device-slots=n leave n slots free for non-dynamic devices of incompatible plugins +-i, --idle-hook=/path/to/program + set program to be called on SetIdle and reactivation + +Idle mode +--------- +A device with no active receiver can be set to "idle". Classes derived +from cDevice shall try to close all resources like filehandles in the +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. +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 "GetTS" watchdog ---------------- @@ -268,4 +285,4 @@ me how to do this... TODO ---- -* implement some OSD functionality for detaching, locking etc. +* implement auto-idle-mode diff --git a/dynamicdevice.c b/dynamicdevice.c index 4910f9b..672cbb1 100644 --- a/dynamicdevice.c +++ b/dynamicdevice.c @@ -6,6 +6,7 @@ cPlugin *cDynamicDevice::dynamite = NULL; int cDynamicDevice::defaultGetTSTimeout = 0; +cString *cDynamicDevice::idleHook = NULL; cDvbDeviceProbe *cDynamicDevice::dvbprobe = NULL; bool cDynamicDevice::enableOsdMessages = false; int cDynamicDevice::numDynamicDevices = 0; @@ -289,6 +290,13 @@ eDynamicDeviceReturnCode cDynamicDevice::SetLockDevice(const char *DevPath, bool return ddrcSuccess; } +static void CallIdleHook(const char *IdleHook, const char *DevPath, bool Idle) +{ + const char *idleHookCmd = *cString::sprintf("%s --idle=%s --device=%s", IdleHook, (Idle ? "on" : "off"), DevPath); + isyslog("dynamite: calling idle hook %s", idleHookCmd); + SystemExec(idleHookCmd, false); +} + eDynamicDeviceReturnCode cDynamicDevice::SetIdle(const char *DevPath, bool Idle) { if (!DevPath) @@ -305,8 +313,16 @@ eDynamicDeviceReturnCode cDynamicDevice::SetIdle(const char *DevPath, bool Idle) if ((index < 0) || (index >= numDynamicDevices)) return ddrcNotFound; - ((cDevice*)dynamicdevice[index])->SetIdle(Idle); isyslog("dynamite: set device %s to %s", DevPath, (Idle ? "idle" : "not idle")); + if (idleHook && !Idle) + CallIdleHook(**idleHook, dynamicdevice[index]->GetDevPath(), Idle); + if (((cDevice*)dynamicdevice[index])->SetIdle(Idle)) { + if (idleHook && Idle) + CallIdleHook(**idleHook, dynamicdevice[index]->GetDevPath(), Idle); + } + else if (idleHook && !Idle) + CallIdleHook(**idleHook, dynamicdevice[index]->GetDevPath(), Idle); + return ddrcSuccess; } diff --git a/dynamicdevice.h b/dynamicdevice.h index 3c4ef37..f920cd0 100644 --- a/dynamicdevice.h +++ b/dynamicdevice.h @@ -19,6 +19,7 @@ class cDynamicDevice : public cDevice { private: static cPlugin *dynamite; static int defaultGetTSTimeout; + static cString *idleHook; static int numDynamicDevices; static cMutex arrayMutex; @@ -10,7 +10,7 @@ #include "menu.h" #include "monitor.h" -static const char *VERSION = "0.0.6f"; +static const char *VERSION = "0.0.6g"; static const char *DESCRIPTION = tr("attach/detach devices on the fly"); static const char *MAINMENUENTRY = NULL; @@ -127,7 +127,9 @@ const char *cPluginDynamite::CommandLineHelp(void) " --GetTSTimeoutHandler=/path/to/program\n" " set program to be called on GetTS-timeout\n" " --free-device-slots=n\n" - " leave n slots free for non-dynamic devices"; + " leave n slots free for non-dynamic devices\n" + " --idle-hook=/path/to/program\n" + " set program to be called on SetIdle and reactivation"; } bool cPluginDynamite::ProcessArgs(int argc, char *argv[]) @@ -139,12 +141,13 @@ bool cPluginDynamite::ProcessArgs(int argc, char *argv[]) {"GetTSTimeout", required_argument, 0, 't'}, {"GetTSTimeoutHandler", required_argument, 0, 'h'}, {"free-device-slots", required_argument, 0, 'f'}, + {"idle-hook", required_argument, 0, 'i'}, {0, 0, 0, 0} }; while (true) { int option_index = 0; - int c = getopt_long(argc, argv, "udt:h:f:", options, &option_index); + int c = getopt_long(argc, argv, "udt:h:f:i:", options, &option_index); if (c == -1) break; switch (c) { @@ -188,6 +191,17 @@ bool cPluginDynamite::ProcessArgs(int argc, char *argv[]) } break; } + case 'i': + { + if (cDynamicDevice::idleHook != NULL) + delete cDynamicDevice::idleHook; + cDynamicDevice::idleHook = NULL; + if (optarg != NULL) { + cDynamicDevice::idleHook = new cString(optarg); + isyslog("dynamite: installing idle-hook %s", **cDynamicDevice::idleHook); + } + break; + } } } return true; @@ -301,6 +315,15 @@ bool cPluginDynamite::SetupParse(const char *Name, const char *Value) else esyslog("dynamite: \"%d\" free device slots is out of range", tmp); } + else if (strcasecmp(Name, "IdleHook") == 0) { + if (cDynamicDevice::idleHook != NULL) + delete cDynamicDevice::idleHook; + cDynamicDevice::idleHook = NULL; + if (Value != NULL) { + cDynamicDevice::idleHook = new cString(Value); + isyslog("dynamite: installing idle-hook %s", **cDynamicDevice::idleHook); + } + } else return false; return true; |