mirror of
https://github.com/rofafor/vdr-plugin-satip.git
synced 2023-10-10 13:37:42 +02:00
parent
4bee8b5345
commit
fbf43d4d49
36
data.c
36
data.c
@ -40,10 +40,7 @@ cSatipTunerDataThread::cSatipTunerDataThread(cSatipDeviceIf &deviceP, cSatipTune
|
||||
packetBufferLenM(packetLenP),
|
||||
packetBufferM(NULL),
|
||||
rtpSocketM(NULL),
|
||||
timeoutM(-1),
|
||||
timeoutHandlerM(0),
|
||||
timeoutFuncM(NULL),
|
||||
timeoutParamM(NULL),
|
||||
timeDataReceivedM(),
|
||||
sleepM(),
|
||||
mutexM()
|
||||
{
|
||||
@ -78,23 +75,18 @@ void cSatipTunerDataThread::Start(cSatipSocket *rtpSocketP)
|
||||
cThread::Start();
|
||||
}
|
||||
|
||||
void cSatipTunerDataThread::SetTimeout(int timeoutP, fCallback callbackP, void *paramP)
|
||||
int cSatipTunerDataThread::LastReceivedMs()
|
||||
{
|
||||
log2(logFunc, "(%d, ...)", timeoutP);
|
||||
cMutexLock MutexLock(&mutexM);
|
||||
int rc = timeDataReceivedM.Elapsed();
|
||||
|
||||
if (timeoutP > 0) {
|
||||
timeoutM = timeoutP;
|
||||
timeoutFuncM = callbackP;
|
||||
timeoutParamM = paramP;
|
||||
timeoutHandlerM.Set(timeoutM);
|
||||
}
|
||||
else {
|
||||
timeoutM = -1;
|
||||
timeoutFuncM = NULL;
|
||||
timeoutParamM = NULL;
|
||||
timeoutHandlerM.Set(0);
|
||||
log2(logFunc, "returning %d", rc);
|
||||
}
|
||||
|
||||
void cSatipTunerDataThread::ResetLastReceivedMs()
|
||||
{
|
||||
log(logFunc);
|
||||
|
||||
timeDataReceivedM.Set();
|
||||
}
|
||||
|
||||
void cSatipTunerDataThread::Cancel(int WaitSeconds)
|
||||
@ -140,13 +132,7 @@ void cSatipTunerDataThread::Action(void)
|
||||
if (statisticsM)
|
||||
statisticsM->AddTunerStatistic(length);
|
||||
|
||||
timeoutHandlerM.Set(timeoutM);
|
||||
}
|
||||
|
||||
if (timeoutM > 0 && timeoutFuncM && timeoutHandlerM.TimedOut()) {
|
||||
error("No Data received for %d ms [device %d], timeout handling started", timeoutM, deviceM->GetId());
|
||||
(*timeoutFuncM)(timeoutParamM);
|
||||
timeoutHandlerM.Set(timeoutM);
|
||||
timeDataReceivedM.Set();
|
||||
}
|
||||
|
||||
mutexM.Unlock();
|
||||
|
11
data.h
11
data.h
@ -29,7 +29,11 @@ public:
|
||||
cSatipTunerDataThread(cSatipDeviceIf &deviceP, cSatipTunerStatistics &statisticsP, unsigned int packetLenP);
|
||||
~cSatipTunerDataThread(void);
|
||||
void Start(cSatipSocket *rtpSocketP);
|
||||
void SetTimeout(int timeoutP, fCallback callbackP, void *parmP);
|
||||
|
||||
|
||||
// returns number of milliseconds since last time we received Data
|
||||
int LastReceivedMs();
|
||||
void ResetLastReceivedMs();
|
||||
void Cancel(int WaitSeconds = 0);
|
||||
void Flush();
|
||||
|
||||
@ -44,10 +48,7 @@ private:
|
||||
unsigned int packetBufferLenM;
|
||||
unsigned char *packetBufferM;
|
||||
cSatipSocket *rtpSocketM;
|
||||
int timeoutM;
|
||||
cTimeMs timeoutHandlerM;
|
||||
fCallback timeoutFuncM;
|
||||
void *timeoutParamM;
|
||||
cTimeMs timeDataReceivedM;
|
||||
cCondWait sleepM;
|
||||
cMutex mutexM;
|
||||
};
|
||||
|
11
tuner.c
11
tuner.c
@ -133,6 +133,15 @@ void cSatipTuner::Action(void)
|
||||
if (rtcpTimeout.TimedOut())
|
||||
reconnectM = true;
|
||||
|
||||
int passedMs = dataThreadM.LastReceivedMs();
|
||||
if (passedMs >= eReConnectTimeoutMs) {
|
||||
error("No Data received for %d ms [device %d], Reconnect initiated",
|
||||
(int)passedMs, deviceM->GetId());
|
||||
dataThreadM.ResetLastReceivedMs();
|
||||
reconnectM = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
sleepM.Wait(10); // to avoid busy loop and reduce cpu load
|
||||
}
|
||||
@ -376,11 +385,9 @@ bool cSatipTuner::UpdatePids(bool forceP)
|
||||
*GeneratePidParameter(forceP));
|
||||
|
||||
// Disable RTP Timeout while sending PLAY Command
|
||||
dataThreadM.SetTimeout(-1, &DataTimeoutCallback, this);
|
||||
if (RtspPlay(*uri)) {
|
||||
addPidsM.Clear();
|
||||
delPidsM.Clear();
|
||||
dataThreadM.SetTimeout(eReConnectTimeoutMs, &DataTimeoutCallback, this);
|
||||
return true;
|
||||
}
|
||||
Disconnect();
|
||||
|
Loading…
Reference in New Issue
Block a user