summaryrefslogtreecommitdiff
path: root/dynamicdevice.c
diff options
context:
space:
mode:
authorLars Hanisch <dvb@flensrocker.de>2011-02-17 01:44:32 +0100
committerLars Hanisch <dvb@flensrocker.de>2011-02-17 01:44:32 +0100
commitc3cc3a490df4937dc70cc2442c6724c4b6d956ec (patch)
treec2a58ac35d051230888a9d60ad405c44764994dc /dynamicdevice.c
parenta5a5be51f1d261a43f142f8be86229f2c46b1482 (diff)
downloadvdr-plugin-dynamite-c3cc3a490df4937dc70cc2442c6724c4b6d956ec.tar.gz
vdr-plugin-dynamite-c3cc3a490df4937dc70cc2442c6724c4b6d956ec.tar.bz2
dynamite can call an external program if the GetTSTimeout of a device triggers
In setup.conf set dynamite.GetTSTimeoutHandler to a program you want to execute. If the udev-property dynamite_timeout_handler_arg is set it will be passed as the argument to it otherwise the devpath with wich the device was attached to dynamite.
Diffstat (limited to 'dynamicdevice.c')
-rw-r--r--dynamicdevice.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/dynamicdevice.c b/dynamicdevice.c
index c7841f0..328e146 100644
--- a/dynamicdevice.c
+++ b/dynamicdevice.c
@@ -251,6 +251,29 @@ void cDynamicDevice::SetDefaultGetTSTimeout(int Seconds)
}
}
+eDynamicDeviceReturnCode cDynamicDevice::SetGetTSTimeoutHandlerArg(const char *DevPath, const char *Arg)
+{
+ if (!DevPath || !Arg)
+ return ddrcNotSupported;
+
+ cMutexLock lock(&arrayMutex);
+ int freeIndex = -1;
+ int index = -1;
+ if (isnumber(DevPath))
+ index = strtol(DevPath, NULL, 10) - 1;
+ else
+ index = IndexOf(DevPath, freeIndex);
+
+ if ((index < 0) || (index >= numDynamicDevices))
+ return ddrcNotFound;
+
+ if (dynamicdevice[index]->getTSTimeoutHandlerArg)
+ delete dynamicdevice[index]->getTSTimeoutHandlerArg;
+ dynamicdevice[index]->getTSTimeoutHandlerArg = new cString(Arg);
+ isyslog("dynamite: set GetTSTimeoutHandlerArg on device %s to %s", DevPath, Arg);
+ return ddrcSuccess;
+}
+
bool cDynamicDevice::IsAttached(const char *DevPath)
{
cMutexLock lock(&arrayMutex);
@@ -262,6 +285,7 @@ bool cDynamicDevice::IsAttached(const char *DevPath)
cDynamicDevice::cDynamicDevice()
:index(-1)
,devpath(NULL)
+,getTSTimeoutHandlerArg(NULL)
,isDetachable(true)
,getTSTimeout(defaultGetTSTimeout)
{
@@ -277,6 +301,9 @@ cDynamicDevice::cDynamicDevice()
cDynamicDevice::~cDynamicDevice()
{
DeleteSubDevice();
+ if (getTSTimeoutHandlerArg)
+ delete getTSTimeoutHandlerArg;
+ getTSTimeoutHandlerArg = NULL;
}
void cDynamicDevice::DeleteSubDevice()
@@ -700,6 +727,10 @@ bool cDynamicDevice::GetTSPacket(uchar *&Data)
d = **devpath;
esyslog("dynamite: device %s hasn't delivered any data for %d seconds, it will be detached", d, getTSTimeout);
cDynamicDeviceProbe::QueueDynamicDeviceCommand(ddpcDetach, *devpath);
+ const char *timeoutHandlerArg = *devpath;
+ if (getTSTimeoutHandlerArg)
+ timeoutHandlerArg = **getTSTimeoutHandlerArg;
+ cDynamicDeviceProbe::QueueDynamicDeviceCommand(ddpcService, *cString::sprintf("dynamite-CallGetTSTimeoutHandler-v0.1 %s", timeoutHandlerArg));
return false;
}
}