summaryrefslogtreecommitdiff
path: root/dxr3outputthread.c
diff options
context:
space:
mode:
Diffstat (limited to 'dxr3outputthread.c')
-rw-r--r--dxr3outputthread.c269
1 files changed, 139 insertions, 130 deletions
diff --git a/dxr3outputthread.c b/dxr3outputthread.c
index ba7e7bb..34fc79c 100644
--- a/dxr3outputthread.c
+++ b/dxr3outputthread.c
@@ -26,21 +26,26 @@
#include "dxr3outputthread.h"
#include "dxr3log.h"
-// ==================================
+// ==================================
const int AUDIO_OFFSET = 4500;
#define SCR m_dxr3Device.GetSysClock()
-// ==================================
+// ==================================
-// ==================================
+// ==================================
//! constructor
-cDxr3OutputThread::cDxr3OutputThread(cDxr3Interface& dxr3Device, cDxr3SyncBuffer& buffer) :
-cThread(), m_dxr3Device(dxr3Device), m_buffer(buffer), m_bStopThread(false), m_bNeedResync(false)
+cDxr3OutputThread::cDxr3OutputThread(cDxr3Interface& dxr3Device,
+ cDxr3SyncBuffer& buffer) :
+ cThread(),
+ m_dxr3Device(dxr3Device),
+ m_buffer(buffer),
+ m_bStopThread(false),
+ m_bNeedResync(false)
{
}
-// ==================================
+// ==================================
//! send stop signal
-void cDxr3OutputThread::SetStopSignal()
+void cDxr3OutputThread::SetStopSignal()
{
Lock();
m_bStopThread = true;
@@ -49,7 +54,7 @@ void cDxr3OutputThread::SetStopSignal()
// ==================================
//! was stop signal send?
-bool cDxr3OutputThread::GetStopSignal()
+bool cDxr3OutputThread::GetStopSignal()
{
bool ret = false;
Lock();
@@ -61,8 +66,9 @@ bool cDxr3OutputThread::GetStopSignal()
// ==================================
//! constr.
-cDxr3AudioOutThread::cDxr3AudioOutThread(cDxr3Interface& dxr3Device, cDxr3SyncBuffer& buffer) :
-cDxr3OutputThread(dxr3Device, buffer)
+cDxr3AudioOutThread::cDxr3AudioOutThread(cDxr3Interface& dxr3Device,
+ cDxr3SyncBuffer& buffer) :
+ cDxr3OutputThread(dxr3Device, buffer)
{
#if VDRVERSNUM >= 10300
SetDescription("DXR3 audio output");
@@ -79,83 +85,85 @@ cDxr3AudioOutThread::~cDxr3AudioOutThread()
// ==================================
//! thread action
-void cDxr3AudioOutThread::Action()
-{
+void cDxr3AudioOutThread::Action()
+{
bool resync = false;
uint32_t pts = 0;
-
+
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";
- }
+ if (!pthread_setschedparam(pthread_self(), SCHED_RR, &temp))
+ {
+ cLog::Instance() << "cDxr3AudioOutThread::Action(): Error can't set priority\n";
+ }
- while (!GetStopSignal())
+ while (!GetStopSignal())
+ {
+ pts = 0;
+ cFixedLengthFrame* pNext = m_buffer.Get();
+
+ if (pNext) pts = pNext->GetPts();
+
+ if (pts && abs((int)pts-(int)SCR) > 30000 ||
+ m_dxr3Device.IsExternalReleased())
{
- pts = 0;
- cFixedLengthFrame* pNext = m_buffer.Get();
+ m_buffer.Clear();
+ m_bNeedResync = true;
+ }
+ else if (pNext)
+ {
+ if (!pts || pts < SCR)
+ {
+ if (!pts && resync)
+ {
+ continue;
+ }
+ else
+ {
+ resync = false;
+ }
- if (pNext) pts = pNext->GetPts();
-
- if (pts && abs((int)pts-(int)SCR) > 30000 || m_dxr3Device.IsExternalReleased())
+ if (pts && (pts < SCR) && ((SCR - pts) > 5000))
{
- m_buffer.Clear();
- m_bNeedResync = true;
- }
- else if (pNext)
+ m_dxr3Device.SetSysClock(pts + 1 * AUDIO_OFFSET);
+ m_dxr3Device.PlayAudioFrame(pNext);
+ if (m_buffer.IsPolled())
+ {
+ m_buffer.Clear();
+ m_bNeedResync = true;
+ }
+ }
+ else
{
- if (!pts || pts < SCR)
- {
- if (!pts && resync)
- {
- continue;
- }
- else
- {
- resync = false;
- }
-
- if (pts && (pts < SCR) && ((SCR - pts) > 5000))
- {
- m_dxr3Device.SetSysClock(pts+ 1 * AUDIO_OFFSET);
- m_dxr3Device.PlayAudioFrame(pNext);
- if (m_buffer.IsPolled())
- {
- m_buffer.Clear();
- m_bNeedResync = true;
- }
- }
- else
- {
- m_dxr3Device.PlayAudioFrame(pNext);
- m_buffer.Pop();
- }
- }
- else
- {
- if (abs((int)pts - (int)SCR) < (AUDIO_OFFSET ))
- {
- m_dxr3Device.PlayAudioFrame(pNext);
- m_buffer.Pop();
- }
- }
- }
-
- if ((pts > SCR && abs((int)pts - (int)SCR) > AUDIO_OFFSET))
+ m_dxr3Device.PlayAudioFrame(pNext);
+ m_buffer.Pop();
+ }
+ }
+ else
+ {
+ if (abs((int)pts - (int)SCR) < (AUDIO_OFFSET ))
{
- usleep(10000);
- }
+ m_dxr3Device.PlayAudioFrame(pNext);
+ m_buffer.Pop();
+ }
+ }
+ }
+
+ if ((pts > SCR && abs((int)pts - (int)SCR) > AUDIO_OFFSET))
+ {
+ usleep(10000);
+ }
}
}
// ==================================
//! constr.
-cDxr3VideoOutThread::cDxr3VideoOutThread(cDxr3Interface& dxr3Device, cDxr3SyncBuffer& buffer) :
-cDxr3OutputThread(dxr3Device, buffer)
+cDxr3VideoOutThread::cDxr3VideoOutThread(cDxr3Interface& dxr3Device,
+ cDxr3SyncBuffer& buffer) :
+ cDxr3OutputThread(dxr3Device, buffer)
{
#if VDRVERSNUM >= 10300
SetDescription("DXR3 video output");
@@ -172,80 +180,81 @@ cDxr3VideoOutThread::~cDxr3VideoOutThread()
// ==================================
//! thread action
-void cDxr3VideoOutThread::Action()
+void cDxr3VideoOutThread::Action()
{
uint32_t pts = 0;
static uint32_t lastPts = 0;
-
- cLog::Instance() << "cDxr3VideoOutThread::Action Thread started\n";
+
+ 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";
- }
+ if (!pthread_setschedparam(pthread_self(), SCHED_RR, &temp))
+ {
+ cLog::Instance() << "cDxr3VideoOutThread::Action(): Error can't set priority\n";
+ }
- while (!GetStopSignal())
+ while (!GetStopSignal())
+ {
+ cFixedLengthFrame* pNext = m_buffer.Get();
+ if (pNext)
{
- cFixedLengthFrame* pNext = m_buffer.Get();
- if (pNext)
+ pts = pNext->GetPts();
+ if (pts == lastPts)
+ pts = 0;
+
+ if (pts > SCR && abs((int)pts - (int)SCR) < 7500)
+ {
+ m_dxr3Device.SetPts(pts);
+ }
+
+ if (!pts || pts < SCR)
+ {
+ if (m_buffer.Available())
{
- pts = pNext->GetPts();
- if (pts == lastPts) pts = 0;
-
- if (pts > SCR && abs((int)pts - (int)SCR) < 7500)
- {
- m_dxr3Device.SetPts(pts);
- }
-
- if (!pts || pts < SCR)
- {
- if (m_buffer.Available())
- {
- m_dxr3Device.PlayVideoFrame(pNext);
- m_buffer.Pop();
- }
- }
- else
- {
- if ((pts > SCR) && abs((int)pts - (int)SCR) < 7500)
- {
- m_dxr3Device.SetPts(pts);
-
- if (m_buffer.Available() && pNext->GetData() && pNext->GetCount())
- {
- m_dxr3Device.PlayVideoFrame(pNext);
- m_buffer.Pop();
- }
- }
- else
- {
- if (pts < SCR)
- {
- m_dxr3Device.PlayVideoFrame(pNext);
- m_buffer.Pop();
- }
- }
- }
-
-
- if (m_dxr3Device.IsExternalReleased())
- {
- m_bNeedResync = true;
- m_buffer.Clear();
- }
-
- if ((pts > SCR && abs((int)pts - (int)SCR) > 7500 ))
- {
- usleep(10000);
- }
- }
+ m_dxr3Device.PlayVideoFrame(pNext);
+ m_buffer.Pop();
+ }
+ }
+ else
+ {
+ if ((pts > SCR) && abs((int)pts - (int)SCR) < 7500)
+ {
+ m_dxr3Device.SetPts(pts);
+
+ if (m_buffer.Available() && pNext->GetData() &&
+ pNext->GetCount())
+ {
+ m_dxr3Device.PlayVideoFrame(pNext);
+ m_buffer.Pop();
+ }
+ }
+ else
+ {
+ if (pts < SCR)
+ {
+ m_dxr3Device.PlayVideoFrame(pNext);
+ m_buffer.Pop();
+ }
+ }
+ }
+
+
+ if (m_dxr3Device.IsExternalReleased())
+ {
+ m_bNeedResync = true;
+ m_buffer.Clear();
+ }
+
+ if ((pts > SCR && abs((int)pts - (int)SCR) > 7500 ))
+ {
+ usleep(10000);
+ }
+ }
}
}
-
#undef SCR
// Local variables: