summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dxr3audiodecoder.h43
-rw-r--r--dxr3demuxdevice.c2
-rw-r--r--dxr3device.c22
-rw-r--r--dxr3device.h12
-rw-r--r--dxr3interface.c388
-rw-r--r--dxr3interface.h63
-rw-r--r--dxr3outputthread.c19
-rw-r--r--dxr3spudecoder.h160
-rw-r--r--dxr3unixserversocket.c19
-rw-r--r--dxr3vdrincludes.h1
10 files changed, 299 insertions, 430 deletions
diff --git a/dxr3audiodecoder.h b/dxr3audiodecoder.h
index 5be42d2..fb7d811 100644
--- a/dxr3audiodecoder.h
+++ b/dxr3audiodecoder.h
@@ -32,47 +32,42 @@
#include "dxr3log.h"
// ==================================
-//! Decode given audiostream in usable audioformat
-/*!
- Here we can decode lpcm, ac3 and pcm to useable
- bitstream for ffmpeg. ffmpeg will convert
- the datastream into mp2.
-*/
+// decode audio to mp2 or use DD :)
class cDxr3AudioDecoder
{
public:
cDxr3AudioDecoder();
~cDxr3AudioDecoder();
- void Init();
+ void Init(void); // init in const?
void Decode(const uint8_t* buf, int length, uint32_t pts, cDxr3SyncBuffer &aBuf);
void DecodeLpcm(const uint8_t* buf, int length, uint32_t pts, cDxr3SyncBuffer &aBuf);
void DecodeAc3Dts(const uint8_t* pPes, const uint8_t* buf, int length, uint32_t pts, cDxr3SyncBuffer &aBuf);
- int GetRate() const { return m_Rate; }
- int GetChannelCount() const { return m_Channels; }
- int GetFrameSize() const { return m_FrameSize; }
- void Reset() { m_AC3dtsDecoder.Clear(); m_RBuf.Clear(); }
+ int GetRate(void) const { return rate; }
+ int GetChannelCount(void) const { return channels; }
+ int GetFrameSize(void) const { return frameSize; }
+ void Reset(void) { ac3dtsDecoder.Clear(); rbuf.Clear(); }
private:
bool HeadCheck(unsigned long head);
- struct Dxr3Codec m_Codec;
+ struct Dxr3Codec Codec;
- cRingBufferFrame m_RBuf;
- cMultichannelAudio m_AC3dtsDecoder;
+ cRingBufferFrame rbuf;
+ cMultichannelAudio ac3dtsDecoder;
- bool m_AudioSynched;
- bool m_DecoderOpened;
- uint8_t m_LastHeader[4];
- int m_Rate;
- int m_Channels;
- uint32_t m_FrameSize;
- uint8_t m_PcmBuf[AVCODEC_MAX_AUDIO_FRAME_SIZE];
- int m_Volume;
- bool m_FoundHeader;
- bool m_DecodeAudio;
+ bool audioSynched;
+ bool decoderOpened;
+ uint8_t lastHeader[4];
+ int rate;
+ int channels;
+ uint32_t frameSize;
+ uint8_t pcmbuf[AVCODEC_MAX_AUDIO_FRAME_SIZE];
+ int volume;
+ bool foundHeader;
+ bool decodeAudio;
cDxr3AudioDecoder(cDxr3AudioDecoder&); // no copy constructor
};
diff --git a/dxr3demuxdevice.c b/dxr3demuxdevice.c
index 0048b6e..0a60513 100644
--- a/dxr3demuxdevice.c
+++ b/dxr3demuxdevice.c
@@ -31,7 +31,7 @@
#include "dxr3log.h"
// ==================================
-//! constructor
+// constr.
cDxr3DemuxDevice::cDxr3DemuxDevice(cDxr3Interface& dxr3Device) :
m_dxr3Device(dxr3Device),
m_aBuf(AUDIO_MAX_BUFFER_SIZE, AUIDO_MAX_FRAME_SIZE, m_dxr3Device),
diff --git a/dxr3device.c b/dxr3device.c
index 36f5ca7..b269b0c 100644
--- a/dxr3device.c
+++ b/dxr3device.c
@@ -1,3 +1,25 @@
+/*
+ * dxr3devide.c
+ *
+ * Copyright (C) 2002-2004 Kai Möller
+ * Copyright (C) 2004 Christian Gmeiner
+ *
+ * This program 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 program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
#include "dxr3device.h"
#include "dxr3configdata.h"
#include "dxr3interface.h"
diff --git a/dxr3device.h b/dxr3device.h
index f0ff959..c6fb975 100644
--- a/dxr3device.h
+++ b/dxr3device.h
@@ -28,14 +28,10 @@
#include "dxr3demuxdevice.h"
#include "dxr3spudecoder.h"
#include <string>
-//using namespace std;
+using namespace std;
// ==================================
// our device :)
-/*!
- cDxr3Device is the interface for VDR devices.
- Is is the part, which VDR "talks" with our plugin.
-*/
class cDxr3Device : public cDevice, public Singleton<cDxr3Device>
{
public:
@@ -58,11 +54,7 @@ public:
virtual void StillPicture(const uchar *Data, int Length);
virtual bool Poll(cPoller &Poller, int TimeoutMs = 0);
virtual int PlayVideo(const uchar *Data, int Length);
-#if VDRVERSNUM >= 10318
- virtual int PlayAudio(const uchar *Data, int Length);
-#else
virtual void PlayAudio(const uchar *Data, int Length);
-#endif
// addition functions
virtual bool GrabImage(const char *FileName, bool Jpeg = true, int Quality = -1, int SizeX = -1, int SizeY = -1);
@@ -83,7 +75,7 @@ protected:
cDxr3DemuxDevice m_DemuxDevice;
bool m_AC3Present;
bool m_CalledBySet;
- std::string m_strBuf;
+ string m_strBuf;
int m_Offset;
//virtual bool SetPlayMode(ePlayMode PlayMode);
diff --git a/dxr3interface.c b/dxr3interface.c
index 4211048..6226f23 100644
--- a/dxr3interface.c
+++ b/dxr3interface.c
@@ -26,7 +26,8 @@
#include "dxr3interface.h"
#include "dxr3syncbuffer.h"
-#include "dxr3osd.h"
+#include "dxr3log.h"
+#include "dxr3configdata.h"
// ==================================
const int LPCM_HEADER_LENGTH = 7;
@@ -34,16 +35,7 @@ const int ZEROBUFFER_SIZE = 4096;
uint8_t zerobuffer[ZEROBUFFER_SIZE] = {0};
// ==================================
-//! default spu palette
-static unsigned default_palette[16] =
-{
- 0xe18080, 0x2b8080, 0x847b9c, 0x51ef5a, 0x7d8080, 0xb48080,
- 0xa910a5, 0x6addca, 0xd29210, 0x1c76b8, 0x50505a, 0x30b86d,
- 0x5d4792, 0x3dafa5, 0x718947, 0xeb8080
-};
-
-// ==================================
-//! helper function to generate name
+// helper function to generate name
static const char *Dxr3Name(const char *Name, int n)
{
static char buffer[PATH_MAX];
@@ -52,7 +44,7 @@ static const char *Dxr3Name(const char *Name, int n)
}
// ==================================
-//! helper function to open the card #n
+// helper function to open the card #n
static int Dxr3Open(const char *Name, int n, int Mode)
{
const char *FileName = Dxr3Name(Name, n);
@@ -61,27 +53,26 @@ static int Dxr3Open(const char *Name, int n, int Mode)
if (fd < 0)
{
cLog::Instance() << "Unable to open " << FileName << "\n";
- return 0;
}
return fd;
}
// ==================================
-//! constructor
+// constr.
cDxr3Interface::cDxr3Interface()
{
// open control stream
m_fdControl = Dxr3Open("", cDxr3ConfigData::Instance().GetDxr3Card(), O_WRONLY | O_SYNC);
if (!m_fdControl)
{
+ cLog::Instance() << "Unable to open the control stream!\n";
cLog::Instance() << "Please check if the dxr3 modules are loaded!\n";
- exit(1);
}
// upload microcode to dxr3
UploadMicroCode();
- ///< open 'multimedia' streams
+ // open 'multimedia' streams
m_fdVideo = Dxr3Open("_mv", cDxr3ConfigData::Instance().GetDxr3Card(), O_WRONLY | O_SYNC);
m_fdAudio = Dxr3Open("_ma", cDxr3ConfigData::Instance().GetDxr3Card(), O_WRONLY | O_SYNC);
m_fdSpu = Dxr3Open("_sp", cDxr3ConfigData::Instance().GetDxr3Card(), O_WRONLY | O_SYNC);
@@ -93,10 +84,8 @@ cDxr3Interface::cDxr3Interface()
exit(1);
}
- // create clock
m_pClock = new cDxr3SysClock(m_fdControl, m_fdVideo, m_fdSpu);
- // everything ok?
if (!m_pClock)
{
cLog::Instance() << "Unable to allocate memory for m_pClock in cDxr3Interface\n";
@@ -137,7 +126,6 @@ cDxr3Interface::cDxr3Interface()
}
// ==================================
-//! destructor
cDxr3Interface::~cDxr3Interface()
{
// close filehandles
@@ -178,11 +166,11 @@ void cDxr3Interface::Stop()
// audio
// ==================================
-//! set audio-output to analog
+// set audio-output to analog
void cDxr3Interface::SetAudioAnalog()
{
- Lock();
int ioval = 0;
+ Lock();
if (!m_ExternalReleased && m_audioMode != EM8300_AUDIOMODE_ANALOG)
{
@@ -202,12 +190,12 @@ void cDxr3Interface::SetAudioAnalog()
}
// ==================================
-//! set audio-output to digital pcm
+// set audio-output to digital pcm
void cDxr3Interface::SetAudioDigitalPCM()
{
- Lock();
int ioval = 0;
-
+ Lock();
+
if (!m_ExternalReleased && m_audioMode != EM8300_AUDIOMODE_DIGITALPCM)
{
int prevMode = m_audioMode;
@@ -227,14 +215,13 @@ void cDxr3Interface::SetAudioDigitalPCM()
}
// ==================================
-//! set audio-output to digital ac3
+// set audio-output to digital ac3
void cDxr3Interface::SetAudioDigitalAC3()
{
- Lock();
-
if (m_audioMode != EM8300_AUDIOMODE_DIGITALAC3)
{
int ioval = 0;
+ Lock();
if (!m_ExternalReleased && m_audioMode != EM8300_AUDIOMODE_DIGITALAC3)
{
@@ -245,17 +232,14 @@ void cDxr3Interface::SetAudioDigitalAC3()
}
ReOpenAudio();
}
+
+ Unlock();
}
-
- Unlock();
}
// ==================================
-//! set audiosepeed
void cDxr3Interface::SetAudioSpeed(uint32_t speed)
{
- Lock();
-
if (m_audioDataRate != speed && speed != UNKNOWN_DATA_RATE)
{
if (!m_ExternalReleased)
@@ -270,16 +254,11 @@ void cDxr3Interface::SetAudioSpeed(uint32_t speed)
}
m_audioDataRate = speed;
}
-
- Unlock();
}
// ==================================
-//! set nummber of channels
void cDxr3Interface::SetChannelCount(uint32_t count)
{
- Lock();
-
if (m_audioChannelCount != count && count != UNKNOWN_CHANNEL_COUNT)
{
if (!m_ExternalReleased)
@@ -294,16 +273,11 @@ void cDxr3Interface::SetChannelCount(uint32_t count)
}
m_audioChannelCount = count;
}
-
- Unlock();
}
// ==================================
-//! set audio sample size
void cDxr3Interface::SetAudioSampleSize(uint32_t sampleSize)
{
- Lock();
-
if (!m_ExternalReleased)
{
if (ioctl(m_fdAudio, SNDCTL_DSP_SAMPLESIZE, sampleSize))
@@ -311,58 +285,42 @@ void cDxr3Interface::SetAudioSampleSize(uint32_t sampleSize)
cLog::Instance() <<"cDxr3AbsDevice::SetAudioSampleSize Unable to set audio sample size\n";
}
}
- m_audioSampleSize = sampleSize;
-
- Unlock();
+ m_audioSampleSize = sampleSize;
}
// clock
// ==================================
void cDxr3Interface::SetSysClock(uint32_t scr)
{
- Lock();
-
if (!m_ExternalReleased)
{
m_pClock->SetSysClock(scr);
}
-
- Unlock();
}
// ==================================
uint32_t cDxr3Interface::GetSysClock() const
{
- Lock();
-
uint32_t ret = 0;
if (!m_ExternalReleased)
{
ret = m_pClock->GetSysClock();
- }
-
- Unlock();
+ }
return ret;
}
// ==================================
void cDxr3Interface::SetPts(uint32_t pts)
{
- Lock();
-
if (!m_ExternalReleased)
{
m_pClock->SetPts(pts);
}
-
- Unlock();
}
// ==================================
void cDxr3Interface::SetSpuPts(uint32_t pts)
{
- Lock();
-
pts = pts >> 1;
if (!m_ExternalReleased)
{
@@ -371,17 +329,15 @@ void cDxr3Interface::SetSpuPts(uint32_t pts)
m_pClock->SetSpuPts(pts);
}
}
-
- Unlock();
}
// state changes
// ==================================
-//! enable subpicture processing of the dxr3
+// enable subpicture proeccesing of the dxr3
void cDxr3Interface::EnableSPU()
{
- Lock();
int ioval = 0;
+ Lock();
if (!m_ExternalReleased && m_spuMode != EM8300_SPUMODE_ON)
{
@@ -396,12 +352,11 @@ void cDxr3Interface::EnableSPU()
}
// ==================================
-//! disable subpicture proeccesing of the dxr3
+// disable subpicture proeccesing of the dxr3
void cDxr3Interface::DisableSPU()
{
- Lock();
-
int ioval = 0;
+ Lock();
if (!m_ExternalReleased && m_spuMode != EM8300_SPUMODE_OFF)
{
@@ -416,11 +371,9 @@ void cDxr3Interface::DisableSPU()
}
// ==================================
-//! disable audio output of dxr3
+// disable audio output of dxr3
void cDxr3Interface::DisableAudio()
{
- Lock();
-
m_AudioActive = false;
// we wirte zero buffers to dxr3
@@ -431,15 +384,12 @@ void cDxr3Interface::DisableAudio()
if (write(m_fdAudio, zerobuffer, ZEROBUFFER_SIZE) < 0) Resuscitation();
if (write(m_fdAudio, zerobuffer, ZEROBUFFER_SIZE) < 0) Resuscitation();
}
- Unlock();
}
// ==================================
-//! enable overlay mode of the dxr3
+// enable overlay mode of the dxr3
void cDxr3Interface::EnableOverlay()
{
- Lock();
-
// first we check, if it is enable yet
if (m_OverlayActive)
{
@@ -488,32 +438,26 @@ void cDxr3Interface::EnableOverlay()
}
m_OverlayActive = true;
-
- Unlock();
}
// ==================================
-//! disable overlay mode of the dxr3
+// disable overlay mode of the dxr3
void cDxr3Interface::DisanleOverlay()
{
- Lock();
-
// is it allready disabled
if (!m_OverlayActive)
{
return;
}
-
- Unlock();
}
// set/get functions
// ==================================
-//! get aspect ratio
+// get aspect ratio
uint32_t cDxr3Interface::GetAspectRatio() const
{
- Lock();
int ioval = 0;
+ Lock();
if (!m_ExternalReleased)
{
@@ -528,12 +472,11 @@ uint32_t cDxr3Interface::GetAspectRatio() const
}
// ==================================
-//! set aspectratio
void cDxr3Interface::SetAspectRatio(uint32_t ratio)
{
- Lock();
-
static int requestCounter = 0;
+
+ Lock();
if (cDxr3ConfigData::Instance().GetForceLetterBox()) ratio = EM8300_ASPECTRATIO_16_9;
if (Setup.VideoFormat) ratio = EM8300_ASPECTRATIO_4_3;
@@ -570,14 +513,14 @@ void cDxr3Interface::SetAspectRatio(uint32_t ratio)
// play functions
// ==================================
-//! set playing mode and start sync engine
+// set playing mode and start sync engine
void cDxr3Interface::SetPlayMode()
{
- Lock();
-
em8300_register_t reg;
int ioval;
+ Lock();
+
if (!m_ExternalReleased)
{
ioval = EM8300_SUBDEVICE_AUDIO;
@@ -606,9 +549,8 @@ void cDxr3Interface::SetPlayMode()
// ==================================
void cDxr3Interface::Pause()
{
- Lock();
-
int ioval = EM8300_PLAYMODE_PAUSED;
+ Lock();
if (!m_ExternalReleased)
{
@@ -623,9 +565,8 @@ void cDxr3Interface::Pause()
// ==================================
void cDxr3Interface::SingleStep()
{
+ int ioval = EM8300_PLAYMODE_SINGLESTEP;
Lock();
-
- int ioval = EM8300_PLAYMODE_SINGLESTEP;
if (!m_ExternalReleased)
{
@@ -640,13 +581,13 @@ void cDxr3Interface::SingleStep()
// ==================================
void cDxr3Interface::PlayVideoFrame(cFixedLengthFrame* pFrame, int times)
{
- Lock();
-
int written = 0;
int count = 0;
if (m_VideoActive)
{
+ Lock();
+
if (!m_ExternalReleased)
{
for (int i = 0; i < times; i++)
@@ -670,30 +611,23 @@ void cDxr3Interface::PlayVideoFrame(cFixedLengthFrame* pFrame, int times)
written = 0;
}
}
+
+ Unlock();
+
SetAspectRatio(pFrame->GetAspectRatio());
}
-
- Unlock();
}
// ==================================
void cDxr3Interface::PlayVideoFrame(const uint8_t* pBuf, int length, int times)
{
Lock();
-
- int written = 0;
if (!m_ExternalReleased)
{
for (int i = 0; i < times; i++)
{
- // if (write(m_fdVideo, pBuf, length) < 0) Resuscitation();
-
- if ((written = write(m_fdVideo, pBuf, length) < 0)) Resuscitation();
- if (written != length)
- {
- cLog::Instance() << "cDxr3Interface::PlayVideoFrame(uint8_t* pBuf, int length): Not written = " << length - written << "\n";
- }
+ if (write(m_fdVideo, pBuf, length) < 0) Resuscitation();
}
}
@@ -703,31 +637,32 @@ void cDxr3Interface::PlayVideoFrame(const uint8_t* pBuf, int length, int times)
// ==================================
void cDxr3Interface::PlayAudioFrame(cFixedLengthFrame* pFrame)
{
- Lock();
+
+ // XXX: Call this only with we are not in external mode?
if (m_AudioActive)
{
+ Lock();
+
SetAudioSpeed(pFrame->GetDataRate());
SetChannelCount(pFrame->GetChannelCount());
if (!m_ExternalReleased)
{
- int size = pFrame->GetCount();
if (!cDxr3ConfigData::Instance().GetAc3OutPut()) ResampleVolume((short*)pFrame->GetData(), pFrame->GetCount());
-
- write(m_fdAudio, pFrame->GetData(), size);
+ write(m_fdAudio, pFrame->GetData(), pFrame->GetCount());
}
+
+ Unlock();
}
- Unlock();
}
// ==================================
void cDxr3Interface::PlayAudioFrame(uint8_t* pBuf, int length)
{
+ int written = 0;
Lock();
- int written = 0;
-
if (!m_ExternalReleased)
{
if (!cDxr3ConfigData::Instance().GetAc3OutPut()) ResampleVolume((short*)pBuf, length);
@@ -738,15 +673,12 @@ void cDxr3Interface::PlayAudioFrame(uint8_t* pBuf, int length)
cLog::Instance() << "cDxr3Interface::PlayAudioFrame(uint8_t* pBuf, int length): Not written = " << length - written << "\n";
}
}
-
Unlock();
}
// ==================================
void cDxr3Interface::PlayAudioLpcmFrame(uint8_t* pBuf, int length)
{
- Lock();
-
if (length > (LPCM_HEADER_LENGTH + 2))
{
uint8_t* pFrame = new uint8_t[length - LPCM_HEADER_LENGTH];
@@ -784,14 +716,12 @@ void cDxr3Interface::PlayAudioLpcmFrame(uint8_t* pBuf, int length)
PlayAudioFrame(pFrame, length - LPCM_HEADER_LENGTH);
delete[] pFrame;
}
-
- Unlock();
}
// external device access
// ==================================
-//! release devices, so mplayer-plugin, for instance,
-//! can access the dxr3
+// release devices, so mplayer-plugin, for instance,
+// can access the dxr3
void cDxr3Interface::ExternalReleaseDevices()
{
Lock();
@@ -814,7 +744,7 @@ void cDxr3Interface::ExternalReleaseDevices()
}
// ==================================
-//! reopen devices for using in the dxr3 plugin
+// reopen devices for using in the dxr3 plugin
void cDxr3Interface::ExternalReopenDevices()
{
Lock();
@@ -855,14 +785,14 @@ void cDxr3Interface::ExternalReopenDevices()
// tools
// ==================================
-//! play blackframe on tv
+// play blackframe on tv
void cDxr3Interface::PlayBlackFrame()
-{
- Lock();
-
+{
extern char blackframe[];
- extern int blackframeLength;
-
+ extern int blackframeLength;
+
+ Lock();
+
if (!m_ExternalReleased)
{
if (write(m_fdVideo, blackframe, blackframeLength) < 0) Resuscitation();
@@ -914,26 +844,22 @@ cOsdBase* cDxr3Interface::NewOsd(int x, int y)
#endif
// ==================================
-//! uploadroutine for microcode
+// uploadroutine for microcode
void cDxr3Interface::UploadMicroCode()
{
- Lock();
-
if (cDxr3ConfigData::Instance().GetDebug())
{
- cLog::Instance() << "cDxr3Interface::UploadMicroCode: uploading from " << MICROCODE << "...";
+ cLog::Instance() << "cDxr3Interface::UploadMicroCode: uploading...";
}
em8300_microcode_t em8300_microcode;
+ const char* MICRO_CODE_FILE = "/usr/share/misc/em8300.uc";
struct stat s;
-
- // try to open it
- // MICROCODE comes from makefile
- int UCODE = open(MICROCODE, O_RDONLY);
+ int UCODE = open(MICRO_CODE_FILE, O_RDONLY);
if (UCODE <0)
{
- cLog::Instance() << "Unable to open microcode file " << MICROCODE << " for reading\n";
+ cLog::Instance() << "Unable to open microcode file " << MICRO_CODE_FILE << " for reading\n";
exit(1);
}
@@ -971,35 +897,21 @@ void cDxr3Interface::UploadMicroCode()
delete [] (char*) em8300_microcode.ucode;
exit(1);
}
-
- // free memory to avoid memory leak
delete [] (char*) em8300_microcode.ucode;
if (cDxr3ConfigData::Instance().GetDebug())
{
cLog::Instance() << "...done\n";
}
-
- Unlock();
}
// ==================================
-//! config and setup device via ioctl calls
+// config and setup device via ioctl calls
void cDxr3Interface::ConfigureDevice()
{
- Lock();
-
- // get videomode from driver
- uint32_t videomode_from_driver = 0;
-
- if (ioctl(m_fdControl, EM8300_IOCTL_GET_VIDEOMODE, &videomode_from_driver) == -1)
- {
- cLog::Instance() << "Unable to get videomode\n";
- exit(1);
- }
+ uint32_t videomode = 0;
// set video mode
- uint32_t videomode = 0;
if (cDxr3ConfigData::Instance().GetVideoMode() == PAL)
{
videomode = EM8300_VIDEOMODE_PAL;
@@ -1025,16 +937,12 @@ void cDxr3Interface::ConfigureDevice()
}
}
- // are the two videmodes different?
- if (videomode_from_driver != videomode)
+ // make ioctl
+ if (ioctl(m_fdControl, EM8300_IOCTL_SET_VIDEOMODE, &videomode) == -1)
{
- // make ioctl
- if (ioctl(m_fdControl, EM8300_IOCTL_SET_VIDEOMODE, &videomode) == -1)
- {
- cLog::Instance() << "Unable to set videomode\n";
- exit(1);
- }
- }
+ cLog::Instance() << "Unable to set videomode\n";
+ exit(1);
+ }
// set audio mode
if (!cDxr3ConfigData::Instance().GetUseDigitalOut())
@@ -1045,16 +953,12 @@ void cDxr3Interface::ConfigureDevice()
cLog::Instance() << "cDxr3Interface::ConfigureDevice: Audiomode = Analog\n";
}
}
-
- Unlock();
}
// ==================================
-//! reset whole hardware
+// reset whole hardware
void cDxr3Interface::Resuscitation()
{
- Lock();
-
time_t startt = time(&startt);
time_t endt = 0;
m_ExternalReleased = true;
@@ -1076,16 +980,11 @@ void cDxr3Interface::Resuscitation()
}
ConfigureDevice();
-
- Unlock();
}
// ==================================
-//! pcm resampling funtcion
void cDxr3Interface::ResampleVolume(short* pcmbuf, int size)
{
- Lock();
-
if (m_volume == 0)
{
memset(pcmbuf, 0, size);
@@ -1099,15 +998,11 @@ void cDxr3Interface::ResampleVolume(short* pcmbuf, int size)
pcmbuf[i] = (((int)pcmbuf[i]) * factor) / 65536;
}
}
-
- Unlock();
}
// ==================================
void cDxr3Interface::ClearOsd()
{
- Lock();
-
encodedata ed;
int controlstart= 0;
int x1 = 0;
@@ -1145,11 +1040,6 @@ void cDxr3Interface::ClearOsd()
WriteSpu((const uint8_t*) &ed, (int) ed.count);
ClearButton();
}
-
- Unlock();
-
- // prevent osd to get pink
- SetPalette(default_palette); // ok here? Has its own un/lock
}
// ==================================
@@ -1168,8 +1058,6 @@ void cDxr3Interface::WriteSpu(const uint8_t* pBuf, int length)
// ==================================
void cDxr3Interface::SetButton(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint32_t palette)
{
- Lock();
-
em8300_button_t button;
button.color = palette >> 16;
@@ -1180,15 +1068,11 @@ void cDxr3Interface::SetButton(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t e
button.right = ex;
ioctl(m_fdSpu, EM8300_IOCTL_SPU_BUTTON, &button);
-
- Unlock();
}
// ==================================
void cDxr3Interface::ClearButton()
{
- Lock();
-
em8300_button_t button;
button.color = 0;
@@ -1199,184 +1083,60 @@ void cDxr3Interface::ClearButton()
button.right = 2;
ioctl(m_fdSpu, EM8300_IOCTL_SPU_BUTTON, &button);
-
- Unlock();
}
// ==================================
void cDxr3Interface::SetPalette(unsigned int *pal)
{
- Lock();
-
ioctl(m_fdSpu, EM8300_IOCTL_SPU_SETPALETTE, (uint8_t*)pal);
-
- Unlock();
}
// helper functions for dxr3 main osd screen
// ==================================
-//! reset dxr3 card
+// reset dxr3 card
void cDxr3Interface::ResetHardware()
{
Lock();
-
cLog::Instance() << "cDxr3Interface: Resting DXR3 hardware\n";
Resuscitation();
-
Unlock();
}
// set brightness/contrast/saturation
// ==================================
-//! set brightness
+// set brightness
void cDxr3Interface::SetBrightness(int value)
{
- Lock();
-
m_bcs.brightness = value;
if (ioctl(m_fdControl, EM8300_IOCTL_SETBCS, &m_bcs) < 0)
{
cLog::Instance() << "cDxr3Interface::SetBrightness: Unable to set brightness to " << value << "\n";
}
-
- Unlock();
}
// ==================================
-//! set contrast
+// set contrast
void cDxr3Interface::SetContrast(int value)
{
- Lock();
-
m_bcs.contrast = value;
if (ioctl(m_fdControl, EM8300_IOCTL_SETBCS, &m_bcs) < 0)
{
cLog::Instance() << "cDxr3Interface::SetContrast: Unable to set contrast to " << value << "\n";
}
-
- Unlock();
}
// ==================================
-//! set saturation
+// set saturation
void cDxr3Interface::SetSaturation(int value)
{
- Lock();
-
m_bcs.saturation = value;
if (ioctl(m_fdControl, EM8300_IOCTL_SETBCS, &m_bcs) < 0)
{
cLog::Instance() << "cDxr3Interface::SetSaturation: Unable to set saturation to " << value << "\n";
}
- Unlock();
-}
-
-// access registers
-// ==================================
-//! read a register
-long cDxr3Interface::ReadRegister(int registernum)
-{
- Lock();
-
- em8300_register_t reg;
-
- reg.microcode_register = 0;
- reg.reg = registernum;
- reg.val = 0;
-
- ioctl(m_fdControl, EM8300_IOCTL_READREG, &reg);
- return (reg.val);
-
- Unlock();
-}
-
-// ==================================
-//! write a register
-void cDxr3Interface::WriteRegister(int registernum, int val)
-{
- Lock();
-
- em8300_register_t reg;
-
- reg.microcode_register = 0;
- reg.reg = registernum;
- reg.val = val;
- ioctl(m_fdControl, EM8300_IOCTL_WRITEREG, &reg);
-
- Unlock();
-}
-
-// ==================================
-//! grabs the current tv screen
-void cDxr3Interface::GrabScreen(int w, int h, char** buf)
-{
-
-}
-
-// maybe we should copy this routine into em8300 driver
-// ==================================
-//! It appears that the follow routine copies length bytes to memory pointed to
-//! by dst.
-//! Most likely, pos contains some kind of buffer offset.
-char cDxr3Interface::Dxr3CopyYUVData(int pos, int *dst, int length)
-{
- int l1;
-
- for (l1 = 0x1000; (l1) ;--l1)
- {
- if (ReadRegister(0x1c1a) == 0)
- break;
- }
-
- if (l1 == 0)
- {
- //printf("Borked!\n");
- exit(0);
- }
-
- WriteRegister(0x1c50, 8);
- WriteRegister(0x1c51, pos & 0xffff);
- WriteRegister(0x1c52, pos >>16);
- WriteRegister(0x1c53, length);
- WriteRegister(0x1c54, length);
- WriteRegister(0x1c55, 0);
- WriteRegister(0x1c56, 1);
- WriteRegister(0x1c57, 1);
- WriteRegister(0x1c58, pos & 0xffff);
- WriteRegister(0x1c59, 0);
- WriteRegister(0x1c5a, 1);
-
- int l2 = 0;
- for (l2=0; l2 < (length>>2) ; ++l2)
- {
- *dst++ = ReadRegister(0x11800);
- }
-
- switch (length % 4)
- {
- case 3:
- *dst++ = ReadRegister(0x11000);
- break;
-
- case 2:
- *dst++ = ReadRegister(0x10800);
- break;
-
- case 1:
- *dst++ = ReadRegister(0x10000);
- break;
- }
-
- for (l1 = 0x1000; (l1) ; --l1)
- {
- if (ReadRegister(0x1c1a) == 0)
- return 1;
- }
-
- return 0;
}
// ==================================
diff --git a/dxr3interface.h b/dxr3interface.h
index 492c1e3..763ee44 100644
--- a/dxr3interface.h
+++ b/dxr3interface.h
@@ -33,17 +33,13 @@
#include "dxr3log.h"
#include "dxr3configdata.h"
#include "dxr3sysclock.h"
+#include "dxr3osd.h"
// ==================================
class cFixedLengthFrame;
// ==================================
-//! interafce to dxr3-card
-/*!
- cDxr3Interface is the interface to the dxr3
- driver and so to the card,
- so this is the layer between plugin and driver.
-*/
+// interafce to dxr3-card
class cDxr3Interface : public Singleton<cDxr3Interface>
{
public:
@@ -127,48 +123,41 @@ public:
private:
// file handles
- int m_fdControl; ///< filehandle for contol fifo of dxr3 card
- int m_fdVideo; ///< filehandle for video fifo of dxr3 card
- int m_fdAudio; ///< filehandle for audio fifo of dxr3 card
- int m_fdSpu; ///< filehandle for spu fifo of dxr3 card
+ int m_fdControl;
+ int m_fdVideo;
+ int m_fdSpu;
+ int m_fdAudio;
// dxr3 clock
- cDxr3SysClock* m_pClock; ///< clock used for sync
-
- uint32_t m_audioMode; ///< current used audiomode like analog or digital-PCM
- uint32_t m_audioChannelCount; ///< how many channles has the current audiostream
- uint32_t m_audioDataRate; ///< which rate is used for the current audiostream
- uint32_t m_audioSampleSize; ///< how big is the sample size for the current audiostream
- //int m_aspectDelayCounter;
- uint32_t m_aspectRatio; ///< current used aspect ratio
- uint32_t m_horizontal; ///< horizontal size of current videostream
- bool m_ExternalReleased; ///< is dxr3 used by e.g. mplayer?
- int m_volume; ///< volumevalue (0...255)
- uint32_t m_spuMode; ///< is spu enabled or disabled?
- bool m_AudioActive; ///< is audio active?
- bool m_VideoActive; ///< is video active?
- bool m_OverlayActive; ///< is overlay active?
+ cDxr3SysClock* m_pClock;
+
+ uint32_t m_audioChannelCount;
+ uint32_t m_audioDataRate;
+ int m_aspectDelayCounter;
+ uint32_t m_aspectRatio;
+ uint32_t m_horizontal;
+ uint32_t m_audioSampleSize;
+ uint32_t m_audioMode;
+ uint32_t m_spuMode;
+ bool m_ExternalReleased; // is dxr3 used by e.g. mplayer?
+ int m_volume;
+ bool m_AudioActive;
+ bool m_VideoActive;
+ bool m_OverlayActive;
// bcs
- em8300_bcs_t m_bcs; ///< BrightnessContrastSaturation values
+ em8300_bcs_t m_bcs;
+
+ // spu
+// cDxr3InterfaceSpu m_SpuInterface;
void UploadMicroCode();
void ConfigureDevice();
void ResampleVolume(short* pcmbuf, int size);
void Resuscitation();
- // access registers
- long ReadRegister(int registernum);
- void WriteRegister(int registernum, int val);
-
- // grab screen
- void GrabScreen(int w, int h, char** buf);
-
- // maybe we should copy this routine into em8300 driver
- char Dxr3CopyYUVData(int pos, int *dst, int length);
-
protected:
- static cMutex* m_pMutex; ///< mutex for dxr3interface
+ static cMutex* m_pMutex;
static void Lock() { cDxr3Interface::m_pMutex->Lock(); }
static void Unlock() { cDxr3Interface::m_pMutex->Unlock(); }
diff --git a/dxr3outputthread.c b/dxr3outputthread.c
index 3fb0933..d74689f 100644
--- a/dxr3outputthread.c
+++ b/dxr3outputthread.c
@@ -1,8 +1,21 @@
/*
- * dxr3outputthread.c:
+ * dxr3outputthread.c
*
- * See the main source file 'dxr3.c' for copyright information and
- * how to reach the author.
+ * Copyright (C) 2002-2004 Kai Möller
+ *
+ * This program 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 program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
diff --git a/dxr3spudecoder.h b/dxr3spudecoder.h
index a5fea45..fab3a31 100644
--- a/dxr3spudecoder.h
+++ b/dxr3spudecoder.h
@@ -21,43 +21,139 @@
#ifndef _DXR3SPUDECODER_H_
#define _DXR3SPUDECODER_H_
-
+
#include "dxr3vdrincludes.h"
-#include "dxr3interface.h"
+#include <inttypes.h>
+
+// ==================================
+typedef struct sDxr3SpuPalDescr
+{
+ uint8_t index;
+ uint8_t trans;
+
+ bool operator != (const sDxr3SpuPalDescr pd) const {
+ return index != pd.index && trans != pd.trans;
+ };
+} aDxr3SpuPalDescr[4];
+
+// ==================================
+struct sDxr3SpuRect
+{
+ int x1, y1;
+ int x2, y2;
+
+ int width()
+ {
+ return x2 - x1 + 1;
+ };
+
+ int height()
+ {
+ return y2 - y1 + 1;
+ };
+
+ bool operator != (const sDxr3SpuRect r) const
+ {
+ return r.x1 != x1 || r.y1 != y1 || r.x2 != x2 || r.y2 != y2;
+ };
+};
+
+// ==================================
+class cDxr3SpuPalette
+{
+private:
+ uint32_t palette[16];
+
+public:
+ void setPalette(const uint32_t * pal);
+ uint32_t getColor(uint8_t idx, uint8_t trans) const;
+};
// ==================================
-//! spu decoder
-/*!
- cDxr3SpuDecoder is used to show DVD
- navigation and subtitles.
- We make here use of the DVD-Functions
- of the dxr3 driver/card.
-*/
-class cDxr3SpuDecoder : public cSpuDecoder
+class cDxr3SpuBitmap
+{
+private:
+ sDxr3SpuRect bmpsize;
+ sDxr3SpuRect minsize[4];
+ uint8_t *bmp;
+
+ void putPixel(int xp, int yp, int len, uint8_t colorid);
+ void putFieldData(int field, uint8_t * data, uint8_t * endp);
+
+public:
+ cDxr3SpuBitmap(sDxr3SpuRect size, uint8_t * fodd, uint8_t * eodd, uint8_t * feven, uint8_t * eeven);
+ ~cDxr3SpuBitmap();
+
+ bool getMinSize(const aDxr3SpuPalDescr paldescr, sDxr3SpuRect & size) const;
+ cBitmap *getBitmap(const aDxr3SpuPalDescr paldescr, const cDxr3SpuPalette & pal, sDxr3SpuRect & size) const;
+};
+
+// ==================================
+class cDxr3SpuDecoder : public cSpuDecoder
{
public:
- cDxr3SpuDecoder();
- ~cDxr3SpuDecoder() {}
-
- int setTime(uint32_t pts);
-
- void setScaleMode(cSpuDecoder::eScaleMode ScaleMode);
- void setPalette(uint32_t * pal);
- void setHighlight(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint32_t palette);
- void clearHighlight();
- void Empty();
- void Hide();
- void Draw();
- bool IsVisible() { return m_visible; }
-#if VDRVERSNUM >= 10318
- void processSPU(uint32_t pts, uint8_t * buf, bool AllowedShow);
-#else
- void processSPU(uint32_t pts, uint8_t * buf);
-#endif
+ cDxr3SpuDecoder();
+ ~cDxr3SpuDecoder();
+
+ int setTime(uint32_t pts);
+
+ void setScaleMode(cSpuDecoder::eScaleMode ScaleMode);
+ void setPalette(uint32_t * pal);
+ void setHighlight(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint32_t palette);
+ void clearHighlight();
+ void Empty();
+ void processSPU(uint32_t pts, uint8_t * buf);
+
+ #if VDRVERSNUM >= 10311
+ void Hide();
+ void Draw();
+ bool IsVisible() { return osd != NULL; }
+ #endif
private:
- cDxr3Interface& m_Interface; ///< interface to dxr3 driver
- bool m_visible; ///< is anything visible (nav, osd, subtilte)
-};
-
+ cOsd * osd;
+
+ // processing state
+ uint8_t *spu;
+ uint32_t spupts;
+ bool clean;
+ bool ready;
+
+ enum spFlag { spNONE, spHIDE, spSHOW, spMENU };
+ spFlag state;
+
+ cSpuDecoder::eScaleMode scaleMode;
+
+ // highligh area
+ bool highlight;
+ sDxr3SpuRect hlpsize;
+ aDxr3SpuPalDescr hlpDescr;
+
+ // palette
+ cDxr3SpuPalette palette;
+
+ // spu info's
+ sDxr3SpuRect size;
+ aDxr3SpuPalDescr palDescr;
+
+ uint16_t DCSQ_offset;
+ uint16_t prev_DCSQ_offset;
+
+ cDxr3SpuBitmap *spubmp;
+
+ int cmdOffs() { return ((spu[2] << 8) | spu[3]); }
+ int spuSize() { return ((spu[0] << 8) | spu[1]); }
+
+ int ScaleYcoord(int value);
+ int ScaleYres(int value);
+ void DrawBmp(sDxr3SpuRect & size, cBitmap * bmp);
+};
+
+// ==================================
+inline uint32_t cDxr3SpuPalette::getColor(uint8_t idx, uint8_t trans) const
+{
+ uint8_t t = trans == 0x0f ? 0xff : trans << 4;
+ return palette[idx] | (t << 24);
+}
+
#endif /*_DXR3SPUDECODER_H_*/
diff --git a/dxr3unixserversocket.c b/dxr3unixserversocket.c
index 8153515..4af5d64 100644
--- a/dxr3unixserversocket.c
+++ b/dxr3unixserversocket.c
@@ -32,12 +32,13 @@
#include "dxr3interface.h"
#include "dxr3log.h"
+using namespace std;
+
#ifndef SOCKET_CHMOD
#define SOCKET_CHMOD 0660
#endif
// ==================================
-//! constructor
cDxr3UnixServerSocket::cDxr3UnixServerSocket(const char* pFileName, int backlog)
{
m_bConnected = false;
@@ -145,12 +146,12 @@ void cDxr3StartStopSocket::SendStatus()
{
if (cDxr3Interface::Instance().IsExternalReleased())
{
- std::string res("CloseDxr3DeviceRsp\n");
+ string res("CloseDxr3DeviceRsp\n");
write(m_fdConnectionSocket, res.c_str(), res.size());
}
else
{
- std::string res("OpenDxr3DeviceRsp\n");
+ string res("OpenDxr3DeviceRsp\n");
write(m_fdConnectionSocket, res.c_str(), res.size());
}
}
@@ -160,26 +161,26 @@ void cDxr3StartStopSocket::ProcessMessage(void)
{
cLog::Instance() << "cDxr3StartStopSocket::ProcessMessage Rec: " << (const char*) m_msg << "\n";
- if (std::string((const char*)m_msg) == std::string("OpenDxr3DeviceCmd"))
+ if (string((const char*)m_msg) == string("OpenDxr3DeviceCmd"))
{
cDxr3Interface::Instance().ExternalReopenDevices();
SendStatus();
}
- else if (std::string((const char*)m_msg) == std::string("CloseDxr3DeviceCmd"))
+ else if (string((const char*)m_msg) == string("CloseDxr3DeviceCmd"))
{
cDxr3Interface::Instance().ExternalReleaseDevices();
SendStatus();
}
- else if (std::string((const char*)m_msg) == std::string("StatusDxr3DeviceCmd"))
+ else if (string((const char*)m_msg) == string("StatusDxr3DeviceCmd"))
{
SendStatus();
}
- else if (std::string((const char *)m_msg) == std::string("SaveDxr3DeviceCmd"))
+ else if (string((const char *)m_msg) == string("SaveDxr3DeviceCmd"))
{
m_bSavedState = cDxr3Interface::Instance().IsExternalReleased();
SendStatus();
}
- else if (std::string((const char *)m_msg) == std::string("RestoreDxr3DeviceCmd"))
+ else if (string((const char *)m_msg) == string("RestoreDxr3DeviceCmd"))
{
if (m_bSavedState)
{
@@ -193,7 +194,7 @@ void cDxr3StartStopSocket::ProcessMessage(void)
}
else
{
- std::string res("Error\n");
+ string res("Error\n");
write(m_fdConnectionSocket, res.c_str(), res.size());
}
}
diff --git a/dxr3vdrincludes.h b/dxr3vdrincludes.h
index 42344d1..c995461 100644
--- a/dxr3vdrincludes.h
+++ b/dxr3vdrincludes.h
@@ -26,6 +26,7 @@
#include <string>
#include <algorithm>
#include <vector>
+using namespace std;
#ifndef __STL_CONFIG_H
#define __STL_CONFIG_H