19 #include <audio_buffer.h>
22 #include "basic_types.h"
24 #include "safec_lib.h"
26 audio_buffer::audio_buffer(
const unsigned char *in_ptr,
unsigned int in_size,
unsigned int clip_length,
unsigned int refcount) : m_size(in_size), m_clip_length(clip_length), m_refcount(refcount)
28 DEBUG(
"Creating new buffer.\n");
30 m_start_ptr = (
unsigned char *)malloc(in_size);
31 rc = memcpy_s(m_start_ptr, in_size, in_ptr, m_size);
38 audio_buffer::~audio_buffer()
40 DEBUG(
"Deleting buffer.\n");
47 return new audio_buffer(in_ptr, in_size, clip_length, refcount);
50 static pthread_mutex_t g_audio_buffer_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
57 REPORT_IF_UNEQUAL(0, pthread_mutex_lock(&g_audio_buffer_mutex));
58 if(1 == ptr->m_refcount)
66 REPORT_IF_UNEQUAL(0, pthread_mutex_unlock(&g_audio_buffer_mutex));
75 REPORT_IF_UNEQUAL(0, pthread_mutex_lock(&g_audio_buffer_mutex));
79 REPORT_IF_UNEQUAL(0, pthread_mutex_unlock(&g_audio_buffer_mutex));