diff --git a/HISTORY b/HISTORY index 381c04b..63c60da 100644 --- a/HISTORY +++ b/HISTORY @@ -137,3 +137,7 @@ VDR Plugin 'satip' Revision History interface. - Added new ATTA and DETA SVDRP commands. - Set the default device count to two. + +2015-xx-xx: Version 2.2.3 + +- Added a timeout for releasing idling devices. diff --git a/device.c b/device.c index 1535c3f..31ed352 100644 --- a/device.c +++ b/device.c @@ -460,6 +460,11 @@ int cSatipDevice::GetCISlot(void) return slot; } +bool cSatipDevice::IsIdle(void) +{ + return !Receiving(); +} + uchar *cSatipDevice::GetData(int *availableP) { debug16("%s [device %u]", __PRETTY_FUNCTION__, deviceIndexM); diff --git a/device.h b/device.h index bfb7a08..a86029e 100644 --- a/device.h +++ b/device.h @@ -110,6 +110,7 @@ public: virtual int GetId(void); virtual int GetPmtPid(void); virtual int GetCISlot(void); + virtual bool IsIdle(void); }; #endif // __SATIP_DEVICE_H diff --git a/deviceif.h b/deviceif.h index 719f4c2..a6f7c8a 100644 --- a/deviceif.h +++ b/deviceif.h @@ -16,6 +16,7 @@ public: virtual int GetId(void) = 0; virtual int GetPmtPid(void) = 0; virtual int GetCISlot(void) = 0; + virtual bool IsIdle(void) = 0; private: cSatipDeviceIf(const cSatipDeviceIf&); diff --git a/satip.c b/satip.c index 21d08ae..3453c48 100644 --- a/satip.c +++ b/satip.c @@ -27,7 +27,7 @@ #define GITVERSION "" #endif - const char VERSION[] = "2.2.2" GITVERSION; + const char VERSION[] = "2.2.3" GITVERSION; static const char DESCRIPTION[] = trNOOP("SAT>IP Devices"); class cPluginSatip : public cPlugin { diff --git a/tuner.c b/tuner.c index 07be861..a8ed8d5 100644 --- a/tuner.c +++ b/tuner.c @@ -29,6 +29,7 @@ cSatipTuner::cSatipTuner(cSatipDeviceIf &deviceP, unsigned int packetLenP) nextServerM(NULL, deviceP.GetId(), 0), mutexM(), reConnectM(), + idleReleaseM(), keepAliveM(), statusUpdateM(), pidUpdateCacheM(), @@ -92,6 +93,7 @@ void cSatipTuner::Action(void) { debug1("%s Entering [device %d]", __PRETTY_FUNCTION__, deviceIdM); reConnectM.Set(eConnectTimeoutMs); + idleReleaseM.Set(eIdleTimeoutMs); // Do the thread loop while (Running()) { UpdateCurrentState(); @@ -116,6 +118,7 @@ void cSatipTuner::Action(void) case tsTuned: debug4("%s: tsTuned [device %d]", __PRETTY_FUNCTION__, deviceIdM); reConnectM.Set(eConnectTimeoutMs); + idleReleaseM.Set(eIdleTimeoutMs); // Read reception statistics via DESCRIBE and RTCP if (hasLockM || ReadReceptionStatus()) { // Quirk for devices without valid reception data @@ -145,6 +148,14 @@ void cSatipTuner::Action(void) RequestState(tsSet, smInternal); break; } + if (idleReleaseM.TimedOut()) { + idleReleaseM.Set(eIdleTimeoutMs); + if (deviceM->IsIdle()) { + info("Idle timeout - releasing [device %d]", deviceIdM); + RequestState(tsRelease, smInternal); + } + break; + } break; default: error("Unknown tuner status %d [device %d]", currentStateM, deviceIdM); diff --git a/tuner.h b/tuner.h index 8ef0beb..c7395f0 100644 --- a/tuner.h +++ b/tuner.h @@ -83,6 +83,7 @@ private: eStatusUpdateTimeoutMs = 1000, // in milliseconds ePidUpdateIntervalMs = 250, // in milliseconds eConnectTimeoutMs = 5000, // in milliseconds + eIdleTimeoutMs = 30000, // in milliseconds eMinKeepAliveIntervalMs = 30000 // in milliseconds }; enum eTunerState { tsIdle, tsRelease, tsSet, tsTuned, tsLocked }; @@ -100,6 +101,7 @@ private: cSatipTunerServer nextServerM; cMutex mutexM; cTimeMs reConnectM; + cTimeMs idleReleaseM; cTimeMs keepAliveM; cTimeMs statusUpdateM; cTimeMs pidUpdateCacheM;