summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dxr3.c11
-rw-r--r--dxr3audio-alsa.c6
-rw-r--r--dxr3audio-oss.c6
-rw-r--r--dxr3device.c53
-rw-r--r--dxr3device.h3
-rw-r--r--dxr3interface.c6
6 files changed, 84 insertions, 1 deletions
diff --git a/dxr3.c b/dxr3.c
index 1247906..103e72e 100644
--- a/dxr3.c
+++ b/dxr3.c
@@ -254,6 +254,11 @@ const char **cPluginDxr3::SVDRPHelpPages(void)
" Switch to digital PCM audio output.",
"SAC3\n"
" Switch to digital AC3 audio output.",
+ "DON\n"
+ " Start plugin - take control of dxr3 card.",
+ "DOF\n"
+ " Stop plugin - release used dxr3 card so it can be used by e.g. MMS.",
+
NULL
};
@@ -291,6 +296,12 @@ cString cPluginDxr3::SVDRPCommand(const char *Command, const char *Option,
device->getAudioOutput()->setAudioMode(iAudio::Ac3);
return "Switched to digital AC3 audio output";
}
+ if (!strcasecmp(Command, "DON")) {
+ device->turnPlugin(true);
+ }
+ if (!strcasecmp(Command, "DOF")) {
+ device->turnPlugin(false);
+ }
return NULL;
}
diff --git a/dxr3audio-alsa.c b/dxr3audio-alsa.c
index cb97494..d327661 100644
--- a/dxr3audio-alsa.c
+++ b/dxr3audio-alsa.c
@@ -65,6 +65,9 @@ void cAudioAlsa::releaseDevice()
void cAudioAlsa::setup(const SampleContext& ctx)
{
+ if (!open)
+ return;
+
// look if ctx is different
if (curContext.channels == ctx.channels && curContext.samplerate == ctx.samplerate) {
return;
@@ -186,6 +189,9 @@ void cAudioAlsa::setup(const SampleContext& ctx)
void cAudioAlsa::write(uchar* data, size_t size)
{
+ if (!open)
+ return;
+
snd_pcm_uframes_t frames = size / bytesFrame;
if (frames == 0) {
diff --git a/dxr3audio-oss.c b/dxr3audio-oss.c
index c1bdc52..ae6cbea 100644
--- a/dxr3audio-oss.c
+++ b/dxr3audio-oss.c
@@ -61,6 +61,9 @@ void cAudioOss::releaseDevice()
void cAudioOss::setup(const SampleContext& ctx)
{
+ if (!open)
+ return;
+
// set sample rate
if (curContext.samplerate != ctx.samplerate) {
dsyslog("[dxr3-audio-oss] changing samplerate to %d (old %d) ", ctx.samplerate, curContext.samplerate);
@@ -78,6 +81,9 @@ void cAudioOss::setup(const SampleContext& ctx)
void cAudioOss::write(uchar* data, size_t size)
{
+ if (!open)
+ return;
+
size_t ret = WriteAllOrNothing(fd, data, size, 1000, 10);
if (ret != size) {
diff --git a/dxr3device.c b/dxr3device.c
index 319f742..5490a72 100644
--- a/dxr3device.c
+++ b/dxr3device.c
@@ -32,7 +32,7 @@
// ==================================
//! constructor
-cDxr3Device::cDxr3Device()
+cDxr3Device::cDxr3Device() : pluginOn(true)
{
m_spuDecoder = NULL;
@@ -178,6 +178,10 @@ bool cDxr3Device::Poll(cPoller &Poller, int TimeoutMs)
//! 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);
}
@@ -185,6 +189,10 @@ int cDxr3Device::PlayVideo(const uchar *Data, int 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 (isAc3 && !audioOut->isAudioModeAC3())
@@ -235,6 +243,49 @@ cSpuDecoder *cDxr3Device::GetSpuDecoder()
return m_spuDecoder;
}
+void cDxr3Device::turnPlugin(bool on)
+{
+ // we have support for a very unique thing.
+ // it is possible to release the current
+ // used dxr3 device and make it so usable
+ // for other programs.
+ // and the unique thing is that VDR can run
+ // without interrupting it.
+
+
+ if (on) {
+
+ // check if we already at 'on' state
+ if (pluginOn) {
+ return;
+ }
+
+ // get full control over device
+ cDxr3Interface::instance()->ClaimDevices();
+ audioOut->openDevice();
+
+ // enable pes packet processing
+ pluginOn = true;
+
+ } else {
+
+ // check if we already at 'off' state
+ if (!pluginOn) {
+ return;
+ }
+
+ // clear buffer
+ m_DemuxDevice.Clear();
+
+ // release device and give control to somebody else
+ cDxr3Interface::instance()->ReleaseDevices();
+ audioOut->releaseDevice();
+
+ // disable pes packet processing
+ pluginOn = false;
+ }
+}
+
// Local variables:
// mode: c++
// c-file-style: "stroustrup"
diff --git a/dxr3device.h b/dxr3device.h
index c816e8b..ebdbcda 100644
--- a/dxr3device.h
+++ b/dxr3device.h
@@ -76,11 +76,14 @@ public:
iAudio *getAudioOutput() const { return audioOut; }
+ void turnPlugin(bool on);
+
private:
ePlayMode m_PlayMode;
cDxr3DemuxDevice m_DemuxDevice;
cDxr3SpuDecoder* m_spuDecoder;
iAudio *audioOut;
+ bool pluginOn;
};
#endif /*_DXR3_DEVICE_H_*/
diff --git a/dxr3interface.c b/dxr3interface.c
index c9688ad..99684ad 100644
--- a/dxr3interface.c
+++ b/dxr3interface.c
@@ -264,6 +264,12 @@ void cDxr3Interface::SetAspectRatio(uint32_t ratio)
//! set playing mode and start sync engine
void cDxr3Interface::SetPlayMode()
{
+ // this is the case, when SVDRP command DOF was used and
+ // should be ignored.
+ if (m_fdControl == -1) {
+ return;
+ }
+
em8300_register_t reg;
int ioval;