summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--HISTORY1
-rw-r--r--dxr3demuxdevice.c6
-rw-r--r--dxr3outputthread.c17
-rw-r--r--dxr3syncbuffer.c25
4 files changed, 32 insertions, 17 deletions
diff --git a/HISTORY b/HISTORY
index 8b09241..a6c8758 100644
--- a/HISTORY
+++ b/HISTORY
@@ -287,3 +287,4 @@ NOTE: I havent found time to include all of the languages, will be done in pre2
one (Ville Skyttä)
- clean up dead code for old VDR versions that hasn't worked for some time
anyway, VDR >= 1.3.11 is now required (Ville Skyttä)
+- improve recovery and avoid lockups caused by bad streams (Jon Burgess)
diff --git a/dxr3demuxdevice.c b/dxr3demuxdevice.c
index 6dc7292..6523768 100644
--- a/dxr3demuxdevice.c
+++ b/dxr3demuxdevice.c
@@ -388,6 +388,9 @@ int cDxr3DemuxDevice::DemuxPes(const uint8_t* buf, int length, bool bAc3Dts)
m_dxr3Device.SetVerticalSize(pesFrame.GetVerticalSize());
while (!Poll(100));
cFixedLengthFrame* pTempFrame = m_vBuf.Push(pesFrame.GetEsStart(), (int) (pesFrame.GetEsLength()), pts, ftVideo);
+ if (!pTempFrame) /* Push Timeout */
+ throw (cDxr3PesFrame::PES_GENERAL_ERROR);
+
pTempFrame->SetAspectRatio(pesFrame.GetAspectRatio());
m_aBuf.WakeUp();
@@ -414,6 +417,9 @@ int cDxr3DemuxDevice::DemuxPes(const uint8_t* buf, int length, bool bAc3Dts)
m_dxr3Device.SetHorizontalSize(pesFrame.GetHorizontalSize());
m_dxr3Device.SetVerticalSize(pesFrame.GetVerticalSize());
cFixedLengthFrame* pTempFrame = m_vBuf.Push(pesFrame.GetEsStart(), (int) (pesFrame.GetEsLength()), pts, ftVideo);
+ if (!pTempFrame) /* Push Timeout */
+ throw (cDxr3PesFrame::PES_GENERAL_ERROR);
+
pTempFrame->SetAspectRatio(pesFrame.GetAspectRatio());
if (m_synchState == DXR3_DEMUX_AUDIO_SYNCHED)
diff --git a/dxr3outputthread.c b/dxr3outputthread.c
index 2a6fc3b..8d6d311 100644
--- a/dxr3outputthread.c
+++ b/dxr3outputthread.c
@@ -22,7 +22,6 @@
#include <stdio.h>
#include <unistd.h>
#include <time.h>
-#include <pthread.h>
#include "dxr3outputthread.h"
#include "dxr3log.h"
@@ -90,14 +89,6 @@ void cDxr3AudioOutThread::Action()
cLog::Instance() << "cDxr3AudioOutThread::Action Thread started\n";
- sched_param temp;
- temp.sched_priority = 2;
-
- if (!pthread_setschedparam(pthread_self(), SCHED_RR, &temp))
- {
- cLog::Instance() << "cDxr3AudioOutThread::Action(): Error can't set priority\n";
- }
-
while (!GetStopSignal())
{
pts = 0;
@@ -183,14 +174,6 @@ void cDxr3VideoOutThread::Action()
cLog::Instance() << "cDxr3VideoOutThread::Action Thread started\n";
- sched_param temp;
- temp.sched_priority = 1;
-
- if (!pthread_setschedparam(pthread_self(), SCHED_RR, &temp))
- {
- cLog::Instance() << "cDxr3VideoOutThread::Action(): Error can't set priority\n";
- }
-
while (!GetStopSignal())
{
cFixedLengthFrame* pNext = m_buffer.Get();
diff --git a/dxr3syncbuffer.c b/dxr3syncbuffer.c
index 4569222..490f9b6 100644
--- a/dxr3syncbuffer.c
+++ b/dxr3syncbuffer.c
@@ -26,6 +26,7 @@
*/
#include <unistd.h>
+#include <sys/time.h>
#include "dxr3syncbuffer.h"
const int DXR3_MAX_VIDEO_FRAME_LENGTH = 4096;
@@ -181,7 +182,9 @@ bool cDxr3SyncBuffer::Poll(int TimeoutMs)
{
bool retVal = true;
uint32_t currTime = m_dxr3Device.GetSysClock();
+ struct timeval tv_start, tv;
m_bPollSync = true;
+ gettimeofday(&tv_start, NULL);
if (m_demuxMode == DXR3_DEMUX_REPLAY_MODE)
{
if (Available() >= Size() - (Size()*BUFFER_LIMIT/100))
@@ -191,10 +194,20 @@ bool cDxr3SyncBuffer::Poll(int TimeoutMs)
((m_dxr3Device.GetSysClock() - currTime) <
((uint32_t)TimeoutMs * (uint32_t)45)))
{
+ int d_s, d_us, ms;
m_bPutBlock = true;
EnableGet();
m_bWaitPts = false;
WaitForPut();
+ gettimeofday(&tv, NULL);
+ d_s = tv.tv_sec - tv_start.tv_sec;
+ d_us = tv.tv_usec - tv_start.tv_usec;
+ ms = d_s * 1000 + d_us / 1000;
+ if (ms > TimeoutMs * 2) {
+ cLog::Instance() << "Secondary timeout\n";
+ printf("Secondary timeout\n");
+ break;
+ }
}
if (Available() >= Size() - (Size()*BUFFER_LIMIT_2)/100)
{
@@ -210,6 +223,8 @@ bool cDxr3SyncBuffer::Poll(int TimeoutMs)
cFixedLengthFrame* cDxr3SyncBuffer::Push(const uint8_t* pStart, int length, uint32_t pts, eFrameType type) throw (eSyncBufferException)
{
int lastIndex = 0;
+ struct timeval tv_start, tv;
+ gettimeofday(&tv_start, NULL);
switch (m_demuxMode)
{
@@ -222,10 +237,20 @@ cFixedLengthFrame* cDxr3SyncBuffer::Push(const uint8_t* pStart, int length, uint
while ((Available() >= Size() - (Size()*10)/100))
{
+ int d_s, d_us, ms;
m_bPutBlock = true;
EnableGet();
m_bWaitPts = false;
WaitForPut();
+ gettimeofday(&tv, NULL);
+ d_s = tv.tv_sec - tv_start.tv_sec;
+ d_us = tv.tv_usec - tv_start.tv_usec;
+ ms = d_s * 1000 + d_us / 1000;
+ if (ms > 2000) {
+ cLog::Instance() << "Push timeout\n";
+ printf("Push timeout\n");
+ return NULL;
+ }
}
#if VDRVERSNUM < 10313