diff --exclude='*.o' -urw /home/jburgess/dvb/vdr-1.3.23/PLUGINS/src/dxr3/dxr3demuxdevice.c dxr3/dxr3demuxdevice.c
--- /home/jburgess/dvb/vdr-1.3.23/PLUGINS/src/dxr3/dxr3demuxdevice.c	2005-04-19 19:19:37.000000000 +0100
+++ dxr3/dxr3demuxdevice.c	2005-05-17 22:36:39.000000000 +0100
@@ -396,6 +396,9 @@
 		    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();
@@ -422,6 +425,10 @@
 			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 -urw ref-/dxr3/dxr3outputthread.c dxr3/dxr3outputthread.c
--- ref-/dxr3/dxr3outputthread.c	2005-04-19 19:19:38.000000000 +0100
+++ dxr3/dxr3outputthread.c	2005-05-08 03:04:21.000000000 +0100
@@ -95,10 +95,12 @@
     sched_param temp;
     temp.sched_priority = 2;
 
+#if 0
     if (!pthread_setschedparam(pthread_self(), SCHED_RR, &temp))
     {
 	cLog::Instance() << "cDxr3AudioOutThread::Action(): Error can't set priority\n";
     }
+#endif
 
     while (!GetStopSignal())
     {
@@ -189,12 +191,12 @@
 
     sched_param temp;
     temp.sched_priority = 1;
-
+#if 0
     if (!pthread_setschedparam(pthread_self(), SCHED_RR, &temp))
     {
 	cLog::Instance() << "cDxr3VideoOutThread::Action(): Error can't set priority\n";
     }
-
+#endif
     while (!GetStopSignal())
     {
 	cFixedLengthFrame* pNext = m_buffer.Get();
diff -urw ref-/dxr3/dxr3syncbuffer.c dxr3/dxr3syncbuffer.c
--- ref-/dxr3/dxr3syncbuffer.c	2005-04-19 19:19:38.000000000 +0100
+++ dxr3/dxr3syncbuffer.c	2005-05-17 22:37:52.000000000 +0100
@@ -26,6 +26,7 @@
 */
 
 #include <unistd.h>
+#include <sys/time.h>
 #include "dxr3syncbuffer.h"
 #include "dxr3memcpy.h"
 
@@ -174,15 +175,17 @@
 }
 
 // ==================================
-const int BUFFER_LIMIT = 5;
-const int BUFFER_LIMIT_2 = 10;
+const int BUFFER_LIMIT = 5;    // 5
+const int BUFFER_LIMIT_2 = 10; // 10
 
 // ==================================
 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))
@@ -192,10 +195,20 @@
 		   ((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)
 	    {
@@ -211,6 +224,8 @@
 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)
     {
@@ -223,10 +238,21 @@
 
 	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;
+		//break;
+	    }
 	}
 
 #if VDRVERSNUM < 10313
