summaryrefslogtreecommitdiff
path: root/dxr3syncbuffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'dxr3syncbuffer.c')
-rw-r--r--dxr3syncbuffer.c38
1 files changed, 26 insertions, 12 deletions
diff --git a/dxr3syncbuffer.c b/dxr3syncbuffer.c
index 7bf6932..f2fe80f 100644
--- a/dxr3syncbuffer.c
+++ b/dxr3syncbuffer.c
@@ -33,15 +33,8 @@ const int DXR3_MAX_AUDIO_FRAME_LENGTH = 4096;
// ==================================
//! constructor
-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);
- }
+cFixedLengthFrame::cFixedLengthFrame() :
+m_count(0), m_length(0), m_pts(0), m_type(ftUnknown) {
m_audioChannelCount = UNKNOWN_CHANNEL_COUNT;
m_audioDataRate = UNKNOWN_DATA_RATE;
@@ -58,6 +51,21 @@ cFixedLengthFrame::~cFixedLengthFrame()
}
// ==================================
+// ! setup our frame
+void cFixedLengthFrame::Init(uint32_t lenght)
+{
+ m_length = length;
+ m_pData = new uint8_t[length];
+
+ // 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)
@@ -101,20 +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(frameLenght);
+ }
+
+ // set some default values
m_count = 0;
m_nextFree = 0;
m_next = 0;