aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cubeb_ring_array.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/cubeb_ring_array.h')
-rw-r--r--src/cubeb_ring_array.h18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/cubeb_ring_array.h b/src/cubeb_ring_array.h
index c02474b..51b3b32 100644
--- a/src/cubeb_ring_array.h
+++ b/src/cubeb_ring_array.h
@@ -8,9 +8,7 @@
#ifndef CUBEB_RING_ARRAY_H
#define CUBEB_RING_ARRAY_H
-#if defined(__cplusplus)
-extern "C" {
-#endif
+#include "cubeb_utils.h"
/** Ring array of pointers is used to hold buffers. In case that
asynchronous producer/consumer callbacks do not arrive in a
@@ -34,10 +32,11 @@ single_audiobuffer_init(AudioBuffer * buffer,
assert(bytesPerFrame > 0 && channelsPerFrame && frames > 0);
size_t size = bytesPerFrame * frames;
- buffer->mData = calloc(1, size);
+ buffer->mData = operator new(size);
if (buffer->mData == NULL) {
return CUBEB_ERROR;
}
+ PodZero(static_cast<char*>(buffer->mData), size);
buffer->mNumberChannels = channelsPerFrame;
buffer->mDataByteSize = size;
@@ -64,7 +63,8 @@ ring_array_init(ring_array * ra,
ra->tail = 0;
ra->count = 0;
- ra->buffer_array = (AudioBuffer *)calloc(ra->capacity, sizeof(AudioBuffer));
+ ra->buffer_array = new AudioBuffer[ra->capacity];
+ PodZero(ra->buffer_array, ra->capacity);
if (ra->buffer_array == NULL) {
return CUBEB_ERROR;
}
@@ -92,10 +92,10 @@ ring_array_destroy(ring_array * ra)
}
for (unsigned int i = 0; i < ra->capacity; ++i) {
if (ra->buffer_array[i].mData) {
- free(ra->buffer_array[i].mData);
+ operator delete(ra->buffer_array[i].mData);
}
}
- free(ra->buffer_array);
+ delete [] ra->buffer_array;
}
/** Get the allocated buffer to be stored with fresh data.
@@ -156,8 +156,4 @@ ring_array_get_dummy_buffer(ring_array * ra)
return &ra->buffer_array[0];
}
-#if defined(__cplusplus)
-}
-#endif
-
#endif //CUBEB_RING_ARRAY_H