diff options
-rw-r--r-- | HISTORY | 1 | ||||
-rw-r--r-- | dxr3syncbuffer.c | 40 |
2 files changed, 29 insertions, 12 deletions
@@ -240,6 +240,7 @@ NOTE: I havent found time to include all of the languages, will be done in pre2 - dxr3memcpy.c/h: should now compile on alpha and powerpc - added support for VDR 1.3.13 and later - thanks to Luca Olivetti and others - removed -lz from makefile +- compiles now with 3.4.x gcc's - use $CXX for generating dependencies instead of hardcoded g++ - added descriptions to audio and video output threads - fixed audio and video thread deletion in demux device destructor diff --git a/dxr3syncbuffer.c b/dxr3syncbuffer.c index 2b6e097..e7544ec 100644 --- a/dxr3syncbuffer.c +++ b/dxr3syncbuffer.c @@ -32,15 +32,9 @@ const int DXR3_MAX_VIDEO_FRAME_LENGTH = 4096; const int DXR3_MAX_AUDIO_FRAME_LENGTH = 4096; // ================================== -cFixedLengthFrame::cFixedLengthFrame(uint32_t length) : -m_count(0), m_length(length), m_pts(0), m_type(ftUnknown) { - - m_pData = new uint8_t[length]; - if (!m_pData) - { - cLog::Instance() << "Failed to allocate memory in cFixedLengthFrame (m_pData) - will stop now"; - exit(1); - } +//! constructor +cFixedLengthFrame::cFixedLengthFrame() : +m_count(0), m_length(0), m_pts(0), m_type(ftUnknown) { m_audioChannelCount = UNKNOWN_CHANNEL_COUNT; m_audioDataRate = UNKNOWN_DATA_RATE; @@ -57,6 +51,21 @@ cFixedLengthFrame::~cFixedLengthFrame() } // ================================== +// ! setup our frame +void cFixedLengthFrame::Init(uint32_t lenght) +{ + m_length = lenght; + m_pData = new uint8_t[lenght]; + + // allocation ok? + if (!m_pData) + { + cLog::Instance() << "Failed to allocate memory in cFixedLengthFrame (m_pData) - will stop now"; + exit(1); + } +} + +// ================================== void cFixedLengthFrame::CopyFrame(const uint8_t* pStart, int length, uint32_t pts, eFrameType type) { if (length > m_length) @@ -100,19 +109,26 @@ uint32_t cFixedLengthFrame::m_staticAudioChannelCount = 0; uint32_t cFixedLengthFrame::m_staticAudioDataRate = 0; - - // ================================== +//! constructor cDxr3SyncBuffer::cDxr3SyncBuffer(int frameCount, int frameLength, cDxr3Interface& dxr3Device) : cRingBuffer(frameCount, true), m_dxr3Device(dxr3Device) { - m_pBuffer = new cFixedLengthFrame[frameCount](frameLength); + m_pBuffer = new cFixedLengthFrame[frameCount]; + // got we a valid m_pBuffer? if (!m_pBuffer) { cLog::Instance() << "Failed to allocate memory in cDxr3SyncBuffer (m_pBuffer) - will stop now"; 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; |