--- a/qtms/src/qtmsmembuffer.cpp Wed Jun 16 16:05:08 2010 +0100
+++ b/qtms/src/qtmsmembuffer.cpp Thu Jul 22 16:38:21 2010 +0100
@@ -16,19 +16,17 @@
*/
#include <qtms.h>
-#include <qtmsbuffer.h>
+#include <tmsbuffer.h>
+#include "tmsutility.h"
#include "qtmsmembuffer.h"
-#include "tmsutility.h"
using namespace QTMS;
using namespace TMS;
-QTMSMemBuffer::QTMSMemBuffer() :
- iBufferSize(0),
- iTimeStamp(0),
- iDataPtr(NULL),
- iOwnsBuffer(FALSE)
+QTMSMemBuffer::QTMSMemBuffer()
{
+ iTmsBuffer = NULL;
+ iOwnsBuffer = FALSE;
}
QTMSMemBuffer::~QTMSMemBuffer()
@@ -39,36 +37,20 @@
}
}
-gint QTMSMemBuffer::Create(guint size, QTMSBuffer*& tmsbuffer)
+gint QTMSMemBuffer::Create(QTMSBuffer*& buffer, TMS::TMSBuffer*& tmsbuffer)
{
- gint ret(TMS_RESULT_INSUFFICIENT_MEMORY);
+ gint ret(QTMS_RESULT_INSUFFICIENT_MEMORY);
TRACE_PRN_FN_ENT;
QTMSMemBuffer* self = new QTMSMemBuffer();
if (self)
{
- ret = self->PostConstruct(size);
- if (ret != TMS_RESULT_SUCCESS)
- {
- delete self;
- self = NULL;
- }
+ self->iTmsBuffer = tmsbuffer;
+ tmsbuffer->GetDataPtr(self->iDataPtr);
+ tmsbuffer->GetDataSize(self->iBufferSize);
+ tmsbuffer->GetTimeStamp(self->iTimeStamp);
+ self->iOwnsBuffer = FALSE;
}
- tmsbuffer = self;
- TRACE_PRN_FN_EXT;
- return ret;
- }
-
-gint QTMSMemBuffer::PostConstruct(guint size)
- {
- gint ret(TMS_RESULT_SUCCESS);
- TRACE_PRN_FN_ENT;
- iDataPtr = (guint8*) malloc(size);
- if (!iDataPtr)
- {
- ret = TMS_RESULT_INSUFFICIENT_MEMORY;
- }
- iOwnsBuffer = TRUE;
- iBufferSize = size;
+ buffer = self;
TRACE_PRN_FN_EXT;
return ret;
}
@@ -76,83 +58,78 @@
gint QTMSMemBuffer::GetType(QTMSBufferType& buffertype)
{
gint ret(TMS_RESULT_SUCCESS);
- buffertype = TMS_BUFFER_MEMORY;
+ buffertype = QTMS_BUFFER_MEMORY;
return ret;
}
-// Implementation of TMSBuffer interface begins
/**
- Gets the timestamp on the Buffer so that the framework can
- determine the time at which this buffer has to be rendered
- by the output device sink.
-
- @param ts
- timestamp in microseconds
-
+ * Gets the timestamp on the Buffer so that the framework can
+ * determine the time at which this buffer has to be rendered
+ * by the output device sink.
+ *
+ * @param ts timestamp in microseconds
+ *
*/
gint QTMSMemBuffer::GetTimeStamp(guint64& ts)
{
- gint ret(TMS_RESULT_SUCCESS);
+ gint ret(QTMS_RESULT_SUCCESS);
ts = iTimeStamp;
return ret;
}
/**
- Sets the timestamp on the Buffer so that the framework can
- determine the time at which this buffer has to be rendered
- by the output device sink.
-
- @param ts
- timestamp in milliseconds
-
+ * Sets the timestamp on the Buffer so that the framework can
+ * determine the time at which this buffer has to be rendered
+ * by the output device sink.
+ *
+ * @param ts timestamp in milliseconds
+ *
*/
gint QTMSMemBuffer::SetTimeStamp(const guint64 ts)
{
- gint ret(TMS_RESULT_SUCCESS);
+ gint ret(QTMS_RESULT_SUCCESS);
iTimeStamp = ts;
+ ret = iTmsBuffer->SetTimeStamp(ts);
return ret;
}
/**
- Gets the size of data in the buffer specified by the client.
-
- @param size
- size of data in bytes
-
+ * Gets the size of data in the buffer specified by the client.
+ *
+ * @param size size of data in bytes
+ *
*/
gint QTMSMemBuffer::GetDataSize(guint& size)
{
- gint ret(TMS_RESULT_SUCCESS);
+ gint ret(QTMS_RESULT_SUCCESS);
size = iBufferSize;
return ret;
}
/**
- Sets the size of data in the buffer after the client
- fill it.
-
- @param size
- size of data in bytes
-
+ * Sets the size of data in the buffer after the client fill it.
+ *
+ * @param size size of data in bytes
+ *
*/
gint QTMSMemBuffer::SetDataSize(const guint size)
{
- gint ret(TMS_RESULT_SUCCESS);
- iBufferSize = size;
+ gint ret(QTMS_RESULT_SUCCESS);
+ ret = iTmsBuffer->SetDataSize(size);
+ iBufferSize = size; //TODO: should realloc when new size > old size (?)
return ret;
}
/**
- Gets the pointer to the memory location associated with this
- buffer where the data is stored.
-
- @param bufptr
- ptr to the data stored in the buffer.
-
+ * Gets the pointer to the memory location associated with this
+ * buffer where the data is stored.
+ *
+ * @param bufptr ptr to the data stored in the buffer.
+ *
*/
gint QTMSMemBuffer::GetDataPtr(guint8*& bufptr)
{
- gint ret(TMS_RESULT_SUCCESS);
+ gint ret(QTMS_RESULT_SUCCESS);
bufptr = iDataPtr;
return ret;
}