diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | dxr3interface.c | 62 | ||||
-rw-r--r-- | dxr3interface.h | 7 | ||||
-rw-r--r-- | dxr3sysclock.c | 78 | ||||
-rw-r--r-- | dxr3sysclock.h | 63 |
5 files changed, 36 insertions, 176 deletions
@@ -70,7 +70,7 @@ DEFINES += -DUSE_XINE_SCALER ### The object files (add further files here): -OBJS = $(PLUGIN).o dxr3multichannelaudio.o dxr3sysclock.o dxr3colormanager.o \ +OBJS = $(PLUGIN).o dxr3multichannelaudio.o dxr3colormanager.o \ dxr3syncbuffer.o dxr3audiodecoder.o dxr3blackframe.o dxr3audio.o \ dxr3pesframe.o dxr3demuxdevice.o dxr3configdata.o \ dxr3interface_spu_encoder.o dxr3interface.o dxr3device.o \ diff --git a/dxr3interface.c b/dxr3interface.c index ffbd89c..a6b69bd 100644 --- a/dxr3interface.c +++ b/dxr3interface.c @@ -69,37 +69,54 @@ int cDxr3Interface::OssSetPlayMode(uint32_t mode) // ================================== void cDxr3Interface::SetSysClock(uint32_t scr) { - m_pClock->SetSysClock(scr); -} + uint32_t sc; -// ================================== -uint32_t cDxr3Interface::GetSysClock() const -{ - return m_pClock->GetSysClock(); + Lock(); + ioctl(m_fdControl, EM8300_IOCTL_SCR_GET, &sc); + m_offset = scr - sc; + Unlock(); } // ================================== -int64_t cDxr3Interface::GetPts() +uint32_t cDxr3Interface::GetSysClock() { - return m_lastSeenPts << 1; + uint32_t sc; + uint32_t retval; + + Lock(); + ioctl(m_fdControl, EM8300_IOCTL_SCR_GET, &sc); + retval = sc + m_offset; + Unlock(); + + return retval; } // ================================== void cDxr3Interface::SetPts(uint32_t pts) { - m_pClock->SetPts(pts); + uint32_t newPts = 0; + + Lock(); + newPts = pts - m_offset; + ioctl(m_fdVideo, EM8300_IOCTL_VIDEO_SETPTS, &newPts); + Unlock(); } // ================================== void cDxr3Interface::SetSpuPts(uint32_t pts) { - pts = pts >> 1; + uint32_t newPts = 0; - if (pts > m_pClock->GetSysClock() && - pts - m_pClock->GetSysClock() < 100000) - { - m_pClock->SetSpuPts(pts); - } + Lock(); + newPts = (pts - m_offset) << 1; // fix for DVD subtitles + ioctl(m_fdSpu, EM8300_IOCTL_SPU_SETPTS, &newPts); + Unlock(); +} + +// ================================== +int64_t cDxr3Interface::GetPts() +{ + return m_lastSeenPts << 1; } // state changes @@ -417,19 +434,6 @@ void cDxr3Interface::ClaimDevices() exit(1); } - // create clock - m_pClock = new cDxr3SysClock(m_fdControl, m_fdVideo, m_fdSpu); - - // everything ok? - 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; @@ -474,8 +478,6 @@ void cDxr3Interface::ReleaseDevices() } m_aspectRatio = UNKNOWN_ASPECT_RATIO; - delete m_pClock; - m_pClock = NULL; } // tools diff --git a/dxr3interface.h b/dxr3interface.h index 66a380f..9a87576 100644 --- a/dxr3interface.h +++ b/dxr3interface.h @@ -29,7 +29,6 @@ #include <vdr/tools.h> #include "dxr3configdata.h" -#include "dxr3sysclock.h" // ================================== class cFixedLengthFrame; @@ -77,7 +76,7 @@ public: // clock void SetSysClock(uint32_t scr); - uint32_t GetSysClock() const; + uint32_t GetSysClock(); void SetPts(uint32_t pts); void SetSpuPts(uint32_t pts); int64_t GetPts(); @@ -160,8 +159,8 @@ private: int m_fdSpu; ///< filehandle for spu fifo of dxr3 card uint32_t m_lastSeenPts; - // dxr3 clock - cDxr3SysClock* m_pClock; ///< clock used for sync + // clock + uint32_t m_offset; uint32_t m_aspectRatio; ///< current used aspect ratio uint32_t m_horizontal; ///< horizontal size of current videostream diff --git a/dxr3sysclock.c b/dxr3sysclock.c deleted file mode 100644 index 1e581e3..0000000 --- a/dxr3sysclock.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * dxr3sysclock.c - * - * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include <sys/ioctl.h> -#include "dxr3sysclock.h" - -// ================================== -void cDxr3SysClock::SetSysClock(uint32_t scr) -{ - uint32_t sc; - - mutex.Lock(); - ioctl(m_fdcontrol, EM8300_IOCTL_SCR_GET, &sc); - m_offset = scr - sc; - mutex.Unlock(); -} - -// ================================== -uint32_t cDxr3SysClock::GetSysClock(void) -{ - uint32_t sc; - uint32_t retval; - - mutex.Lock(); - ioctl(m_fdcontrol, EM8300_IOCTL_SCR_GET, &sc); - retval = sc + m_offset; - mutex.Unlock(); - - return retval; -} - -// ================================== -void cDxr3SysClock::SetPts(uint32_t pts) -{ - uint32_t newPts = 0; - - mutex.Lock(); - newPts = pts - m_offset; - ioctl(m_fdvideo, EM8300_IOCTL_VIDEO_SETPTS, &newPts); - mutex.Unlock(); -} - -// ================================== -void cDxr3SysClock::SetSpuPts(uint32_t pts) -{ - uint32_t newPts = 0; - - mutex.Lock(); - newPts = (pts - m_offset) << 1; // fix for DVD subtitles - ioctl(m_fdspu, EM8300_IOCTL_SPU_SETPTS, &newPts); - mutex.Unlock(); -} - -// 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/dxr3sysclock.h b/dxr3sysclock.h deleted file mode 100644 index 12d4946..0000000 --- a/dxr3sysclock.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * dxr3sysclock.h - * - * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef _DXR3_SYSCLOCK_H_ -#define _DXR3_SYSCLOCK_H_ - -#include <stdint.h> -#include <linux/em8300.h> -#include <vdr/thread.h> -#include "Uncopyable.h" - -// ================================== -// work with dxr3's clock -class cDxr3SysClock : private Uncopyable { -public: - cDxr3SysClock(int fd_control, int fd_video, int fd_spu): - m_fdcontrol(fd_control), - m_fdvideo(fd_video), - m_fdspu(fd_spu), - m_offset(0) {}; - - virtual ~cDxr3SysClock() {}; - - void SetSysClock(uint32_t scr); - uint32_t GetSysClock(void); - void SetPts(uint32_t pts); - void SetSpuPts(uint32_t pts); - -private: - int m_fdcontrol; - int m_fdvideo; - int m_fdspu; - uint32_t m_offset; - cMutex mutex; -}; - -#endif /*_DXR3_SYSCLOCK_H_*/ - -// Local variables: -// mode: c++ -// c-file-style: "stroustrup" -// c-file-offsets: ((inline-open . 0)) -// tab-width: 4; -// indent-tabs-mode: nil -// End: |