summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Hanisch <dvb@flensrocker.de>2012-01-04 23:01:41 +0100
committerLars Hanisch <dvb@flensrocker.de>2012-01-04 23:01:41 +0100
commit4c2297e076c351194b308ee077b9e262300f008b (patch)
treee8e883bcefb7aec467b07b401816d8e9f1b86841
parent30759991089691c10b1235b725abb419f5d518e1 (diff)
downloadvdr-plugin-dynamite-4c2297e076c351194b308ee077b9e262300f008b.tar.gz
vdr-plugin-dynamite-4c2297e076c351194b308ee077b9e262300f008b.tar.bz2
if device is not ready after 30 seconds reset CAMs and retryv0.0.9a
-rw-r--r--dynamicdevice.c31
-rw-r--r--dynamicdevice.h1
2 files changed, 28 insertions, 4 deletions
diff --git a/dynamicdevice.c b/dynamicdevice.c
index fb27887..ae0cab3 100644
--- a/dynamicdevice.c
+++ b/dynamicdevice.c
@@ -5,6 +5,8 @@
#include <vdr/skins.h>
#include <vdr/transfer.h>
+#define SUBDEVICEREADYTIMEOUT 30 // seconds to wait until subdevice is ready
+
cPlugin *cDynamicDevice::dynamite = NULL;
int cDynamicDevice::defaultGetTSTimeout = 0;
int cDynamicDevice::idleTimeoutMinutes = 0;
@@ -281,9 +283,27 @@ eDynamicDeviceReturnCode cDynamicDevice::AttachDevice(const char *DevPath, int D
return ddrcNotSupported;
attach:
- dynamicdevice[freeIndex]->lastCloseDvr = time(NULL);
- while (!dynamicdevice[freeIndex]->Ready())
- cCondWait::SleepMs(2);
+ int retry = 3;
+ do {
+ dynamicdevice[freeIndex]->lastCloseDvr = time(NULL);
+ for (time_t t0 = time(NULL); time(NULL) - t0 < SUBDEVICEREADYTIMEOUT; ) {
+ if (dynamicdevice[freeIndex]->Ready()) {
+ retry = -1;
+ break;
+ }
+ cCondWait::SleepMs(100);
+ }
+ if (!dynamicdevice[freeIndex]->Ready() && dynamicdevice[freeIndex]->HasCi() && (retry > 0)) {
+ retry--;
+ isyslog("dynamite: device %s not ready after %d seconds - resetting CAMs (retry == %d)", DevPath, SUBDEVICEREADYTIMEOUT, retry);
+ for (cCamSlot* cs = CamSlots.First(); cs; cs = CamSlots.Next(cs)) {
+ if ((cs->Device() == dynamicdevice[freeIndex]) || (cs->Device() == NULL))
+ cs->Reset();
+ }
+ }
+ else
+ break;
+ } while (retry >= 0);
dynamicdevice[freeIndex]->devpath = new cString(DevPath);
isyslog("dynamite: attached device %s to dynamic device slot %d", DevPath, freeIndex + 1);
dynamicdevice[freeIndex]->ReadUdevProperties();
@@ -300,6 +320,7 @@ attach:
if (!WIFEXITED(status) || WEXITSTATUS(status))
esyslog("SystemExec() failed with status %d", status);
}
+ dynamicdevice[freeIndex]->subDeviceIsReady = true;
return ddrcSuccess;
}
@@ -538,6 +559,7 @@ bool cDynamicDevice::IsAttached(const char *DevPath)
cDynamicDevice::cDynamicDevice()
:index(-1)
+,subDeviceIsReady(false)
,devpath(NULL)
,udevRemoveSyspath(NULL)
,getTSTimeoutHandlerArg(NULL)
@@ -633,6 +655,7 @@ void cDynamicDevice::InternSetLock(bool Lock)
void cDynamicDevice::DeleteSubDevice()
{
+ subDeviceIsReady = false;
if (subDevice) {
Cancel(3);
if (cTransferControl::ReceiverDevice() == this)
@@ -1098,7 +1121,7 @@ void cDynamicDevice::CloseDvr(void)
bool cDynamicDevice::GetTSPacket(uchar *&Data)
{
- if (subDevice) {
+ if (subDeviceIsReady && subDevice) {
bool r = subDevice->GetTSPacket(Data);
if (getTSTimeout > 0) {
if (Data == NULL) {
diff --git a/dynamicdevice.h b/dynamicdevice.h
index 5a9017c..881a1ce 100644
--- a/dynamicdevice.h
+++ b/dynamicdevice.h
@@ -69,6 +69,7 @@ public:
static bool IsAttached(const char *DevPath);
private:
int index;
+ bool subDeviceIsReady;
cString *devpath;
cString *udevRemoveSyspath;
cString *getTSTimeoutHandlerArg;