dep/cubeb: Update to dc511c6

This commit is contained in:
Connor McLaughlin
2022-08-05 17:28:17 +10:00
parent 06ecc50797
commit 8f45bf7f27
50 changed files with 5667 additions and 4813 deletions

View File

@ -16,17 +16,16 @@
them in the correct order. */
typedef struct {
AudioBuffer * buffer_array; /**< Array that hold pointers of the allocated space for the buffers. */
unsigned int tail; /**< Index of the last element (first to deliver). */
unsigned int count; /**< Number of elements in the array. */
unsigned int capacity; /**< Total length of the array. */
AudioBuffer * buffer_array; /**< Array that hold pointers of the allocated
space for the buffers. */
unsigned int tail; /**< Index of the last element (first to deliver). */
unsigned int count; /**< Number of elements in the array. */
unsigned int capacity; /**< Total length of the array. */
} ring_array;
static int
single_audiobuffer_init(AudioBuffer * buffer,
uint32_t bytesPerFrame,
uint32_t channelsPerFrame,
uint32_t frames)
single_audiobuffer_init(AudioBuffer * buffer, uint32_t bytesPerFrame,
uint32_t channelsPerFrame, uint32_t frames)
{
assert(buffer);
assert(bytesPerFrame > 0 && channelsPerFrame && frames > 0);
@ -36,7 +35,7 @@ single_audiobuffer_init(AudioBuffer * buffer,
if (buffer->mData == NULL) {
return CUBEB_ERROR;
}
PodZero(static_cast<char*>(buffer->mData), size);
PodZero(static_cast<char *>(buffer->mData), size);
buffer->mNumberChannels = channelsPerFrame;
buffer->mDataByteSize = size;
@ -48,15 +47,12 @@ single_audiobuffer_init(AudioBuffer * buffer,
@param ra The ring_array pointer of allocated structure.
@retval 0 on success. */
int
ring_array_init(ring_array * ra,
uint32_t capacity,
uint32_t bytesPerFrame,
uint32_t channelsPerFrame,
uint32_t framesPerBuffer)
ring_array_init(ring_array * ra, uint32_t capacity, uint32_t bytesPerFrame,
uint32_t channelsPerFrame, uint32_t framesPerBuffer)
{
assert(ra);
if (capacity == 0 || bytesPerFrame == 0 ||
channelsPerFrame == 0 || framesPerBuffer == 0) {
if (capacity == 0 || bytesPerFrame == 0 || channelsPerFrame == 0 ||
framesPerBuffer == 0) {
return CUBEB_ERROR_INVALID_PARAMETER;
}
ra->capacity = capacity;
@ -70,8 +66,7 @@ ring_array_init(ring_array * ra,
}
for (unsigned int i = 0; i < ra->capacity; ++i) {
if (single_audiobuffer_init(&ra->buffer_array[i],
bytesPerFrame,
if (single_audiobuffer_init(&ra->buffer_array[i], bytesPerFrame,
channelsPerFrame,
framesPerBuffer) != CUBEB_OK) {
return CUBEB_ERROR;
@ -87,7 +82,7 @@ void
ring_array_destroy(ring_array * ra)
{
assert(ra);
if (ra->buffer_array == NULL){
if (ra->buffer_array == NULL) {
return;
}
for (unsigned int i = 0; i < ra->capacity; ++i) {
@ -95,12 +90,13 @@ ring_array_destroy(ring_array * ra)
operator delete(ra->buffer_array[i].mData);
}
}
delete [] ra->buffer_array;
delete[] ra->buffer_array;
}
/** Get the allocated buffer to be stored with fresh data.
@param ra The ring_array pointer.
@retval Pointer of the allocated space to be stored with fresh data or NULL if full. */
@retval Pointer of the allocated space to be stored with fresh data or NULL
if full. */
AudioBuffer *
ring_array_get_free_buffer(ring_array * ra)
{
@ -156,4 +152,4 @@ ring_array_get_dummy_buffer(ring_array * ra)
return &ra->buffer_array[0];
}
#endif //CUBEB_RING_ARRAY_H
#endif // CUBEB_RING_ARRAY_H