diff options
author | Christian Gmeiner <christian.gmeiner@gmail.com> | 2009-03-28 12:20:45 +0100 |
---|---|---|
committer | Christian Gmeiner <christian.gmeiner@gmail.com> | 2009-03-28 12:20:45 +0100 |
commit | ecc3dd09be579348e8a17e968415fecaaed47d84 (patch) | |
tree | 7cbc2db0ee8634c76ab208e403bed2ee67d3b308 | |
parent | 7cc46900f0a8795bcd586eec983d7172ebe439b4 (diff) | |
download | vdr-plugin-dxr3-ecc3dd09be579348e8a17e968415fecaaed47d84.tar.gz vdr-plugin-dxr3-ecc3dd09be579348e8a17e968415fecaaed47d84.tar.bz2 |
rework pmExtern_THIS_SHOULD_BE_AVOIDED playmode
This commit removes all checks if the device is external released as it
is not possible/wanted to set playmode to pmExtern_THIS_SHOULD_BE_AVOIDED and
call play methods of device class.
Also I removed DON and DOF svdr commands, as
in my opinion these two commands are not useful at all. If somebody who
needs them give me an example usage for these commands, I will bring them
back.
-rw-r--r-- | dxr3.c | 12 | ||||
-rw-r--r-- | dxr3device.c | 42 | ||||
-rw-r--r-- | dxr3interface.c | 161 | ||||
-rw-r--r-- | dxr3interface.h | 10 | ||||
-rw-r--r-- | dxr3output-audio.c | 3 | ||||
-rw-r--r-- | dxr3output-video.c | 7 |
6 files changed, 63 insertions, 172 deletions
@@ -245,10 +245,6 @@ cOsdObject* cPluginDxr3::MainMenuAction() const char **cPluginDxr3::SVDRPHelpPages(void) { static const char *HelpPages[] = { - "DON\n" - " Start DXR3.", - "DOF\n" - " Stop DXR3.", "SAT\n" " Set saturation (0..999).", "CON\n" @@ -271,14 +267,6 @@ const char **cPluginDxr3::SVDRPHelpPages(void) cString cPluginDxr3::SVDRPCommand(const char *Command, const char *Option, int &ReplyCode) { - if (!strcasecmp(Command, "DON")) { - cDxr3Interface::Instance().ExternalReopenDevices(); - return "DXR3 started"; - } - if (!strcasecmp(Command, "DOF")) { - cDxr3Interface::Instance().ExternalReleaseDevices(); - return "DXR3 stopped"; - } if (!strcasecmp(Command, "BRI")) { cDxr3Interface::Instance().SetBrightness(atoi(Option)); return cString::sprintf("Brightness set to %d", diff --git a/dxr3device.c b/dxr3device.c index 9103b5c..2d3c449 100644 --- a/dxr3device.c +++ b/dxr3device.c @@ -82,32 +82,30 @@ bool cDxr3Device::CanReplay() const // ================================== bool cDxr3Device::SetPlayMode(ePlayMode PlayMode) { - if (PlayMode == pmExtern_THIS_SHOULD_BE_AVOIDED) { - Tools::WriteInfoToOsd(tr("DXR3: releasing devices")); - cDxr3Interface::Instance().ExternalReleaseDevices(); - audioOut->releaseDevice(); - } else { - cDxr3Interface::Instance().ExternalReopenDevices(); + if (PlayMode != pmExtern_THIS_SHOULD_BE_AVOIDED) { + cDxr3Interface::Instance().ClaimDevices(); audioOut->openDevice(); } - if (PlayMode == pmAudioOnlyBlack) - { - m_PlayMode = pmAudioOnly; - } - else - { - m_PlayMode = PlayMode; - } + dsyslog("setting playmode %d", PlayMode); - if (m_PlayMode == pmAudioVideo) - { - m_DemuxDevice.SetReplayMode(); - } + switch (PlayMode) { + case pmExtern_THIS_SHOULD_BE_AVOIDED: + Tools::WriteInfoToOsd(tr("DXR3: releasing devices")); + cDxr3Interface::Instance().ReleaseDevices(); + audioOut->releaseDevice(); + break; - if (m_PlayMode == pmNone) - { - m_DemuxDevice.Stop(); + case pmNone: + //m_DemuxDevice.Stop(); + break; + + case pmAudioVideo: + case pmAudioOnly: + case pmAudioOnlyBlack: + case pmVideoOnly: + + m_PlayMode = PlayMode; } return true; @@ -196,7 +194,7 @@ 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) || cDxr3Interface::Instance().IsExternalReleased()) { + m_DemuxDevice.GetTrickState() == DXR3_FREEZE)) { cCondWait::SleepMs(TimeoutMs); return false; } diff --git a/dxr3interface.c b/dxr3interface.c index fb3b174..3621773 100644 --- a/dxr3interface.c +++ b/dxr3interface.c @@ -73,21 +73,13 @@ int cDxr3Interface::OssSetPlayMode(uint32_t mode) // ================================== void cDxr3Interface::SetSysClock(uint32_t scr) { - if (!m_ExternalReleased) - { m_pClock->SetSysClock(scr); - } } // ================================== uint32_t cDxr3Interface::GetSysClock() const { - uint32_t ret = 0; - if (!m_ExternalReleased) - { - ret = m_pClock->GetSysClock(); - } - return ret; + return m_pClock->GetSysClock(); } // ================================== @@ -99,17 +91,12 @@ int64_t cDxr3Interface::GetPts() // ================================== void cDxr3Interface::SetPts(uint32_t pts) { - if (!m_ExternalReleased) - { m_pClock->SetPts(pts); - } } // ================================== void cDxr3Interface::SetSpuPts(uint32_t pts) { - if (!m_ExternalReleased) - { pts = pts >> 1; if (pts > m_pClock->GetSysClock() && @@ -117,7 +104,6 @@ void cDxr3Interface::SetSpuPts(uint32_t pts) { m_pClock->SetSpuPts(pts); } - } } // state changes @@ -129,7 +115,7 @@ void cDxr3Interface::EnableSPU() Lock(); - if (!m_ExternalReleased && m_spuMode != ioval) + if (m_spuMode != ioval) { if (ioctl(m_fdControl, EM8300_IOCTL_SET_SPUMODE, &ioval) == -1) { @@ -152,7 +138,7 @@ void cDxr3Interface::DisableSPU() Lock(); - if (!m_ExternalReleased && m_spuMode != ioval) + if (m_spuMode != ioval) { if (ioctl(m_fdControl, EM8300_IOCTL_SET_SPUMODE, &ioval) == -1) { @@ -185,13 +171,10 @@ uint32_t cDxr3Interface::GetAspectRatio() const Lock(); - if (!m_ExternalReleased) - { if (ioctl(m_fdControl, EM8300_IOCTL_GET_ASPECTRATIO, &ioval) == -1) { esyslog("dxr3: unable to get aspect ratio: %m"); } - } Unlock(); @@ -210,7 +193,7 @@ void cDxr3Interface::SetAspectRatio(uint32_t ratio) if (cDxr3ConfigData::Instance().GetForceLetterBox()) ratio = EM8300_ASPECTRATIO_16_9; - if (!m_ExternalReleased && ratio != UNKNOWN_ASPECT_RATIO) + if (ratio != UNKNOWN_ASPECT_RATIO) { if (ratio != m_aspectRatio && requestCounter > 50) { @@ -273,8 +256,6 @@ void cDxr3Interface::SetPlayMode() Lock(); - if (!m_ExternalReleased) - { ioval = EM8300_SUBDEVICE_AUDIO; ioctl(m_fdControl, EM8300_IOCTL_FLUSH, &ioval); fsync(m_fdVideo); @@ -292,7 +273,6 @@ void cDxr3Interface::SetPlayMode() { esyslog("dxr3: unable to start em8300 sync engine: %m"); } - } Unlock(); } @@ -304,13 +284,10 @@ void cDxr3Interface::Pause() Lock(); - if (!m_ExternalReleased) - { if (ioctl(m_fdControl, EM8300_IOCTL_SET_PLAYMODE, &ioval) == -1) { esyslog("dxr3: unable to set pause mode: %m"); } - } Unlock(); } @@ -321,13 +298,10 @@ void cDxr3Interface::SingleStep() Lock(); - if (!m_ExternalReleased) - { if (ioctl(m_fdControl, EM8300_IOCTL_SET_PLAYMODE, &ioval) == -1) { esyslog("dxr3: unable to set single-step mode: %m"); } - } Unlock(); } @@ -342,28 +316,25 @@ void cDxr3Interface::PlayVideoFrame(cFixedLengthFrame* pFrame, int times) { Lock(); - if (!m_ExternalReleased) + for (int i = 0; i < times; i++) { - for (int i = 0; i < times; i++) - { - if (times > 1) - { - dsyslog("dxr3: playvideoframe: times=%d", times); - } + if (times > 1) + { + dsyslog("dxr3: playvideoframe: times=%d", times); + } - while (written < pFrame->GetCount() && count >= 0) + while (written < pFrame->GetCount() && count >= 0) + { + if ((count = write(m_fdVideo, pFrame->GetData() + written, pFrame->GetCount() - written)) == -1) { - if ((count = write(m_fdVideo, pFrame->GetData() + written, pFrame->GetCount() - written)) == -1) - { - // an error occured - Resuscitation(); - } - written += count; + // an error occured + Resuscitation(); } + written += count; + } - // reset - written = 0; - } + // reset + written = 0; } Unlock(); @@ -380,14 +351,11 @@ void cDxr3Interface::PlayVideoFrame(const uint8_t* pBuf, int length, int times) { Lock(); - if (!m_ExternalReleased) - { for (int i = 0; i < times; i++) { if (write(m_fdVideo, pBuf, length) == -1) Resuscitation(); } - } Unlock(); } @@ -395,6 +363,11 @@ void cDxr3Interface::PlayVideoFrame(const uint8_t* pBuf, int length, int times) // ================================== void cDxr3Interface::ClaimDevices() { + // devices already open + if (m_fdControl > -1 && m_fdVideo > -1 && m_fdSpu > -1) { + return; + } + // open control stream m_fdControl = Dxr3Open(DEV_DXR3_CONT, O_WRONLY | O_SYNC); if (m_fdControl == -1) @@ -424,13 +397,15 @@ void cDxr3Interface::ClaimDevices() if (!m_pClock) { esyslog("dxr3: fatal: unable to allocate memory for em8300 clock"); + close(m_fdControl); + close(m_fdVideo); + close(m_fdSpu); exit(1); } // set default values m_AudioActive = false; m_VideoActive = false; - m_ExternalReleased = false; m_horizontal = 720; m_vertical = 576; m_aspectRatio = UNKNOWN_ASPECT_RATIO; @@ -456,76 +431,26 @@ void cDxr3Interface::ClaimDevices() // ================================== void cDxr3Interface::ReleaseDevices() { - if (m_fdControl > -1) - close(m_fdControl); - m_fdControl = -1; + if (m_fdControl > -1) { + close(m_fdControl); + m_fdControl = -1; + } - if (m_fdVideo > -1) - close(m_fdVideo); - m_fdVideo = -1; + if (m_fdVideo > -1) { + close(m_fdVideo); + m_fdVideo = -1; + } - if (m_fdSpu > -1) - close(m_fdSpu); - m_fdSpu = -1; + if (m_fdSpu > -1) { + close(m_fdSpu); + m_fdSpu = -1; + } m_aspectRatio = UNKNOWN_ASPECT_RATIO; - m_ExternalReleased = true; delete m_pClock; m_pClock = NULL; } -// external device access -// ================================== -//! release devices, so mplayer-plugin, for instance, -//! can access the dxr3 -void cDxr3Interface::ExternalReleaseDevices() -{ - Lock(); - if (!m_ExternalReleased) - ReleaseDevices(); - Unlock(); -} - -// ================================== -//! reopen devices for using in the dxr3 plugin -void cDxr3Interface::ExternalReopenDevices() -{ - Lock(); - - if (m_ExternalReleased) - { - // open control stream - m_fdControl = Dxr3Open(DEV_DXR3_CONT, O_WRONLY | O_SYNC); - - // open 'multimedia' streams - m_fdVideo = Dxr3Open(DEV_DXR3_VIDEO, O_WRONLY | O_SYNC); - m_fdSpu = Dxr3Open(DEV_DXR3_OSD, O_WRONLY | O_SYNC); - - if (m_fdControl == -1 || m_fdVideo == -1 || - m_fdSpu == -1) - { - ExternalReleaseDevices(); - } - else - { - m_pClock = new cDxr3SysClock(m_fdControl, m_fdVideo, m_fdSpu); - if (!m_pClock) - { - esyslog("dxr3: fatal: failed to allocate memory for em8300" - " system clock in reopen"); - exit(1); - } - - m_ExternalReleased = false; - } - - Resuscitation(); - } - - Unlock(); -} - - // tools // ================================== //! play black frame on tv @@ -536,14 +461,12 @@ void cDxr3Interface::PlayBlackFrame() Lock(); - if (!m_ExternalReleased) - { for (int i = 0; i < 3; i++) { if (write(m_fdVideo, blackframe, blackframeLength) == -1) Resuscitation(); } - } + m_horizontal = 720; m_vertical = 576; @@ -726,11 +649,8 @@ void cDxr3Interface::ClearOsd() ed.data[0]= i >> 8; ed.data[1]= i & 0xff; - if (!m_ExternalReleased) - { WriteSpu((const uint8_t*) &ed, (int) ed.count); ClearButton(); - } } // ================================== @@ -738,11 +658,8 @@ void cDxr3Interface::WriteSpu(const uint8_t* pBuf, int length) { Lock(); - if (!m_ExternalReleased) - { if (write(m_fdSpu, pBuf, length) == -1) Resuscitation(); - } Unlock(); } diff --git a/dxr3interface.h b/dxr3interface.h index b7b6dc0..a147a6c 100644 --- a/dxr3interface.h +++ b/dxr3interface.h @@ -128,10 +128,9 @@ public: void PlayVideoFrame(cFixedLengthFrame* pFrame, int times = 1); void PlayVideoFrame(const uint8_t* pBuf, int length, int times = 1); - // external device access - void ExternalReleaseDevices(); - void ExternalReopenDevices(); - bool IsExternalReleased() const { return m_ExternalReleased; } + // device access + void ClaimDevices(); + void ReleaseDevices(); // tools void PlayBlackFrame(); @@ -171,7 +170,6 @@ private: uint32_t m_horizontal; ///< horizontal size of current videostream uint32_t m_vertical; ///< vertical size of current videostream uint32_t m_spuMode; - bool m_ExternalReleased; ///< is dxr3 used by e.g. mplayer? bool m_AudioActive; ///< is audio active? bool m_VideoActive; ///< is video active? @@ -180,8 +178,6 @@ private: void UploadMicroCode(); void ConfigureDevice(); - void ClaimDevices(); - void ReleaseDevices(); void Resuscitation(); protected: diff --git a/dxr3output-audio.c b/dxr3output-audio.c index b664737..0d2e11d 100644 --- a/dxr3output-audio.c +++ b/dxr3output-audio.c @@ -52,8 +52,7 @@ void cDxr3AudioOutThread::Action() if (pNext) pts = pNext->GetPts(); - if ((pts && abs((int)pts-(int)SCR) > 30000) || - m_dxr3Device.IsExternalReleased()) + if ((pts && abs((int)pts-(int)SCR) > 30000)) { m_buffer.Clear(); m_bNeedResync = true; diff --git a/dxr3output-video.c b/dxr3output-video.c index e306df7..09c3af8 100644 --- a/dxr3output-video.c +++ b/dxr3output-video.c @@ -86,13 +86,6 @@ void cDxr3VideoOutThread::Action() } } - - if (m_dxr3Device.IsExternalReleased()) - { - m_bNeedResync = true; - m_buffer.Clear(); - } - if ((pts > SCR && abs((int)pts - (int)SCR) > 7500 )) { cCondWait::SleepMs(10); |