summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile6
-rw-r--r--dxr3audiodecoder.c3
-rw-r--r--dxr3audiodecoder.h6
-rw-r--r--dxr3demuxdevice.c416
-rw-r--r--dxr3demuxdevice.h82
-rw-r--r--dxr3device.c31
-rw-r--r--dxr3device.h2
-rw-r--r--dxr3generaldefines.h55
-rw-r--r--dxr3interface.c31
-rw-r--r--dxr3interface.h2
-rw-r--r--dxr3output-audio.c138
-rw-r--r--dxr3output-video.c104
-rw-r--r--dxr3output.c41
-rw-r--r--dxr3output.h85
-rw-r--r--dxr3pesframe.c9
-rw-r--r--dxr3syncbuffer.c294
-rw-r--r--dxr3syncbuffer.h130
17 files changed, 15 insertions, 1420 deletions
diff --git a/Makefile b/Makefile
index 220b85a..c05f4b6 100644
--- a/Makefile
+++ b/Makefile
@@ -67,10 +67,10 @@ DEFINES += -DMICROCODE=\"/lib/firmware/em8300.bin\"
### The object files (add further files here):
OBJS = $(PLUGIN).o dxr3multichannelaudio.o \
- dxr3syncbuffer.o dxr3audiodecoder.o dxr3blackframe.o dxr3audio.o \
- dxr3pesframe.o dxr3demuxdevice.o settings.o \
+ dxr3audiodecoder.o dxr3blackframe.o dxr3audio.o \
+ dxr3pesframe.o settings.o \
dxr3interface.o dxr3device.o \
- dxr3output.o dxr3output-video.o dxr3output-audio.o dxr3osd.o dxr3spudecoder.o \
+ dxr3osd.o dxr3spudecoder.o \
dxr3audio-oss.o dxr3audio-alsa.o spuencoder.o spuregion.o scaler.o
### Default target:
diff --git a/dxr3audiodecoder.c b/dxr3audiodecoder.c
index e1bc0be..6ad774e 100644
--- a/dxr3audiodecoder.c
+++ b/dxr3audiodecoder.c
@@ -86,6 +86,7 @@ void cDxr3AudioDecoder::Init()
}
}
+#if 0
// ==================================
//! decode given buffer
void cDxr3AudioDecoder::Decode(cDxr3PesFrame *frame, uint32_t pts, cDxr3SyncBuffer &aBuf)
@@ -227,7 +228,7 @@ void cDxr3AudioDecoder::DecodeAc3Dts(cDxr3PesFrame *frame, uint32_t pts, cDxr3Sy
}
}
}
-
+#endif
// ==================================
//! checking routine
bool cDxr3AudioDecoder::checkMpegAudioHdr(const uint8_t *head)
diff --git a/dxr3audiodecoder.h b/dxr3audiodecoder.h
index 62eb806..b4d004b 100644
--- a/dxr3audiodecoder.h
+++ b/dxr3audiodecoder.h
@@ -28,7 +28,7 @@ extern "C" {
# include <libavformat/avformat.h>
}
-#include "dxr3syncbuffer.h"
+#include <vdr/ringbuffer.h>
#include "dxr3multichannelaudio.h"
#include "uncopyable.h"
@@ -40,11 +40,11 @@ class cDxr3AudioDecoder : private Uncopyable {
public:
cDxr3AudioDecoder();
~cDxr3AudioDecoder();
-
+/*
void Decode(cDxr3PesFrame *frame, uint32_t pts, cDxr3SyncBuffer &aBuf);
void DecodeLpcm(cDxr3PesFrame *frame, uint32_t pts, cDxr3SyncBuffer &aBuf);
void DecodeAc3Dts(cDxr3PesFrame *frame, uint32_t pts, cDxr3SyncBuffer &aBuf);
-
+*/
void Reset()
{
ac3dtsDecoder.Clear();
diff --git a/dxr3demuxdevice.c b/dxr3demuxdevice.c
deleted file mode 100644
index 0814488..0000000
--- a/dxr3demuxdevice.c
+++ /dev/null
@@ -1,416 +0,0 @@
-/*
- * dxr3demuxdevice.c
- *
- * Copyright (C) 2002-2004 Kai Möller
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#include "dxr3demuxdevice.h"
-#include "dxr3pesframe.h"
-
-// ==================================
-//! constructor
-cDxr3DemuxDevice::cDxr3DemuxDevice() :
- aBuf(AUDIO_MAX_BUFFER_SIZE, AUIDO_MAX_FRAME_SIZE),
- vBuf(VIDEO_MAX_BUFFER_SIZE, VIDEO_MAX_FRAME_SIZE)
-{
- synchState = DXR3_DEMUX_UNSYNCHED;
- demuxMode = DXR3_DEMUX_OFF_MODE;
- audioThread = new cDxr3AudioOutThread(aBuf);
- if (!audioThread) {
- esyslog("dxr3: fatal: unable to allocate memory for audio thread");
- exit(1);
- }
-
- videoThread = new cDxr3VideoOutThread(vBuf);
- if (!videoThread) {
- esyslog("dxr3: fatal: unable to allocate memory for video thread");
- exit(1);
- }
- videoThread->Start();
-}
-
-void cDxr3DemuxDevice::setAudio(iAudio *audio)
-{
- audioThread->setAudio(audio);
- audioThread->Start();
-}
-
-// ==================================
-// deconstr.
-cDxr3DemuxDevice::~cDxr3DemuxDevice()
-{
- delete videoThread;
- delete audioThread;
-}
-
-// ==================================
-// stop demuxing process
-void cDxr3DemuxDevice::Stop()
-{
- cDxr3Interface::instance()->DisableVideo();
- audioThread->audio()->setEnabled(false);
- vBuf.Clear();
- aBuf.Clear();
- vBuf.WakeUp();
- aBuf.WakeUp();
- vBuf.WaitForReceiverStopped();
- aBuf.WaitForReceiverStopped();
- synchState = DXR3_DEMUX_UNSYNCHED;
- demuxMode = DXR3_DEMUX_OFF_MODE;
-
- cDxr3Interface::instance()->PlayBlackFrame();
-}
-
-// ==================================
-void cDxr3DemuxDevice::Resync()
-{
- cDxr3Interface::instance()->DisableVideo();
- audioThread->audio()->setEnabled(false);
- vBuf.Clear();
- aBuf.Clear();
- vBuf.WakeUp();
- aBuf.WakeUp();
- vBuf.WaitForReceiverStopped();
- aBuf.WaitForReceiverStopped();
- synchState = DXR3_DEMUX_UNSYNCHED;
- demuxMode = DXR3_DEMUX_OFF_MODE;
-}
-
-// ==================================
-void cDxr3DemuxDevice::Clear()
-{
- cDxr3Interface::instance()->DisableVideo();
- audioThread->audio()->setEnabled(false);
- vBuf.Clear();
- aBuf.Clear();
- vBuf.WakeUp();
- aBuf.WakeUp();
- vBuf.WaitForReceiverStopped();
- aBuf.WaitForReceiverStopped();
- synchState = DXR3_DEMUX_UNSYNCHED;
- demuxMode = DXR3_DEMUX_OFF_MODE;
-}
-
-// ==================================
-void cDxr3DemuxDevice::SetReplayMode()
-{
- if (demuxMode != DXR3_DEMUX_REPLAY_MODE)
- {
- if (demuxMode == DXR3_DEMUX_TRICK_MODE && trickState == DXR3_FREEZE) {
- cDxr3Interface::instance()->SetPlayMode();
- cDxr3Interface::instance()->SetSysClock(stopScr);
- cDxr3Interface::instance()->EnableVideo();
- audioThread->audio()->setEnabled(true);
- vBuf.Start();
- aBuf.Start();
- vBuf.WakeUp();
- aBuf.WakeUp();
- } else {
- synchState = DXR3_DEMUX_UNSYNCHED;
- aBuf.SetDemuxMode(DXR3_DEMUX_REPLAY_MODE);
- vBuf.SetDemuxMode(DXR3_DEMUX_REPLAY_MODE);
- }
- }
- demuxMode = DXR3_DEMUX_REPLAY_MODE;
-}
-
-// ==================================
-void cDxr3DemuxDevice::SetTrickMode(eDxr3TrickState trickState, int Speed)
-{
- demuxMode = DXR3_DEMUX_TRICK_MODE;
- trickState = trickState;
- audioThread->audio()->setEnabled(false);
-
- if (demuxMode == DXR3_DEMUX_TRICK_MODE && trickState == DXR3_FREEZE) {
- stopScr = cDxr3Interface::instance()->GetSysClock();
- // cDxr3Interface::instance()->Pause();
- vBuf.Stop();
- aBuf.Stop();
- } else {
- vBuf.Clear();
- aBuf.Clear();
- }
-}
-
-// ==================================
-void cDxr3DemuxDevice::StillPicture()
-{
- vBuf.Clear();
- aBuf.Clear();
- demuxMode = DXR3_DEMUX_TRICK_MODE;
- trickState = DXR3_FREEZE;
-}
-
-// ==================================
-int cDxr3DemuxDevice::DemuxPes(const uint8_t* buf, int length, bool bAc3Dts)
-{
- uint32_t pts = 0;
- static uint32_t aPts = 0;
- static uint32_t vPts = 0;
- static uint32_t lastPts = 0;
- static bool bPlaySuc = false;
- static bool bPlayedFrame = false;
-
- int scr = 0;
- int pcr = 0;
-
- scr = cDxr3Interface::instance()->GetSysClock();
-
- if (audioThread->NeedResync() || videoThread->NeedResync()) {
- Resync();
- if (demuxMode == DXR3_DEMUX_REPLAY_MODE) {
- SetReplayMode();
- }
- aBuf.Clear();
- vBuf.Clear();
- audioThread->ClearResyncRequest();
- videoThread->ClearResyncRequest();
- aDecoder.Reset();
- lastPts = 0;
- aPts = 0;
- vPts = 0;
- bPlaySuc = false;
- }
-
- if (demuxMode == DXR3_DEMUX_OFF_MODE) {
- demuxMode = DXR3_DEMUX_TV_MODE;
- synchState = DXR3_DEMUX_UNSYNCHED;
-
- lastPts = 0;
- aPts = 0;
- vPts = 0;
- bPlaySuc = false;
- }
-
- cDxr3PesFrame *pesFrame = new cDxr3PesFrame();
-
- if (!pesFrame || !pesFrame->parse(buf, length)) {
- return -1;
- }
-
- if (pesFrame->GetPts() != lastPts) {
- pts = lastPts = pesFrame->GetPts();
- } else {
- pts = 0;
- }
-
- if (demuxMode != DXR3_DEMUX_VIDEO_ONLY_MODE) {
-
- if (pesFrame->GetPesDataType() != cDxr3PesFrame::PES_VIDEO_DATA) {
-
- if (synchState == DXR3_DEMUX_AUDIO_SYNCHED || synchState == DXR3_DEMUX_SYNCHED) {
- if (pts && synchState != DXR3_DEMUX_SYNCHED) {
- synchState = DXR3_DEMUX_SYNCHED;
- pcr = aPts - PRE_BUFFER_LENGTH;
- cDxr3Interface::instance()->SetSysClock(pcr);
- cDxr3Interface::instance()->SetPlayMode();
- cDxr3Interface::instance()->EnableVideo();
- audioThread->audio()->setEnabled(true);
- vBuf.Start();
- aBuf.Start();
- }
- while(!Poll(100)) {}
-
- if (pesFrame->GetPesDataType() == cDxr3PesFrame::PES_PRIVATE_DATA) {
- if (bAc3Dts) {
- aDecoder.DecodeAc3Dts(pesFrame, pts, aBuf);
- } else {
- aDecoder.DecodeLpcm(pesFrame, pts, aBuf);
- }
- }
- aDecoder.Decode(pesFrame, pts, aBuf);
-
- } else {
- if (pts) {
- aPts = pts;
-
- if (pesFrame->GetPesDataType() == cDxr3PesFrame::PES_PRIVATE_DATA) {
- if (bAc3Dts) {
- aDecoder.DecodeAc3Dts(pesFrame, pts, aBuf);
- } else {
- aDecoder.DecodeLpcm(pesFrame, pts, aBuf);
- }
- }
- aDecoder.Decode(pesFrame, pts, aBuf);
-
- if (synchState == DXR3_DEMUX_VIDEO_SYNCHED) {
- synchState = DXR3_DEMUX_SYNCHED;
- } else {
- synchState = DXR3_DEMUX_AUDIO_SYNCHED;
- }
- if (synchState == DXR3_DEMUX_SYNCHED) {
- if (!vPts) {
- vPts = aPts;
- }
- if (aPts < vPts) {
- pcr = aPts - PRE_BUFFER_LENGTH;
- } else {
- pcr = vPts - PRE_BUFFER_LENGTH;
- }
- cDxr3Interface::instance()->SetSysClock(pcr);
- cDxr3Interface::instance()->SetPlayMode();
- cDxr3Interface::instance()->EnableVideo();
- audioThread->audio()->setEnabled(true);
- vBuf.Start();
- aBuf.Start();
- }
- }
- }
- } else {
-
- if (demuxMode == DXR3_DEMUX_TRICK_MODE) {
- switch (pesFrame->GetFrameType()) {
- case I_FRAME:
- dsyslog("dxr3: demux: I-frame");
- bPlaySuc = true;
- //if (bPlayedFrame) return length;
- bPlayedFrame = true;
- cDxr3Interface::instance()->setDimension(pesFrame->GetHorizontalSize(), pesFrame->GetVerticalSize());
- cDxr3Interface::instance()->PlayVideoFrame(pesFrame);
- break;
-
- case UNKNOWN_FRAME:
- dsyslog("dxr3: demux: unknown frame");
- if (bPlaySuc) {
- cDxr3Interface::instance()->PlayVideoFrame(pesFrame);
- }
- break;
-
- default:
- dsyslog("dxr3: demux: default frame");
- if (bPlaySuc) {
- cDxr3Interface::instance()->PlayVideoFrame(pesFrame);
- }
-
- bPlaySuc = false;
- break;
- }
-
- } else if (synchState == DXR3_DEMUX_VIDEO_SYNCHED || synchState == DXR3_DEMUX_SYNCHED) {
- cDxr3Interface::instance()->setDimension(pesFrame->GetHorizontalSize(), pesFrame->GetVerticalSize());
- while (!Poll(100)) {}
- cFixedLengthFrame* pTempFrame = vBuf.Push(pesFrame->GetPayload(), (int) (pesFrame->GetPayloadLength()), pts);
-
- // TODO: rework me
- //if (!pTempFrame) /* Push Timeout */
- // throw (cDxr3PesFrame::PES_GENERAL_ERROR);
-
- pTempFrame->aspectratio(pesFrame->GetAspectRatio());
-
- aBuf.WakeUp();
-
- if (vBuf.GetFillLevel() > 5 && synchState != DXR3_DEMUX_SYNCHED) {
- synchState = DXR3_DEMUX_SYNCHED;
- pcr = vPts - PRE_BUFFER_LENGTH;
- cDxr3Interface::instance()->SetSysClock(pcr);
- cDxr3Interface::instance()->SetPlayMode();
- cDxr3Interface::instance()->EnableVideo();
- audioThread->audio()->setEnabled(true);
- vBuf.Start();
- aBuf.Start();
- }
- } else {
- if (pesFrame->GetFrameType() == I_FRAME) {
- vPts = pts;
-
- cDxr3Interface::instance()->setDimension(pesFrame->GetHorizontalSize(), pesFrame->GetVerticalSize());
- cFixedLengthFrame* pTempFrame = vBuf.Push(pesFrame->GetPayload(), (int) (pesFrame->GetPayloadLength()), pts);
- // TODO: rework me
- //if (!pTempFrame) /* Push Timeout */
- // throw (cDxr3PesFrame::PES_GENERAL_ERROR);
-
- pTempFrame->aspectratio(pesFrame->GetAspectRatio());
-
- if (synchState == DXR3_DEMUX_AUDIO_SYNCHED) {
- synchState = DXR3_DEMUX_SYNCHED;
- } else {
- synchState = DXR3_DEMUX_VIDEO_SYNCHED;
- }
- if (synchState == DXR3_DEMUX_SYNCHED) {
- if (!vPts) {
- vPts = aPts;
- }
- if (aPts < vPts) {
- pcr = aPts - PRE_BUFFER_LENGTH;
- } else {
- pcr = vPts - PRE_BUFFER_LENGTH;
- }
- cDxr3Interface::instance()->SetSysClock(pcr);
- cDxr3Interface::instance()->SetPlayMode();
- cDxr3Interface::instance()->EnableVideo();
- audioThread->audio()->setEnabled(true);
- vBuf.Start();
- aBuf.Start();
- }
- }
- }
-
- }
- } else if (demuxMode == DXR3_DEMUX_VIDEO_ONLY_MODE) {
- cDxr3Interface::instance()->PlayVideoFrame(pesFrame);
- }
-
- delete pesFrame;
- return length;
-}
-
-// ==================================
-int cDxr3DemuxDevice::DemuxAudioPes(const uint8_t* buf, int length)
-{
- static int syncCounter = 0;
-
- demuxMode = DXR3_DEMUX_AUDIO_ONLY_MODE;
- aBuf.SetDemuxMode(DXR3_DEMUX_REPLAY_MODE);
- vBuf.SetDemuxMode(DXR3_DEMUX_REPLAY_MODE);
-
- cDxr3PesFrame *pesFrame = new cDxr3PesFrame();
-
- if (!pesFrame || !pesFrame->parse(buf, length)) {
- return -1;
- }
-
- if (pesFrame->GetPesDataType() == cDxr3PesFrame::PES_PRIVATE_DATA) {
- if (synchState != DXR3_DEMUX_AUDIO_SYNCHED &&
- syncCounter > 2) {
- synchState = DXR3_DEMUX_AUDIO_SYNCHED;
- cDxr3Interface::instance()->SetPlayMode();
- cDxr3Interface::instance()->EnableVideo();
- audioThread->audio()->setEnabled(true);
- vBuf.Start();
- aBuf.Start();
- }
- if (synchState != DXR3_DEMUX_AUDIO_SYNCHED &&
- syncCounter <= 2) {
- syncCounter++;
- }
- while (!aBuf.Poll(100)) {}
- aDecoder.DecodeLpcm(pesFrame, 0, aBuf);
- }
-
- delete pesFrame;
-
- return length;
-}
-
-// Local variables:
-// mode: c++
-// c-file-style: "stroustrup"
-// c-file-offsets: ((inline-open . 0))
-// tab-width: 4;
-// indent-tabs-mode: nil
-// End:
diff --git a/dxr3demuxdevice.h b/dxr3demuxdevice.h
deleted file mode 100644
index 2f38260..0000000
--- a/dxr3demuxdevice.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * dxr3demuxdevice.h
- *
- * Copyright (C) 2002-2004 Kai Möller
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#ifndef __DXR3_DEMUX_DEVICE_H
-#define __DXR3_DEMUX_DEVICE_H
-
-#include "dxr3generaldefines.h"
-#include "dxr3syncbuffer.h"
-#include "dxr3output.h"
-
-const int AUDIO_MAX_BUFFER_SIZE = 200;
-const int VIDEO_MAX_BUFFER_SIZE = 500;
-
-const int AUIDO_MAX_FRAME_SIZE = 5000;
-const int VIDEO_MAX_FRAME_SIZE = 3000;
-const uint32_t PRE_BUFFER_LENGTH = 0;
-
-// ==================================
-// extract video and audio
-class cDxr3DemuxDevice : private Uncopyable {
-public:
- cDxr3DemuxDevice();
- ~cDxr3DemuxDevice();
-
- void setAudio(iAudio *audio);
-
- void Stop();
- void Resync();
- void Clear();
- void SetReplayMode();
- void SetTrickMode(eDxr3TrickState trickState, int Speed = 1);
-
- int DemuxPes(const uint8_t* buf, int length, bool bAc3Dts);
- int DemuxAudioPes(const uint8_t* buf, int length);
- void StillPicture();
-
- eDxr3DemuxMode GetDemuxMode() { return demuxMode; }
- eDxr3TrickState GetTrickState() { return trickState; };
-
- bool Poll(int TimeoutMs) {
- return aBuf.Poll(TimeoutMs) && vBuf.Poll(TimeoutMs);
- };
-
-private:
- cDxr3SyncBuffer aBuf;
- cDxr3SyncBuffer vBuf;
- eDxr3DemuxSynchState synchState;
- eDxr3DemuxMode demuxMode;
- eDxr3TrickState trickState;
- cDxr3AudioDecoder aDecoder;
- cDxr3AudioOutThread* audioThread;
- cDxr3VideoOutThread* videoThread;
- uint32_t stopScr;
-};
-
-#endif // __DXR3_DEMUX_DEVICE_H
-
-// Local variables:
-// mode: c++
-// c-file-style: "stroustrup"
-// c-file-offsets: ((inline-open . 0))
-// tab-width: 4;
-// indent-tabs-mode: nil
-// End:
diff --git a/dxr3device.c b/dxr3device.c
index 8bfdd90..dbc16c5 100644
--- a/dxr3device.c
+++ b/dxr3device.c
@@ -40,8 +40,6 @@ cDxr3Device::cDxr3Device() : pluginOn(true)
audioOut = new cAudioOss();
//audioOut = new cAudioAlsa();
audioOut->openDevice();
-
- m_DemuxDevice.setAudio(audioOut);
}
// ==================================
@@ -99,7 +97,6 @@ bool cDxr3Device::SetPlayMode(ePlayMode PlayMode)
break;
case pmNone:
- //m_DemuxDevice.Stop();
break;
case pmAudioVideo:
@@ -123,15 +120,12 @@ int64_t cDxr3Device::GetSTC()
void cDxr3Device::TrickSpeed(int Speed)
{
dsyslog("dxr3: device: tricspeed: %d", Speed);
-
- m_DemuxDevice.SetTrickMode(DXR3_FAST, Speed);
}
// ==================================
//! clear our demux buffer
void cDxr3Device::Clear()
{
- m_DemuxDevice.Clear();
cDevice::Clear();
}
@@ -139,14 +133,12 @@ void cDxr3Device::Clear()
//! play a recording
void cDxr3Device::Play()
{
- m_DemuxDevice.SetReplayMode();
}
// ==================================
//! puts the device into "freeze frame" mode
void cDxr3Device::Freeze()
{
- m_DemuxDevice.SetTrickMode(DXR3_FREEZE);
}
// ==================================
@@ -161,7 +153,6 @@ void cDxr3Device::Mute()
void cDxr3Device::StillPicture(const uchar *Data, int Length)
{
// clear used buffers of output threads
- m_DemuxDevice.StillPicture();
// we need to check if Data points to a pes
// frame or to non-pes data. This could be the
@@ -179,40 +170,29 @@ void cDxr3Device::StillPicture(const uchar *Data, int Length)
// ==================================
bool cDxr3Device::Poll(cPoller &Poller, int TimeoutMs)
{
+ /*
if ((m_DemuxDevice.GetDemuxMode() == DXR3_DEMUX_TRICK_MODE &&
m_DemuxDevice.GetTrickState() == DXR3_FREEZE)) {
cCondWait::SleepMs(TimeoutMs);
return false;
}
return m_DemuxDevice.Poll(TimeoutMs); // Poller.Poll(TimeoutMs);
+ */
+ return true;
}
// ==================================
//! actually plays the given data block as video
int cDxr3Device::PlayVideo(const uchar *Data, int Length)
{
- if (!pluginOn) {
- return Length;
- }
-
- return m_DemuxDevice.DemuxPes(Data, Length, false);
+ return Length;
}
// ==================================
// plays additional audio streams, like Dolby Digital
int cDxr3Device::PlayAudio(const uchar *Data, int Length, uchar Id)
{
- if (!pluginOn) {
- return Length;
- }
-
- bool isAc3 = ((Id & 0xF0) == 0x80) || Id == 0xbd;
-
- if (m_PlayMode == pmAudioOnly) {
- return m_DemuxDevice.DemuxAudioPes(Data, Length);
- } else {
- return m_DemuxDevice.DemuxPes(Data, Length, isAc3);
- }
+ return Length;
}
#if VDRVERSNUM >= 10710
@@ -304,7 +284,6 @@ void cDxr3Device::turnPlugin(bool on)
}
// clear buffer
- m_DemuxDevice.Clear();
// release device and give control to somebody else
Tools::WriteInfoToOsd(tr("DXR3: releasing devices"));
diff --git a/dxr3device.h b/dxr3device.h
index 6a775ad..9fcacb7 100644
--- a/dxr3device.h
+++ b/dxr3device.h
@@ -27,7 +27,6 @@
#include <vdr/device.h>
#include "dxr3interface.h"
-#include "dxr3demuxdevice.h"
#include "dxr3spudecoder.h"
#include "dxr3audio.h"
@@ -85,7 +84,6 @@ public:
private:
ePlayMode m_PlayMode;
- cDxr3DemuxDevice m_DemuxDevice;
cDxr3SpuDecoder* m_spuDecoder;
iAudio *audioOut;
bool pluginOn;
diff --git a/dxr3generaldefines.h b/dxr3generaldefines.h
deleted file mode 100644
index a06c2c3..0000000
--- a/dxr3generaldefines.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * dxr3generaldefines.h
- *
- * Copyright (C) 2002-2004 Kai Möller
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#ifndef __DXR3_GENERAL_DEFINES_H
-#define __DXR3_GENERAL_DEFINES_H
-
-enum eDxr3DemuxSynchState {
- DXR3_DEMUX_AUDIO_SYNCHED,
- DXR3_DEMUX_VIDEO_SYNCHED,
- DXR3_DEMUX_SYNCHED,
- DXR3_DEMUX_UNSYNCHED
-};
-
-enum eDxr3DemuxMode {
- DXR3_DEMUX_TV_MODE,
- DXR3_DEMUX_REPLAY_MODE,
- DXR3_DEMUX_AUDIO_ONLY_MODE,
- DXR3_DEMUX_VIDEO_ONLY_MODE,
- DXR3_DEMUX_TRICK_MODE,
- DXR3_DEMUX_OFF_MODE
-};
-
-enum eDxr3TrickState {
- DXR3_FAST,
- DXR3_SLOW,
- DXR3_FREEZE
-};
-
-#endif // __DXR3_GENERAL_DEFINES_H
-
-// Local variables:
-// mode: c++
-// c-file-style: "stroustrup"
-// c-file-offsets: ((inline-open . 0))
-// tab-width: 4;
-// indent-tabs-mode: nil
-// End:
diff --git a/dxr3interface.c b/dxr3interface.c
index 0625029..1c1a392 100644
--- a/dxr3interface.c
+++ b/dxr3interface.c
@@ -22,7 +22,6 @@
*/
#include "dxr3interface.h"
-#include "dxr3syncbuffer.h"
#include "dxr3osd.h"
#include "dxr3pesframe.h"
@@ -31,6 +30,8 @@ static const char *DEV_DXR3_VIDEO = "_mv";
static const char *DEV_DXR3_OSS = "_ma";
static const char *DEV_DXR3_CONT = "";
+static const int UNKNOWN_ASPECT_RATIO = 0xdeadbeef;
+
// ==================================
//! constructor
cDxr3Interface::cDxr3Interface() :
@@ -274,34 +275,6 @@ void cDxr3Interface::Pause()
}
// ==================================
-void cDxr3Interface::PlayVideoFrame(cFixedLengthFrame* pFrame)
-{
- if (!m_VideoActive) {
- return;
- }
-
- int written = 0;
- int count = 0;
-
- Lock();
-
- while (written < pFrame->length() && count >= 0) {
- if ((count = write(m_fdVideo, pFrame->GetData() + written, pFrame->length() - written)) == -1) {
- // an error occured
- Resuscitation();
- }
- written += count;
- }
-
- Unlock();
-
- SetAspectRatio(pFrame->aspectratio());
- uint32_t pts = pFrame->pts();
- if (pts > 0)
- m_lastSeenPts = pts;
-}
-
-// ==================================
void cDxr3Interface::PlayVideoFrame(cDxr3PesFrame *frame)
{
if (!m_VideoActive) {
diff --git a/dxr3interface.h b/dxr3interface.h
index 96d551a..101fd40 100644
--- a/dxr3interface.h
+++ b/dxr3interface.h
@@ -31,7 +31,6 @@
#include "settings.h"
// ==================================
-class cFixedLengthFrame;
class cDxr3PesFrame;
class cDxr3Name {
@@ -100,7 +99,6 @@ public:
// play functions
void SetPlayMode();
void Pause();
- void PlayVideoFrame(cFixedLengthFrame* pFrame);
void PlayVideoFrame(cDxr3PesFrame *frame);
// device access
diff --git a/dxr3output-audio.c b/dxr3output-audio.c
deleted file mode 100644
index 25f40c1..0000000
--- a/dxr3output-audio.c
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * dxr3output-audio.c
- *
- * Copyright (C) 2002-2004 Kai Möller
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#include <stdio.h>
-#include <time.h>
-#include "dxr3output.h"
-#include "dxr3audio.h"
-#include "dxr3pesframe.h"
-
-// ==================================
-const int AUDIO_OFFSET = 4500;
-#define SCR m_dxr3Device->GetSysClock()
-// ==================================
-
-// ==================================
-//! constr.
-cDxr3AudioOutThread::cDxr3AudioOutThread(cDxr3SyncBuffer& buffer) :
- cDxr3OutputThread(buffer)
-{
- SetDescription("DXR3 audio output");
-}
-
-// ==================================
-//! thread action
-void cDxr3AudioOutThread::Action()
-{
- bool resync = false;
- uint32_t pts = 0;
-
- while (Running())
- {
- pts = 0;
- cFixedLengthFrame* pNext = m_buffer.Get();
-
- if (pNext) pts = pNext->pts();
-
- if ((pts && abs((int)pts-(int)SCR) > 30000))
- {
- m_buffer.Clear();
- m_bNeedResync = true;
- }
- else if (pNext)
- {
- 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);
- PlayFrame(pNext);
- if (m_buffer.IsPolled())
- {
- m_buffer.Clear();
- m_bNeedResync = true;
- }
- }
- else
- {
- PlayFrame(pNext);
- m_buffer.Pop();
- }
- }
- else
- {
- if (abs((int)pts - (int)SCR) < (AUDIO_OFFSET ))
- {
- PlayFrame(pNext);
- m_buffer.Pop();
- }
- }
- }
-
- if ((pts > SCR && abs((int)pts - (int)SCR) > AUDIO_OFFSET))
- {
- cCondWait::SleepMs(10);
- }
- }
-}
-
-void cDxr3AudioOutThread::PlayFrame(cFixedLengthFrame *frame)
-{
- // only call setup and manipulate the volume for analog audio
- if (!audioOutput->isDigitalAudio()) {
-
- // update audio context
- SampleContext ctx;
- ctx.samplerate = frame->samplerate();
- ctx.channels = frame->channels();
-
- // TODO find cause why we need this workaround
- if (ctx.samplerate != -1 && ctx.channels != -1) {
- audioOutput->setup(ctx);
- } else {
- dsyslog("[fixme] samplerate: %d channels: %d", ctx.samplerate, ctx.channels);
- }
-
- // volume changes
- audioOutput->changeVolume((short *)frame->GetData(), (size_t)frame->length());
- }
-
- audioOutput->write(frame->GetData(), frame->length());
-}
-
-#undef SCR
-
-// Local variables:
-// mode: c++
-// c-file-style: "stroustrup"
-// c-file-offsets: ((inline-open . 0))
-// tab-width: 4;
-// indent-tabs-mode: nil
-// End:
diff --git a/dxr3output-video.c b/dxr3output-video.c
deleted file mode 100644
index 4773853..0000000
--- a/dxr3output-video.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * dxr3output-video.c
- *
- * Copyright (C) 2002-2004 Kai Möller
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#include <stdio.h>
-#include <time.h>
-#include "dxr3output.h"
-
-#define SCR m_dxr3Device->GetSysClock()
-
-// ==================================
-//! constr.
-cDxr3VideoOutThread::cDxr3VideoOutThread(cDxr3SyncBuffer& buffer) :
- cDxr3OutputThread(buffer)
-{
- SetDescription("DXR3 video output");
-}
-
-// ==================================
-//! thread action
-void cDxr3VideoOutThread::Action()
-{
- uint32_t pts = 0;
- static uint32_t lastPts = 0;
-
- while (Running())
- {
- cFixedLengthFrame* pNext = m_buffer.Get();
- if (pNext)
- {
- pts = pNext->pts();
- 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->length())
- {
- m_dxr3Device->PlayVideoFrame(pNext);
- m_buffer.Pop();
- }
- }
- else
- {
- if (pts < SCR)
- {
- m_dxr3Device->PlayVideoFrame(pNext);
- m_buffer.Pop();
- }
- }
- }
-
- if ((pts > SCR && abs((int)pts - (int)SCR) > 7500 ))
- {
- cCondWait::SleepMs(10);
- }
- }
- }
-}
-
-#undef SCR
-
-// Local variables:
-// mode: c++
-// c-file-style: "stroustrup"
-// c-file-offsets: ((inline-open . 0))
-// tab-width: 4;
-// indent-tabs-mode: nil
-// End:
diff --git a/dxr3output.c b/dxr3output.c
deleted file mode 100644
index dc56251..0000000
--- a/dxr3output.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * dxr3output.c
- *
- * Copyright (C) 2002-2004 Kai Möller
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#include <time.h>
-#include "dxr3output.h"
-
-// ==================================
-//! constructor
-cDxr3OutputThread::cDxr3OutputThread(cDxr3SyncBuffer& buffer) :
- cThread(),
- m_dxr3Device(cDxr3Interface::instance()),
- m_buffer(buffer),
- m_bNeedResync(false)
-{
-}
-
-// Local variables:
-// mode: c++
-// c-file-style: "stroustrup"
-// c-file-offsets: ((inline-open . 0))
-// tab-width: 4;
-// indent-tabs-mode: nil
-// End:
diff --git a/dxr3output.h b/dxr3output.h
deleted file mode 100644
index abd21c6..0000000
--- a/dxr3output.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * dxr3output.h
- *
- * Copyright (C) 2002-2004 Kai Möller
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#ifndef _DXR3OUTPUTTHREAD_H_
-#define _DXR3OUTPUTTHREAD_H_
-
-#include "dxr3syncbuffer.h"
-#include "dxr3audiodecoder.h"
-#include "uncopyable.h"
-
-class iAudio;
-
-// ==================================
-class cDxr3OutputThread : public cThread, private Uncopyable {
-public:
- cDxr3OutputThread(cDxr3SyncBuffer& buffer);
- virtual ~cDxr3OutputThread() {
- m_buffer.Stop();
- Cancel(3);
- };
-
- bool NeedResync() const { return m_bNeedResync; }
- void ClearResyncRequest() { m_bNeedResync = false; }
-
-protected:
- virtual void Action() = 0;
-
- cDxr3Interface *m_dxr3Device;
- cDxr3SyncBuffer& m_buffer;
- bool m_bNeedResync;
-};
-
-// ==================================
-class cDxr3AudioOutThread : public cDxr3OutputThread {
-public:
- cDxr3AudioOutThread(cDxr3SyncBuffer& buffer);
-
- void setAudio(iAudio *a) { audioOutput = a; }
- iAudio *audio() { return audioOutput; }
-
-protected:
- void Action();
-
-private:
- iAudio *audioOutput;
-
- void PlayFrame(cFixedLengthFrame *frame);
-};
-
-// ==================================
-class cDxr3VideoOutThread : public cDxr3OutputThread {
-public:
- cDxr3VideoOutThread(cDxr3SyncBuffer& buffer);
-
-protected:
- void Action();
-};
-
-#endif /*_DXR3OUTPUTTHREAD_H_*/
-
-// Local variables:
-// mode: c++
-// c-file-style: "stroustrup"
-// c-file-offsets: ((inline-open . 0))
-// tab-width: 4;
-// indent-tabs-mode: nil
-// End:
diff --git a/dxr3pesframe.c b/dxr3pesframe.c
index 817c51c..c0731da 100644
--- a/dxr3pesframe.c
+++ b/dxr3pesframe.c
@@ -24,7 +24,6 @@
#include <linux/em8300.h>
#include <vdr/tools.h>
-#include "dxr3demuxdevice.h"
// ==================================
bool cDxr3PesFrame::parse(const uint8_t *pes, uint32_t length)
@@ -76,14 +75,6 @@ bool cDxr3PesFrame::parse(const uint8_t *pes, uint32_t length)
m_payload = &pes[payloadStart];
m_payloadLength = length - payloadStart;
- // check for max sizes supported by syncbuffer
- if (m_pesDataType == PES_VIDEO_DATA && m_payloadLength > (uint32_t)VIDEO_MAX_FRAME_SIZE) {
- return false;
- }
- if (m_pesDataType == PES_AUDIO_DATA && m_payloadLength > (uint32_t)AUIDO_MAX_FRAME_SIZE) {
- return false;
- }
-
if (m_pesDataType == PES_VIDEO_DATA) {
// we can get some informations about the video payload
diff --git a/dxr3syncbuffer.c b/dxr3syncbuffer.c
deleted file mode 100644
index d9b7f3d..0000000
--- a/dxr3syncbuffer.c
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * dxr3syncbuffer.c
- *
- * Copyright (C) 2002-2004 Kai Möller
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-/*
- ToDo:
- - cDxr3SyncBuffer::Push: XXX This is only a workaround until a
- sufficient control algorithm is implemented
-*/
-
-#include <sys/time.h>
-#include "dxr3syncbuffer.h"
-
-const int DXR3_MAX_VIDEO_FRAME_LENGTH = 4096;
-const int DXR3_MAX_AUDIO_FRAME_LENGTH = 4096;
-
-// ==================================
-cFixedLengthFrame::~cFixedLengthFrame()
-{
- if (m_pData) {
- delete[] m_pData;
- }
-}
-
-// ==================================
-// ! setup our frame
-void cFixedLengthFrame::Init(uint32_t length)
-{
- this->length = length;
- m_pData = new uint8_t[length];
-
- // allocation ok?
- if (!m_pData) {
- esyslog("dxr3: fatal: unable to allocate memory for new frame");
- exit(1);
- }
-}
-
-// ==================================
-void cFixedLengthFrame::CopyFrame(const uint8_t* pStart, int length)
-{
- if (length > this->length()) {
- delete[] m_pData;
- m_pData = new uint8_t[length];
- }
- this->length = length;
- memcpy((void*) m_pData, (void*) pStart, length);
-}
-
-// ==================================
-uint8_t* cFixedLengthFrame::GetData(void)
-{
- return m_pData;
-}
-
-// ==================================
-//! constructor
-cDxr3SyncBuffer::cDxr3SyncBuffer(int frameCount, int frameLength) :
- cRingBuffer(frameCount, true)
-{
- m_dxr3Device = cDxr3Interface::instance();
- m_pBuffer = new cFixedLengthFrame[frameCount];
-
- // got we a valid m_pBuffer?
- if (!m_pBuffer) {
- esyslog("dxr3: fatal: unable to allocate memory for new frame");
- exit(1);
- }
-
- // init our new m_pBuffer;
- for (int i = 0; i < frameCount; i++) {
- m_pBuffer[i].Init(frameLength);
- }
-
- // set some default values
- m_count = 0;
- m_nextFree = 0;
- m_next = 0;
- m_bPutBlock = false;
- m_bGetBlock = false;
- m_bStartReceiver = false;
- m_bStopped = false;
- m_demuxMode = DXR3_DEMUX_TV_MODE;
- m_bPollSync = false;
- SetTimeouts(1000, 10);
-}
-
-// ==================================
-cDxr3SyncBuffer::~cDxr3SyncBuffer()
-{
- if (m_pBuffer) {
- delete[] m_pBuffer;
- }
-}
-
-// ==================================
-int cDxr3SyncBuffer::Available(void)
-{
- return m_count;
-}
-
-// ==================================
-const int BUFFER_LIMIT = 5;
-const int BUFFER_LIMIT_2 = 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)) {
- m_bPollSync = true;
- while ((Available() >= Size() - (Size()*BUFFER_LIMIT_2)/100) &&
- ((m_dxr3Device->GetSysClock() - currTime) <
- ((uint32_t)TimeoutMs * (uint32_t)45)))
- {
- int d_s, d_us, ms;
- m_bPutBlock = true;
- EnableGet();
- 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) {
- esyslog("dxr3: sync: secondary timeout");
- break;
- }
- }
- if (Available() >= Size() - (Size()*BUFFER_LIMIT_2)/100) {
- retVal = false;
- }
- }
- }
-
- return retVal;
-}
-
-// ==================================
-cFixedLengthFrame* cDxr3SyncBuffer::Push(const uint8_t* pStart, int length, uint32_t pts) throw (eSyncBufferException)
-{
- int lastIndex = 0;
- struct timeval tv_start, tv;
- gettimeofday(&tv_start, NULL);
-
- while ((Available() >= Size() - (Size()*10)/100)) {
- int d_s, d_us, ms;
- m_bPutBlock = true;
- EnableGet();
- 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) {
- esyslog("dxr3: sync: push timeout");
- return NULL;
- }
- }
-
- lastIndex = m_nextFree;
- m_pBuffer[m_nextFree].CopyFrame(pStart, length);
- m_pBuffer[m_nextFree].pts(pts);
- m_pBuffer[m_nextFree].channels(UNKNOWN_CHANNEL_COUNT);
- m_pBuffer[m_nextFree].samplerate(UNKNOWN_DATA_RATE);
- m_pBuffer[m_nextFree].aspectratio(UNKNOWN_ASPECT_RATIO);
- m_nextFree++;
- m_count++;
- m_nextFree %= Size();
-
- if (m_nextFree == m_next) {
- esyslog("dxr3: sync: push buffer overrun");
- Clear(); // XXX This is only a workaround until a sufficient control algorithm is implemented
- throw(SYNC_BUFFER_OVERRUN);
- }
- if (m_bStartReceiver) {
- EnableGet();
- }
-
- return &m_pBuffer[lastIndex];
-}
-
-// ==================================
-void cDxr3SyncBuffer::Pop(void)
-{
- if (m_count) {
- m_next++;
- m_count--;
- m_next %= Size();
- if (m_next == m_nextFree) {
- m_next = m_nextFree = m_count = 0;
- }
- }
- EnablePut();
-}
-
-// ==================================
-cFixedLengthFrame* cDxr3SyncBuffer::Get(void)
-{
- cFixedLengthFrame* pRet = 0;
-
- if (!m_bStopped) {
- while ((!Available() || !m_bStartReceiver) && !m_bStopped) {
- m_bGetBlock = true;
- ReceiverStopped();
- WaitForGet();
- }
-
- if (m_nextFree != m_next) {
- pRet = &m_pBuffer[m_next];
- }
- } else {
- WaitForGet();
- }
-
- return pRet;
-}
-
-// ==================================
-void cDxr3SyncBuffer::Clear(void)
-{
- m_next = 0;
- m_nextFree = 0;
- m_count = 0;
- m_bStartReceiver = false;
- m_bPollSync = false;
- if (m_bPutBlock) {
- EnablePut();
- m_bPutBlock = false;
- }
-}
-
-// ==================================
-void cDxr3SyncBuffer::Start(void)
-{
- m_bStartReceiver = true;
- m_bStopped = false;
- if (Available()) {
- EnableGet();
- }
-}
-
-// ==================================
-void cDxr3SyncBuffer::WakeUp(void)
-{
- if (m_bStartReceiver == true) {
- EnableGet();
- }
-}
-
-// ==================================
-void cDxr3SyncBuffer::WaitForReceiverStopped(void)
-{
- if (!m_bGetBlock) {
- receiverStoppedMutex.Lock();
- receiverStopped.Wait(receiverStoppedMutex);
- receiverStoppedMutex.Unlock();
- }
-}
-
-// ==================================
-void cDxr3SyncBuffer::ReceiverStopped(void)
-{
- receiverStopped.Broadcast();
-}
-
-// Local variables:
-// mode: c++
-// c-file-style: "stroustrup"
-// c-file-offsets: ((inline-open . 0))
-// tab-width: 4;
-// indent-tabs-mode: nil
-// End:
diff --git a/dxr3syncbuffer.h b/dxr3syncbuffer.h
deleted file mode 100644
index 0be8d91..0000000
--- a/dxr3syncbuffer.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * dxr3syncbuffer.h
- *
- * Copyright (C) 2002-2004 Kai Möller
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#ifndef _DXR3SYNCBUFFER_H_
-#define _DXR3SYNCBUFFER_H_
-
-
-#include <vdr/ringbuffer.h>
-#include "dxr3interface.h"
-#include "dxr3generaldefines.h"
-#include "uncopyable.h"
-#include "accessors.h"
-
-// ==================================
-const uint32_t UNKNOWN_CHANNEL_COUNT = 0xFFFFFFFF;
-const uint32_t UNKNOWN_DATA_RATE = 0xFFFFFFFF;
-const uint32_t UNKNOWN_ASPECT_RATIO = 0xFFFFFFFF;
-
-// ==================================
-class cFixedLengthFrame : private Uncopyable {
-public:
- cFixedLengthFrame() : samplerate(UNKNOWN_DATA_RATE), channels(UNKNOWN_CHANNEL_COUNT), aspectratio(UNKNOWN_ASPECT_RATIO),
- pts(0), length(0)
- {}
-
- ~cFixedLengthFrame();
-
- void Init(uint32_t lenght);
-
- void CopyFrame(const uint8_t* pStart, int length);
- uint8_t* GetData(void);
- int GetCount(void);
-
- Accessors<uint32_t> samplerate;
- Accessors<uint32_t> channels;
- Accessors<uint32_t> aspectratio;
- Accessors<uint32_t> pts;
-
- Accessors<uint32_t, ro> length;
-
-private:
- uint8_t* m_pData;
-};
-
-// ==================================
-class cDxr3SyncBuffer : public cRingBuffer, private Uncopyable {
-public:
- enum eSyncBufferException
- {
- SYNC_BUFFER_OVERRUN
- };
-public:
- cDxr3SyncBuffer(int frameCount, int frameLength);
- ~cDxr3SyncBuffer();
-
- virtual int Available(void);
- cFixedLengthFrame* Push(const uint8_t* pStart, int length, uint32_t pts)
- throw (eSyncBufferException);
- void Pop(void);
- cFixedLengthFrame* Get(void);
- void Clear(void);
- void Stop(void)
- {
- m_bStopped = true;
- };
- void Start(void);
- void WakeUp(void);
- void WaitForReceiverStopped(void);
- void SetDemuxMode(eDxr3DemuxMode demuxMode)
- {
- m_demuxMode = demuxMode;
- };
- bool Poll(int TimeoutMs);
- bool IsPolled(void)
- {
- return m_bPollSync;
- };
- uint32_t GetFillLevel(void)
- {
- return Available() * 100 / Size();
- };
-
-private:
- void ReceiverStopped(void);
-
- cFixedLengthFrame* m_pBuffer;
- int m_count;
- int m_nextFree;
- int m_next;
- bool m_bPutBlock;
- bool m_bGetBlock;
- bool m_bStartReceiver;
- bool m_bStopped;
- eDxr3DemuxMode m_demuxMode;
-
- cCondVar receiverStopped;
- cMutex receiverStoppedMutex;
- cDxr3Interface *m_dxr3Device;
- bool m_bPollSync;
-
- cDxr3SyncBuffer(); // you are not allowed to use this constructor
-};
-
-#endif /*_DXR3SYNCBUFFER_H_*/
-
-// Local variables:
-// mode: c++
-// c-file-style: "stroustrup"
-// c-file-offsets: ((inline-open . 0))
-// tab-width: 4;
-// indent-tabs-mode: nil
-// End: