1
0
mirror of https://github.com/rofafor/vdr-plugin-satip.git synced 2023-10-10 13:37:42 +02:00

Added a double check for the idle release.

This commit is contained in:
Rolf Ahrenberg 2015-05-23 15:28:37 +03:00
parent 6384b8694e
commit 4e2535a7e2
2 changed files with 11 additions and 8 deletions

16
tuner.c
View File

@ -29,7 +29,6 @@ cSatipTuner::cSatipTuner(cSatipDeviceIf &deviceP, unsigned int packetLenP)
nextServerM(NULL, deviceP.GetId(), 0), nextServerM(NULL, deviceP.GetId(), 0),
mutexM(), mutexM(),
reConnectM(), reConnectM(),
idleReleaseM(),
keepAliveM(), keepAliveM(),
statusUpdateM(), statusUpdateM(),
pidUpdateCacheM(), pidUpdateCacheM(),
@ -92,8 +91,10 @@ cSatipTuner::~cSatipTuner()
void cSatipTuner::Action(void) void cSatipTuner::Action(void)
{ {
debug1("%s Entering [device %d]", __PRETTY_FUNCTION__, deviceIdM); debug1("%s Entering [device %d]", __PRETTY_FUNCTION__, deviceIdM);
bool lastIdleStatus = false;
cTimeMs idleCheck(eIdleCheckTimeoutMs);
reConnectM.Set(eConnectTimeoutMs); reConnectM.Set(eConnectTimeoutMs);
idleReleaseM.Set(eIdleTimeoutMs);
// Do the thread loop // Do the thread loop
while (Running()) { while (Running()) {
UpdateCurrentState(); UpdateCurrentState();
@ -118,7 +119,8 @@ void cSatipTuner::Action(void)
case tsTuned: case tsTuned:
debug4("%s: tsTuned [device %d]", __PRETTY_FUNCTION__, deviceIdM); debug4("%s: tsTuned [device %d]", __PRETTY_FUNCTION__, deviceIdM);
reConnectM.Set(eConnectTimeoutMs); reConnectM.Set(eConnectTimeoutMs);
idleReleaseM.Set(eIdleTimeoutMs); idleCheck.Set(eIdleCheckTimeoutMs);
lastIdleStatus = false;
// Read reception statistics via DESCRIBE and RTCP // Read reception statistics via DESCRIBE and RTCP
if (hasLockM || ReadReceptionStatus()) { if (hasLockM || ReadReceptionStatus()) {
// Quirk for devices without valid reception data // Quirk for devices without valid reception data
@ -148,12 +150,14 @@ void cSatipTuner::Action(void)
RequestState(tsSet, smInternal); RequestState(tsSet, smInternal);
break; break;
} }
if (idleReleaseM.TimedOut()) { if (idleCheck.TimedOut()) {
idleReleaseM.Set(eIdleTimeoutMs); bool currentIdleStatus = deviceM->IsIdle();
if (deviceM->IsIdle()) { if (lastIdleStatus && currentIdleStatus) {
info("Idle timeout - releasing [device %d]", deviceIdM); info("Idle timeout - releasing [device %d]", deviceIdM);
RequestState(tsRelease, smInternal); RequestState(tsRelease, smInternal);
} }
lastIdleStatus = currentIdleStatus;
idleCheck.Set(eIdleCheckTimeoutMs);
break; break;
} }
break; break;

View File

@ -83,7 +83,7 @@ private:
eStatusUpdateTimeoutMs = 1000, // in milliseconds eStatusUpdateTimeoutMs = 1000, // in milliseconds
ePidUpdateIntervalMs = 250, // in milliseconds ePidUpdateIntervalMs = 250, // in milliseconds
eConnectTimeoutMs = 5000, // in milliseconds eConnectTimeoutMs = 5000, // in milliseconds
eIdleTimeoutMs = 30000, // in milliseconds eIdleCheckTimeoutMs = 15000, // in milliseconds
eMinKeepAliveIntervalMs = 30000 // in milliseconds eMinKeepAliveIntervalMs = 30000 // in milliseconds
}; };
enum eTunerState { tsIdle, tsRelease, tsSet, tsTuned, tsLocked }; enum eTunerState { tsIdle, tsRelease, tsSet, tsTuned, tsLocked };
@ -101,7 +101,6 @@ private:
cSatipTunerServer nextServerM; cSatipTunerServer nextServerM;
cMutex mutexM; cMutex mutexM;
cTimeMs reConnectM; cTimeMs reConnectM;
cTimeMs idleReleaseM;
cTimeMs keepAliveM; cTimeMs keepAliveM;
cTimeMs statusUpdateM; cTimeMs statusUpdateM;
cTimeMs pidUpdateCacheM; cTimeMs pidUpdateCacheM;