mirror of
https://github.com/rofafor/vdr-plugin-satip.git
synced 2023-10-10 13:37:42 +02:00
Tweaked tuner state machine.
This commit is contained in:
parent
8ec972d4ee
commit
ec596a02b8
31
tuner.c
31
tuner.c
@ -88,7 +88,7 @@ void cSatipTuner::Action(void)
|
|||||||
// Do the thread loop
|
// Do the thread loop
|
||||||
while (Running()) {
|
while (Running()) {
|
||||||
mutexM.Lock();
|
mutexM.Lock();
|
||||||
if (currentStateM != nextStateM)
|
if (StateRequested())
|
||||||
currentStateM = nextStateM;
|
currentStateM = nextStateM;
|
||||||
mutexM.Unlock();
|
mutexM.Unlock();
|
||||||
switch (currentStateM) {
|
switch (currentStateM) {
|
||||||
@ -98,19 +98,19 @@ void cSatipTuner::Action(void)
|
|||||||
case tsRelease:
|
case tsRelease:
|
||||||
//debug("cSatipTuner::%s(): tsRelease [device %d]", __FUNCTION__, deviceIdM);
|
//debug("cSatipTuner::%s(): tsRelease [device %d]", __FUNCTION__, deviceIdM);
|
||||||
Disconnect();
|
Disconnect();
|
||||||
nextStateM = tsIdle;
|
RequestState(tsIdle);
|
||||||
break;
|
break;
|
||||||
case tsSet:
|
case tsSet:
|
||||||
//debug("cSatipTuner::%s(): tsSet [device %d]", __FUNCTION__, deviceIdM);
|
//debug("cSatipTuner::%s(): tsSet [device %d]", __FUNCTION__, deviceIdM);
|
||||||
reConnectM.Set(eConnectTimeoutMs);
|
reConnectM.Set(eConnectTimeoutMs);
|
||||||
Disconnect();
|
Disconnect();
|
||||||
if (Connect()) {
|
if (Connect()) {
|
||||||
nextStateM = tsTuned;
|
RequestState(tsTuned);
|
||||||
UpdatePids(true);
|
UpdatePids(true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
error("Tuning failed - re-tuning [device %d]", deviceIdM);
|
error("Tuning failed - re-tuning [device %d]", deviceIdM);
|
||||||
nextStateM = tsIdle;
|
RequestState(tsIdle);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case tsTuned:
|
case tsTuned:
|
||||||
@ -125,7 +125,7 @@ void cSatipTuner::Action(void)
|
|||||||
signalQualityM = eDefaultSignalQuality;
|
signalQualityM = eDefaultSignalQuality;
|
||||||
}
|
}
|
||||||
if (hasLockM)
|
if (hasLockM)
|
||||||
nextStateM = tsLocked;
|
RequestState(tsLocked);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case tsLocked:
|
case tsLocked:
|
||||||
@ -150,7 +150,8 @@ void cSatipTuner::Action(void)
|
|||||||
error("Unknown tuner status %d [device %d]", currentStateM, deviceIdM);
|
error("Unknown tuner status %d [device %d]", currentStateM, deviceIdM);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sleepM.Wait(eSleepTimeoutMs); // to avoid busy loop and reduce cpu load
|
if (!StateRequested())
|
||||||
|
sleepM.Wait(eSleepTimeoutMs); // to avoid busy loop and reduce cpu load
|
||||||
}
|
}
|
||||||
debug("cSatipTuner::%s(): exiting [device %d]", __FUNCTION__, deviceIdM);
|
debug("cSatipTuner::%s(): exiting [device %d]", __FUNCTION__, deviceIdM);
|
||||||
}
|
}
|
||||||
@ -366,7 +367,7 @@ bool cSatipTuner::SetPid(int pidP, int typeP, bool onP)
|
|||||||
|
|
||||||
bool cSatipTuner::UpdatePids(bool forceP)
|
bool cSatipTuner::UpdatePids(bool forceP)
|
||||||
{
|
{
|
||||||
//debug("cSatipTuner::%s(%d) tunerStatus=%s [device %d]", __FUNCTION__, forceP, TunerStateString(currentStateM), deviceIdM);
|
//debug("cSatipTuner::%s(%d) tunerState=%s [device %d]", __FUNCTION__, forceP, TunerStateString(currentStateM), deviceIdM);
|
||||||
if (((forceP && pidsM.Size()) || (pidUpdateCacheM.TimedOut() && (addPidsM.Size() || delPidsM.Size()))) &&
|
if (((forceP && pidsM.Size()) || (pidUpdateCacheM.TimedOut() && (addPidsM.Size() || delPidsM.Size()))) &&
|
||||||
!isempty(*streamAddrM) && (streamIdM > 0)) {
|
!isempty(*streamAddrM) && (streamIdM > 0)) {
|
||||||
cString uri = cString::sprintf("rtsp://%s/stream=%d", *streamAddrM, streamIdM);
|
cString uri = cString::sprintf("rtsp://%s/stream=%d", *streamAddrM, streamIdM);
|
||||||
@ -403,7 +404,7 @@ bool cSatipTuner::UpdatePids(bool forceP)
|
|||||||
|
|
||||||
bool cSatipTuner::KeepAlive(bool forceP)
|
bool cSatipTuner::KeepAlive(bool forceP)
|
||||||
{
|
{
|
||||||
//debug("cSatipTuner::%s(%d) tunerStatus=%s [device %d]", __FUNCTION__, forceP, TunerStateString(currentStateM), deviceIdM);
|
//debug("cSatipTuner::%s(%d) tunerState=%s [device %d]", __FUNCTION__, forceP, TunerStateString(currentStateM), deviceIdM);
|
||||||
cMutexLock MutexLock(&mutexM);
|
cMutexLock MutexLock(&mutexM);
|
||||||
if (keepAliveM.TimedOut()) {
|
if (keepAliveM.TimedOut()) {
|
||||||
keepAliveM.Set(timeoutM);
|
keepAliveM.Set(timeoutM);
|
||||||
@ -420,7 +421,7 @@ bool cSatipTuner::KeepAlive(bool forceP)
|
|||||||
|
|
||||||
bool cSatipTuner::ReadReceptionStatus(bool forceP)
|
bool cSatipTuner::ReadReceptionStatus(bool forceP)
|
||||||
{
|
{
|
||||||
//debug("cSatipTuner::%s(%d) tunerStatus=%s [device %d]", __FUNCTION__, forceP, TunerStateString(currentStateM), deviceIdM);
|
//debug("cSatipTuner::%s(%d) tunerState=%s [device %d]", __FUNCTION__, forceP, TunerStateString(currentStateM), deviceIdM);
|
||||||
cMutexLock MutexLock(&mutexM);
|
cMutexLock MutexLock(&mutexM);
|
||||||
if (statusUpdateM.TimedOut()) {
|
if (statusUpdateM.TimedOut()) {
|
||||||
statusUpdateM.Set(eStatusUpdateTimeoutMs);
|
statusUpdateM.Set(eStatusUpdateTimeoutMs);
|
||||||
@ -435,14 +436,22 @@ bool cSatipTuner::ReadReceptionStatus(bool forceP)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool cSatipTuner::StateRequested(void)
|
||||||
|
{
|
||||||
|
cMutexLock MutexLock(&mutexM);
|
||||||
|
//debug("cSatipTuner::%s(%s <> %s) [device %d]", __FUNCTION__, TunerStateString(currentStateM), TunerStateString(nextStateM), deviceIdM);
|
||||||
|
|
||||||
|
return (currentStateM != nextStateM);
|
||||||
|
}
|
||||||
|
|
||||||
bool cSatipTuner::RequestState(eTunerState stateP)
|
bool cSatipTuner::RequestState(eTunerState stateP)
|
||||||
{
|
{
|
||||||
cMutexLock MutexLock(&mutexM);
|
cMutexLock MutexLock(&mutexM);
|
||||||
debug("cSatipTuner::%s(%d) [device %d]", __FUNCTION__, TunerStateString(stateP), deviceIdM);
|
debug("cSatipTuner::%s(%s) [device %d]", __FUNCTION__, TunerStateString(stateP), deviceIdM);
|
||||||
|
|
||||||
nextStateM = stateP;
|
nextStateM = stateP;
|
||||||
|
|
||||||
// return always true
|
// validate legal state changes
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1
tuner.h
1
tuner.h
@ -92,6 +92,7 @@ private:
|
|||||||
bool KeepAlive(bool forceP = false);
|
bool KeepAlive(bool forceP = false);
|
||||||
bool ReadReceptionStatus(bool forceP = false);
|
bool ReadReceptionStatus(bool forceP = false);
|
||||||
bool UpdatePids(bool forceP = false);
|
bool UpdatePids(bool forceP = false);
|
||||||
|
bool StateRequested(void);
|
||||||
bool RequestState(eTunerState stateP);
|
bool RequestState(eTunerState stateP);
|
||||||
const char *TunerStateString(eTunerState stateP);
|
const char *TunerStateString(eTunerState stateP);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user