1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Improved tuner timeout handling

This commit is contained in:
Klaus Schmidinger 2006-01-03 10:42:47 +01:00
parent c01259dbb5
commit fb641c9149

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: dvbdevice.c 1.144 2006/01/01 12:03:31 kls Exp $ * $Id: dvbdevice.c 1.145 2006/01/03 10:42:47 kls Exp $
*/ */
#include "dvbdevice.h" #include "dvbdevice.h"
@ -40,12 +40,12 @@
#define DEV_DVB_AUDIO "audio" #define DEV_DVB_AUDIO "audio"
#define DEV_DVB_CA "ca" #define DEV_DVB_CA "ca"
#define DVBS_TUNE_TIMEOUT 1000 //ms #define DVBS_TUNE_TIMEOUT 2000 //ms
#define DVBS_LOCK_TIMEOUT 1000 //ms #define DVBS_LOCK_TIMEOUT 2000 //ms
#define DVBC_TUNE_TIMEOUT 1000 //ms #define DVBC_TUNE_TIMEOUT 5000 //ms
#define DVBC_LOCK_TIMEOUT 1000 //ms #define DVBC_LOCK_TIMEOUT 2000 //ms
#define DVBT_TUNE_TIMEOUT 1000 //ms #define DVBT_TUNE_TIMEOUT 9000 //ms
#define DVBT_LOCK_TIMEOUT 1000 //ms #define DVBT_LOCK_TIMEOUT 2000 //ms
class cDvbName { class cDvbName {
private: private:
@ -75,6 +75,7 @@ private:
int cardIndex; int cardIndex;
int tuneTimeout; int tuneTimeout;
int lockTimeout; int lockTimeout;
time_t lastTimeoutReport;
fe_type_t frontendType; fe_type_t frontendType;
cCiHandler *ciHandler; cCiHandler *ciHandler;
cChannel channel; cChannel channel;
@ -100,6 +101,9 @@ cDvbTuner::cDvbTuner(int Fd_Frontend, int CardIndex, fe_type_t FrontendType, cCi
cardIndex = CardIndex; cardIndex = CardIndex;
frontendType = FrontendType; frontendType = FrontendType;
ciHandler = CiHandler; ciHandler = CiHandler;
tuneTimeout = 0;
lockTimeout = 0;
lastTimeoutReport = 0;
diseqcCommands = NULL; diseqcCommands = NULL;
tunerStatus = tsIdle; tunerStatus = tsIdle;
if (frontendType == FE_QPSK) if (frontendType == FE_QPSK)
@ -127,6 +131,7 @@ void cDvbTuner::Set(const cChannel *Channel, bool Tune)
if (Tune) if (Tune)
tunerStatus = tsSet; tunerStatus = tsSet;
channel = *Channel; channel = *Channel;
lastTimeoutReport = 0;
newSet.Broadcast(); newSet.Broadcast();
} }
@ -299,7 +304,6 @@ void cDvbTuner::Action(void)
{ {
cTimeMs Timer; cTimeMs Timer;
bool LostLock = false; bool LostLock = false;
time_t LastTimeoutReport = 0;
dvb_frontend_event event; dvb_frontend_event event;
while (Running()) { while (Running()) {
bool hasEvent = GetFrontendEvent(event, 1); bool hasEvent = GetFrontendEvent(event, 1);
@ -318,9 +322,9 @@ void cDvbTuner::Action(void)
if (Timer.TimedOut()) { if (Timer.TimedOut()) {
tunerStatus = tsSet; tunerStatus = tsSet;
diseqcCommands = NULL; diseqcCommands = NULL;
if (time(NULL) - LastTimeoutReport > 60) { // let's not get too many of these if (time(NULL) - lastTimeoutReport > 60) { // let's not get too many of these
esyslog("ERROR: frontend %d timed out while tuning", cardIndex); esyslog("ERROR: frontend %d timed out while tuning", cardIndex);
LastTimeoutReport = time(NULL); lastTimeoutReport = time(NULL);
} }
continue; continue;
} }
@ -330,21 +334,23 @@ void cDvbTuner::Action(void)
tunerStatus = tsSet; tunerStatus = tsSet;
diseqcCommands = NULL; diseqcCommands = NULL;
esyslog("ERROR: frontend %d was reinitialized", cardIndex); esyslog("ERROR: frontend %d was reinitialized", cardIndex);
lastTimeoutReport = 0;
} }
else if (event.status & FE_HAS_LOCK) { else if (event.status & FE_HAS_LOCK) {
if (LostLock) { if (LostLock) {
esyslog("frontend %d regained lock", cardIndex); esyslog("frontend %d regained lock", cardIndex);
LostLock = false; LostLock = false;
LastTimeoutReport = 0;
} }
tunerStatus = tsLocked; tunerStatus = tsLocked;
locked.Broadcast(); locked.Broadcast();
lastTimeoutReport = 0;
} }
else if (tunerStatus == tsLocked) { else if (tunerStatus == tsLocked) {
LostLock = true; LostLock = true;
esyslog("ERROR: frontend %d lost lock", cardIndex); esyslog("ERROR: frontend %d lost lock", cardIndex);
tunerStatus = tsTuned; tunerStatus = tsTuned;
Timer.Set(lockTimeout); Timer.Set(lockTimeout);
lastTimeoutReport = 0;
} }
continue; continue;
} }