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),
|
packetBufferLenM(packetLenP),
|
||||||
packetBufferM(NULL),
|
packetBufferM(NULL),
|
||||||
rtpSocketM(NULL),
|
rtpSocketM(NULL),
|
||||||
timeoutM(-1),
|
timeDataReceivedM(),
|
||||||
timeoutHandlerM(0),
|
|
||||||
timeoutFuncM(NULL),
|
|
||||||
timeoutParamM(NULL),
|
|
||||||
sleepM(),
|
sleepM(),
|
||||||
mutexM()
|
mutexM()
|
||||||
{
|
{
|
||||||
@ -78,23 +75,18 @@ void cSatipTunerDataThread::Start(cSatipSocket *rtpSocketP)
|
|||||||
cThread::Start();
|
cThread::Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void cSatipTunerDataThread::SetTimeout(int timeoutP, fCallback callbackP, void *paramP)
|
int cSatipTunerDataThread::LastReceivedMs()
|
||||||
{
|
{
|
||||||
log2(logFunc, "(%d, ...)", timeoutP);
|
int rc = timeDataReceivedM.Elapsed();
|
||||||
cMutexLock MutexLock(&mutexM);
|
|
||||||
|
|
||||||
if (timeoutP > 0) {
|
log2(logFunc, "returning %d", rc);
|
||||||
timeoutM = timeoutP;
|
|
||||||
timeoutFuncM = callbackP;
|
|
||||||
timeoutParamM = paramP;
|
|
||||||
timeoutHandlerM.Set(timeoutM);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
timeoutM = -1;
|
|
||||||
timeoutFuncM = NULL;
|
|
||||||
timeoutParamM = NULL;
|
|
||||||
timeoutHandlerM.Set(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cSatipTunerDataThread::ResetLastReceivedMs()
|
||||||
|
{
|
||||||
|
log(logFunc);
|
||||||
|
|
||||||
|
timeDataReceivedM.Set();
|
||||||
}
|
}
|
||||||
|
|
||||||
void cSatipTunerDataThread::Cancel(int WaitSeconds)
|
void cSatipTunerDataThread::Cancel(int WaitSeconds)
|
||||||
@ -140,13 +132,7 @@ void cSatipTunerDataThread::Action(void)
|
|||||||
if (statisticsM)
|
if (statisticsM)
|
||||||
statisticsM->AddTunerStatistic(length);
|
statisticsM->AddTunerStatistic(length);
|
||||||
|
|
||||||
timeoutHandlerM.Set(timeoutM);
|
timeDataReceivedM.Set();
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mutexM.Unlock();
|
mutexM.Unlock();
|
||||||
|
11
data.h
11
data.h
@ -29,7 +29,11 @@ public:
|
|||||||
cSatipTunerDataThread(cSatipDeviceIf &deviceP, cSatipTunerStatistics &statisticsP, unsigned int packetLenP);
|
cSatipTunerDataThread(cSatipDeviceIf &deviceP, cSatipTunerStatistics &statisticsP, unsigned int packetLenP);
|
||||||
~cSatipTunerDataThread(void);
|
~cSatipTunerDataThread(void);
|
||||||
void Start(cSatipSocket *rtpSocketP);
|
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 Cancel(int WaitSeconds = 0);
|
||||||
void Flush();
|
void Flush();
|
||||||
|
|
||||||
@ -44,10 +48,7 @@ private:
|
|||||||
unsigned int packetBufferLenM;
|
unsigned int packetBufferLenM;
|
||||||
unsigned char *packetBufferM;
|
unsigned char *packetBufferM;
|
||||||
cSatipSocket *rtpSocketM;
|
cSatipSocket *rtpSocketM;
|
||||||
int timeoutM;
|
cTimeMs timeDataReceivedM;
|
||||||
cTimeMs timeoutHandlerM;
|
|
||||||
fCallback timeoutFuncM;
|
|
||||||
void *timeoutParamM;
|
|
||||||
cCondWait sleepM;
|
cCondWait sleepM;
|
||||||
cMutex mutexM;
|
cMutex mutexM;
|
||||||
};
|
};
|
||||||
|
11
tuner.c
11
tuner.c
@ -133,6 +133,15 @@ void cSatipTuner::Action(void)
|
|||||||
if (rtcpTimeout.TimedOut())
|
if (rtcpTimeout.TimedOut())
|
||||||
reconnectM = true;
|
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
|
sleepM.Wait(10); // to avoid busy loop and reduce cpu load
|
||||||
}
|
}
|
||||||
@ -376,11 +385,9 @@ bool cSatipTuner::UpdatePids(bool forceP)
|
|||||||
*GeneratePidParameter(forceP));
|
*GeneratePidParameter(forceP));
|
||||||
|
|
||||||
// Disable RTP Timeout while sending PLAY Command
|
// Disable RTP Timeout while sending PLAY Command
|
||||||
dataThreadM.SetTimeout(-1, &DataTimeoutCallback, this);
|
|
||||||
if (RtspPlay(*uri)) {
|
if (RtspPlay(*uri)) {
|
||||||
addPidsM.Clear();
|
addPidsM.Clear();
|
||||||
delPidsM.Clear();
|
delPidsM.Clear();
|
||||||
dataThreadM.SetTimeout(eReConnectTimeoutMs, &DataTimeoutCallback, this);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Disconnect();
|
Disconnect();
|
||||||
|
2
tuner.h
2
tuner.h
@ -57,8 +57,6 @@ private:
|
|||||||
eMinKeepAliveIntervalMs = 30000 // in milliseconds
|
eMinKeepAliveIntervalMs = 30000 // in milliseconds
|
||||||
};
|
};
|
||||||
|
|
||||||
static void DataTimeoutCallback(void *objP);
|
|
||||||
|
|
||||||
cSatipTunerDataThread dataThreadM;
|
cSatipTunerDataThread dataThreadM;
|
||||||
cCondWait sleepM;
|
cCondWait sleepM;
|
||||||
cSatipDeviceIf* deviceM;
|
cSatipDeviceIf* deviceM;
|
||||||
|
Loading…
Reference in New Issue
Block a user