Backed out 2 changesets (bug 1285541) for causing a frequent mda failure

Backed out changeset 53ac5a12a19b (bug 1285541)
Backed out changeset aea13acdf417 (bug 1285541)

--HG--
rename : media/libcubeb/src/cubeb_audiounit.cpp => media/libcubeb/src/cubeb_audiounit.c
This commit is contained in:
Wes Kocher 2016-07-08 15:21:43 -07:00
Родитель f5f39f87cc
Коммит e94aeb34ae
8 изменённых файлов: 120 добавлений и 149 удалений

Просмотреть файл

@ -22,4 +22,4 @@
# changes to stick? As of bug 928195, this shouldn't be necessary! Please
# don't change CLOBBER for WebIDL changes any more.
Bug 1285541 - touch clobber to fix bustage
Bug 1267887 - Build skew after updating rust mp4parse

Просмотреть файл

@ -5,4 +5,4 @@ Makefile.in build files for the Mozilla build system.
The cubeb git repository is: git://github.com/kinetiknz/cubeb.git
The git commit ID used was 9d28cd3133bc8f40172ede9897f6755c46526c7b.
The git commit ID used was b8aebef33a096640d6cbd7a6fa568bccef1b339c.

Просмотреть файл

@ -27,7 +27,6 @@
#endif
#include "cubeb_resampler.h"
#include "cubeb_ring_array.h"
#include "cubeb_utils.h"
#if !defined(kCFCoreFoundationVersionNumber10_7)
/* From CoreFoundation CFBase.h */
@ -57,7 +56,7 @@ typedef UInt32 AudioFormatFlags;
#define CUBEB_AUDIOUNIT_SUBTYPE kAudioUnitSubType_HALOutput
#endif
// #define LOGGING_ENABLED
//#define LOGGING_ENABLED
#ifdef LOGGING_ENABLED
#define LOG(...) do { \
fprintf(stderr, __VA_ARGS__); \
@ -66,10 +65,10 @@ typedef UInt32 AudioFormatFlags;
#define LOG(...)
#endif
extern cubeb_ops const audiounit_ops;
static struct cubeb_ops const audiounit_ops;
struct cubeb {
cubeb_ops const * ops;
struct cubeb_ops const * ops;
pthread_mutex_t mutex;
int active_streams;
int limit_streams;
@ -166,7 +165,7 @@ audiounit_input_callback(void * user_ptr,
UInt32 input_frames,
AudioBufferList * bufs)
{
cubeb_stream * stm = static_cast<cubeb_stream *>(user_ptr);
cubeb_stream * stm = user_ptr;
long outframes, frames;
pthread_mutex_lock(&stm->mutex);
@ -254,7 +253,7 @@ audiounit_output_callback(void * user_ptr,
assert(AU_OUT_BUS == bus);
assert(outBufferList->mNumberBuffers == 1);
cubeb_stream * stm = static_cast<cubeb_stream *>(user_ptr);
cubeb_stream * stm = user_ptr;
LOG("- output(%p): buffers %d, size %d, channels %d, frames %d\n", stm,
outBufferList->mNumberBuffers, outBufferList->mBuffers[0].mDataByteSize,
@ -271,10 +270,6 @@ audiounit_output_callback(void * user_ptr,
return noErr;
}
LOG("- output(%p): buffers %d, size %d, channels %d, frames %d\n", stm,
outBufferList->mNumberBuffers, outBufferList->mBuffers[0].mDataByteSize,
outBufferList->mBuffers[0].mNumberChannels, output_frames);
stm->current_latency_frames = audiotimestamp_to_latency(tstamp, stm);
if (stm->draining) {
OSStatus r = AudioOutputUnitStop(stm->output_unit);
@ -293,28 +288,31 @@ audiounit_output_callback(void * user_ptr,
/* If Full duplex get also input buffer */
AudioBuffer * input_aud_buf = NULL;
if (stm->input_unit != NULL) {
/* Output callback came first */
if (stm->frames_read == 0) {
LOG("Output callback came first send silent.\n");
audiounit_make_silent(&outBufferList->mBuffers[0]);
pthread_mutex_unlock(&stm->mutex);
return noErr;
}
/* Input samples stored previously in input callback. */
input_aud_buf = ring_array_get_data_buffer(&stm->input_buffer_array);
if (input_aud_buf == NULL) {
LOG("Requested more output than input. "
"This is either a hole or we are after a stream stop and input thread stopped before output\n");
/* Provide silent input. Other than that we could provide silent output and exit without
* calling user callback. This is not preferred because the user loose the control of
* calling user callback. I do not prefer it because the user loose the control of
* the output. Also resampler loose frame counting and produce less frame than
* expected at some point in the future breaking an assert. */
LOG("Input hole. Requested more input than existing.\n");
/* Avoid here to allocate new memory since we are inside callback. Use the existing
* allocated buffers since the ring array is empty and the buffer is not used. */
input_aud_buf = ring_array_get_dummy_buffer(&stm->input_buffer_array);
/* Output callback came first */
if (stm->frames_read == 0) {
LOG("Output callback came first send silent.\n");
}
audiounit_make_silent(input_aud_buf);
}
// The input buffer
input_buffer = input_aud_buf->mData;
// Number of input frames in the buffer
input_frames = stm->input_buffer_frames;
assert(stm->frames_read > 0);
}
/* Call user callback through resampler. */
@ -360,8 +358,7 @@ audiounit_output_callback(void * user_ptr,
return noErr;
}
extern "C" {
int
/*static*/ int
audiounit_init(cubeb ** context, char const * context_name)
{
cubeb * ctx;
@ -369,9 +366,8 @@ audiounit_init(cubeb ** context, char const * context_name)
*context = NULL;
ctx = new cubeb;
ctx = calloc(1, sizeof(*ctx));
assert(ctx);
PodZero(ctx, 1);
ctx->ops = &audiounit_ops;
@ -389,7 +385,6 @@ audiounit_init(cubeb ** context, char const * context_name)
return CUBEB_OK;
}
}
static char const *
audiounit_get_backend_id(cubeb * ctx)
@ -716,7 +711,7 @@ audiounit_get_min_latency(cubeb * ctx, cubeb_stream_params params, uint32_t * la
return CUBEB_ERROR;
}
*latency_ms = ceil((latency_range.mMinimum * 1000 ) / params.rate);
*latency_ms = (latency_range.mMinimum * 1000 + params.rate - 1) / params.rate;
#endif
return CUBEB_OK;
@ -755,7 +750,7 @@ audiounit_get_preferred_sample_rate(cubeb * ctx, uint32_t * rate)
return CUBEB_ERROR;
}
*rate = static_cast<uint32_t>(fsamplerate);
*rate = (uint32_t)fsamplerate;
#endif
return CUBEB_OK;
}
@ -778,7 +773,7 @@ audiounit_destroy(cubeb * ctx)
int r = pthread_mutex_destroy(&ctx->mutex);
assert(r == 0);
delete ctx;
free(ctx);
}
static void audiounit_stream_destroy(cubeb_stream * stm);
@ -867,7 +862,7 @@ audiounit_create_unit(AudioUnit * unit,
devid = audiounit_get_default_device_id(is_input ? CUBEB_DEVICE_TYPE_INPUT
: CUBEB_DEVICE_TYPE_OUTPUT);
} else {
devid = *(static_cast<AudioDeviceID*>(device));
devid = (AudioDeviceID)device;
}
int err = AudioUnitSetProperty(*unit, kAudioOutputUnitProperty_CurrentDevice,
kAudioUnitScope_Global,
@ -950,9 +945,8 @@ audiounit_stream_init(cubeb * context,
}
}
stm = new cubeb_stream;
stm = calloc(1, sizeof(cubeb_stream));
assert(stm);
PodZero(stm, 1);
/* These could be different in the future if we have both
* full-duplex stream and different devices for input vs output. */
@ -976,6 +970,27 @@ audiounit_stream_init(cubeb * context,
/* Setup Input Stream! */
if (input_stream_params != NULL) {
size = sizeof(UInt32);
if (AudioUnitGetProperty(stm->input_unit,
kAudioDevicePropertyBufferFrameSize,
kAudioUnitScope_Input,
AU_IN_BUS,
&stm->input_buffer_frames,
&size) != 0) {
audiounit_stream_destroy(stm);
return CUBEB_ERROR;
}
if (AudioUnitSetProperty(stm->input_unit,
kAudioDevicePropertyBufferFrameSize,
kAudioUnitScope_Output,
AU_IN_BUS,
&stm->input_buffer_frames,
size) != 0) {
audiounit_stream_destroy(stm);
return CUBEB_ERROR;
}
/* Get input device sample rate. */
AudioStreamBasicDescription input_hw_desc;
size = sizeof(AudioStreamBasicDescription);
@ -997,19 +1012,6 @@ audiounit_stream_init(cubeb * context,
return r;
}
// Use latency to calculate buffer size
stm->input_buffer_frames = (latency / 1000.0) * stm->input_hw_rate;
LOG("Calculated input number of frames %u for latency %u\n", stm->input_buffer_frames, latency);
if (AudioUnitSetProperty(stm->input_unit,
kAudioDevicePropertyBufferFrameSize,
kAudioUnitScope_Output,
AU_IN_BUS,
&stm->input_buffer_frames,
sizeof(UInt32)) != 0) {
audiounit_stream_destroy(stm);
return CUBEB_ERROR;
}
AudioStreamBasicDescription src_desc = stm->input_desc;
/* Input AudioUnit must be configured with device's sample rate.
we will resample inside input callback. */
@ -1070,20 +1072,6 @@ audiounit_stream_init(cubeb * context,
return r;
}
/* Get output device sample rate. */
AudioStreamBasicDescription output_hw_desc;
size = sizeof(AudioStreamBasicDescription);
memset(&output_hw_desc, 0, size);
if (AudioUnitGetProperty(stm->output_unit,
kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Output,
AU_OUT_BUS,
&output_hw_desc,
&size) != 0) {
audiounit_stream_destroy(stm);
return CUBEB_ERROR;
}
if (AudioUnitSetProperty(stm->output_unit,
kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Input,
@ -1094,21 +1082,6 @@ audiounit_stream_init(cubeb * context,
return CUBEB_ERROR;
}
// Use latency to set number of frames in out buffer. Use the
// device sampling rate, internal resampler of audiounit will
// calculate the expected number of frames.
uint32_t output_buffer_frames = (latency / 1000.0) * output_hw_desc.mSampleRate;
LOG("Calculated output number of frames %u for latency %u\n", output_buffer_frames, latency);
if (AudioUnitSetProperty(stm->output_unit,
kAudioDevicePropertyBufferFrameSize,
kAudioUnitScope_Input,
AU_OUT_BUS,
&output_buffer_frames,
sizeof(output_buffer_frames)) != 0) {
audiounit_stream_destroy(stm);
return CUBEB_ERROR;
}
assert(stm->output_unit != NULL);
aurcbs_out.inputProc = audiounit_output_callback;
aurcbs_out.inputProcRefCon = stm;
@ -1252,7 +1225,7 @@ audiounit_stream_destroy(cubeb_stream * stm)
stm->context->active_streams -= 1;
pthread_mutex_unlock(&stm->context->mutex);
delete stm;
free(stm);
}
static int
@ -1374,7 +1347,7 @@ audiounit_stream_get_latency(cubeb_stream * stm, uint32_t * latency)
/* This part is fixed and depend on the stream parameter and the hardware. */
stm->hw_latency_frames =
static_cast<uint32_t>(unit_latency_sec * stm->output_desc.mSampleRate)
(uint32_t)(unit_latency_sec * stm->output_desc.mSampleRate)
+ device_latency_frames
+ device_safety_offset;
}
@ -1446,11 +1419,10 @@ int audiounit_stream_get_current_device(cubeb_stream * stm,
return CUBEB_ERROR;
}
*device = new cubeb_device;
*device = malloc(sizeof(cubeb_device));
if (!*device) {
return CUBEB_ERROR;
}
PodZero(*device, 1);
size = sizeof(UInt32);
/* This fails with some USB headset, so simply return an empty string. */
@ -1462,7 +1434,12 @@ int audiounit_stream_get_current_device(cubeb_stream * stm,
data = 0;
}
(*device)->output_name = new char[size + 1];
(*device)->output_name = malloc(size + 1);
if (!(*device)->output_name) {
return CUBEB_ERROR;
}
(*device)->output_name = malloc(size + 1);
if (!(*device)->output_name) {
return CUBEB_ERROR;
}
@ -1488,7 +1465,7 @@ int audiounit_stream_get_current_device(cubeb_stream * stm,
data = 0;
}
(*device)->input_name = new char[size + 1];
(*device)->input_name = malloc(size + 1);
if (!(*device)->input_name) {
return CUBEB_ERROR;
}
@ -1509,9 +1486,9 @@ int audiounit_stream_get_current_device(cubeb_stream * stm,
int audiounit_stream_device_destroy(cubeb_stream * stream,
cubeb_device * device)
{
delete [] device->output_name;
delete [] device->input_name;
delete device;
free(device->output_name);
free(device->input_name);
free(device);
return CUBEB_OK;
}
@ -1551,17 +1528,17 @@ audiounit_get_devices(AudioObjectID ** devices, uint32_t * count)
return ret;
}
*count = static_cast<uint32_t>(size / sizeof(AudioObjectID));
*count = (uint32_t)(size / sizeof(AudioObjectID));
if (size >= sizeof(AudioObjectID)) {
if (*devices != NULL) {
delete [] (*devices);
free(*devices);
}
*devices = new AudioObjectID[*count];
PodZero(*devices, *count);
*devices = malloc(size);
memset(*devices, 0, size);
ret = AudioObjectGetPropertyData(kAudioObjectSystemObject, &adr, 0, NULL, &size, (void *)*devices);
if (ret != noErr) {
delete [] (*devices);
free(*devices);
*devices = NULL;
}
} else {
@ -1583,10 +1560,10 @@ audiounit_strref_to_cstr_utf8(CFStringRef strref)
len = CFStringGetLength(strref);
size = CFStringGetMaximumSizeForEncoding(len, kCFStringEncodingUTF8);
ret = new char[size];
ret = malloc(size);
if (!CFStringGetCString(strref, ret, size, kCFStringEncodingUTF8)) {
delete [] ret;
free(ret);
ret = NULL;
}
@ -1603,7 +1580,7 @@ audiounit_get_channel_count(AudioObjectID devid, AudioObjectPropertyScope scope)
adr.mSelector = kAudioDevicePropertyStreamConfiguration;
if (AudioObjectGetPropertyDataSize(devid, &adr, 0, NULL, &size) == noErr && size > 0) {
AudioBufferList * list = static_cast<AudioBufferList *>(alloca(size));
AudioBufferList * list = alloca(size);
if (AudioObjectGetPropertyData(devid, &adr, 0, NULL, &size, list) == noErr) {
for (i = 0; i < list->mNumberBuffers; i++)
ret += list->mBuffers[i].mNumberChannels;
@ -1634,7 +1611,7 @@ audiounit_get_available_samplerate(AudioObjectID devid, AudioObjectPropertyScope
if (AudioObjectHasProperty(devid, &adr) &&
AudioObjectGetPropertyDataSize(devid, &adr, 0, NULL, &size) == noErr) {
uint32_t i, count = size / sizeof(AudioValueRange);
AudioValueRange * ranges = new AudioValueRange[count];
AudioValueRange * ranges = malloc(size);
range.mMinimum = 9999999999.0;
range.mMaximum = 0.0;
if (AudioObjectGetPropertyData(devid, &adr, 0, NULL, &size, ranges) == noErr) {
@ -1645,9 +1622,9 @@ audiounit_get_available_samplerate(AudioObjectID devid, AudioObjectPropertyScope
range.mMinimum = ranges[i].mMinimum;
}
}
delete [] ranges;
*max = static_cast<uint32_t>(range.mMaximum);
*min = static_cast<uint32_t>(range.mMinimum);
free(ranges);
*max = (uint32_t)range.mMaximum;
*min = (uint32_t)range.mMinimum;
} else {
*min = *max = 0;
}
@ -1706,8 +1683,7 @@ audiounit_create_device_from_hwdev(AudioObjectID devid, cubeb_device_type type)
return NULL;
}
ret = new cubeb_device_info;
PodZero(ret, 1);
ret = calloc(1, sizeof(cubeb_device_info));
size = sizeof(CFStringRef);
adr.mSelector = kAudioDevicePropertyDeviceUID;
@ -1757,7 +1733,7 @@ audiounit_create_device_from_hwdev(AudioObjectID devid, cubeb_device_type type)
CUBEB_DEVICE_PREF_ALL : CUBEB_DEVICE_PREF_NONE;
ret->max_channels = ch;
ret->format = (cubeb_device_fmt)CUBEB_DEVICE_FMT_ALL; /* CoreAudio supports All! */
ret->format = CUBEB_DEVICE_FMT_ALL; /* CoreAudio supports All! */
/* kAudioFormatFlagsAudioUnitCanonical is deprecated, prefer floating point */
ret->default_format = CUBEB_DEVICE_FMT_F32NE;
audiounit_get_available_samplerate(devid, adr.mScope,
@ -1790,8 +1766,8 @@ audiounit_enumerate_devices(cubeb * context, cubeb_device_type type,
return CUBEB_ERROR;
}
*collection = static_cast<cubeb_device_collection *>(malloc(sizeof(cubeb_device_collection) +
sizeof(cubeb_device_info*) * (hwdevcount > 0 ? hwdevcount - 1 : 0)));
*collection = malloc(sizeof(cubeb_device_collection) +
sizeof(cubeb_device_info*) * (hwdevcount > 0 ? hwdevcount - 1 : 0));
(*collection)->count = 0;
if (hwdevcount > 0) {
@ -1812,7 +1788,7 @@ audiounit_enumerate_devices(cubeb * context, cubeb_device_type type,
}
}
delete [] hwdevs;
free(hwdevs);
return CUBEB_OK;
}
@ -1849,7 +1825,7 @@ audiounit_get_devices_of_type(cubeb_device_type devtype, AudioObjectID ** devid_
if (devtype == (CUBEB_DEVICE_TYPE_INPUT | CUBEB_DEVICE_TYPE_OUTPUT)) {
if (devid_array) {
*devid_array = new AudioObjectID[count];
*devid_array = calloc(count, sizeof(AudioObjectID));
assert(*devid_array);
memcpy(*devid_array, &devices, count * sizeof(AudioObjectID));
}
@ -1871,7 +1847,7 @@ audiounit_get_devices_of_type(cubeb_device_type devtype, AudioObjectID ** devid_
}
if (devid_array && dev_count > 0) {
*devid_array = static_cast<AudioObjectID *>(calloc(dev_count, sizeof(AudioObjectID)));
*devid_array = calloc(dev_count, sizeof(AudioObjectID));
assert(*devid_array);
memcpy(*devid_array, &devices_in_scope, dev_count * sizeof(AudioObjectID));
}
@ -1896,7 +1872,7 @@ audiounit_collection_changed_callback(AudioObjectID inObjectID,
const AudioObjectPropertyAddress * inAddresses,
void * inClientData)
{
cubeb * context = static_cast<cubeb *>(inClientData);
cubeb * context = inClientData;
pthread_mutex_lock(&context->mutex);
if (context->collection_changed_callback == NULL) {
/* Listener removed while waiting in mutex, abort. */
@ -1913,14 +1889,14 @@ audiounit_collection_changed_callback(AudioObjectID inObjectID,
if (context->devtype_device_count == new_number_of_devices &&
audiounit_equal_arrays(devices, context->devtype_device_array, new_number_of_devices)) {
/* Device changed for the other scope, ignore. */
delete [] devices;
free(devices);
pthread_mutex_unlock(&context->mutex);
return noErr;
}
/* Device on desired scope changed, reset counter and array. */
context->devtype_device_count = new_number_of_devices;
/* Free the old array before replace. */
delete [] context->devtype_device_array;
free(context->devtype_device_array);
context->devtype_device_array = devices;
}
@ -1981,12 +1957,12 @@ audiounit_remove_device_listener(cubeb * context)
context);
if (ret == noErr) {
/* Reset all values. */
context->collection_changed_devtype = CUBEB_DEVICE_TYPE_UNKNOWN;
context->collection_changed_devtype = 0;
context->collection_changed_callback = NULL;
context->collection_changed_user_ptr = NULL;
context->devtype_device_count = 0;
if (context->devtype_device_array) {
delete [] context->devtype_device_array;
free(context->devtype_device_array);
context->devtype_device_array = NULL;
}
}
@ -2011,24 +1987,24 @@ int audiounit_register_device_collection_changed(cubeb * context,
return (ret == noErr) ? CUBEB_OK : CUBEB_ERROR;
}
cubeb_ops const audiounit_ops = {
/*.init =*/ audiounit_init,
/*.get_backend_id =*/ audiounit_get_backend_id,
/*.get_max_channel_count =*/ audiounit_get_max_channel_count,
/*.get_min_latency =*/ audiounit_get_min_latency,
/*.get_preferred_sample_rate =*/ audiounit_get_preferred_sample_rate,
/*.enumerate_devices =*/ audiounit_enumerate_devices,
/*.destroy =*/ audiounit_destroy,
/*.stream_init =*/ audiounit_stream_init,
/*.stream_destroy =*/ audiounit_stream_destroy,
/*.stream_start =*/ audiounit_stream_start,
/*.stream_stop =*/ audiounit_stream_stop,
/*.stream_get_position =*/ audiounit_stream_get_position,
/*.stream_get_latency =*/ audiounit_stream_get_latency,
/*.stream_set_volume =*/ audiounit_stream_set_volume,
/*.stream_set_panning =*/ audiounit_stream_set_panning,
/*.stream_get_current_device =*/ audiounit_stream_get_current_device,
/*.stream_device_destroy =*/ audiounit_stream_device_destroy,
/*.stream_register_device_changed_callback =*/ audiounit_stream_register_device_changed_callback,
/*.register_device_collection_changed =*/ audiounit_register_device_collection_changed
static struct cubeb_ops const audiounit_ops = {
.init = audiounit_init,
.get_backend_id = audiounit_get_backend_id,
.get_max_channel_count = audiounit_get_max_channel_count,
.get_min_latency = audiounit_get_min_latency,
.get_preferred_sample_rate = audiounit_get_preferred_sample_rate,
.enumerate_devices = audiounit_enumerate_devices,
.destroy = audiounit_destroy,
.stream_init = audiounit_stream_init,
.stream_destroy = audiounit_stream_destroy,
.stream_start = audiounit_stream_start,
.stream_stop = audiounit_stream_stop,
.stream_get_position = audiounit_stream_get_position,
.stream_get_latency = audiounit_stream_get_latency,
.stream_set_volume = audiounit_stream_set_volume,
.stream_set_panning = audiounit_stream_set_panning,
.stream_get_current_device = audiounit_stream_get_current_device,
.stream_device_destroy = audiounit_stream_device_destroy,
.stream_register_device_changed_callback = audiounit_stream_register_device_changed_callback,
.register_device_collection_changed = audiounit_register_device_collection_changed
};

Просмотреть файл

@ -11,12 +11,4 @@
*
* This has to be called only once per process, so it is in a separate header
* for easy integration in other code bases. */
#if defined(__cplusplus)
extern "C" {
#endif
void cubeb_set_coreaudio_notification_runloop();
#if defined(__cplusplus)
}
#endif

Просмотреть файл

@ -263,7 +263,7 @@ public:
* number of output frames will be exactly equal. */
uint32_t input_needed_for_output(uint32_t output_frame_count)
{
return (uint32_t)ceilf((output_frame_count - samples_to_frames(resampling_out_buffer.length()))
return (uint32_t)ceilf((output_frame_count - samples_to_frames(resampling_in_buffer.length()))
* resampling_ratio);
}
@ -332,7 +332,7 @@ private:
/** Additional latency inserted into the pipeline for synchronisation. */
uint32_t additional_latency;
/** When `input_buffer` is called, this allows tracking the number of samples
that were in the buffer. */
that where in the buffer. */
uint32_t leftover_samples;
};

Просмотреть файл

@ -8,7 +8,9 @@
#ifndef CUBEB_RING_ARRAY_H
#define CUBEB_RING_ARRAY_H
#include "cubeb_utils.h"
#if defined(__cplusplus)
extern "C" {
#endif
/** Ring array of pointers is used to hold buffers. In case that
asynchronous producer/consumer callbacks do not arrive in a
@ -32,11 +34,10 @@ single_audiobuffer_init(AudioBuffer * buffer,
assert(bytesPerFrame > 0 && channelsPerFrame && frames > 0);
size_t size = bytesPerFrame * frames;
buffer->mData = operator new(size);
buffer->mData = calloc(1, size);
if (buffer->mData == NULL) {
return CUBEB_ERROR;
}
PodZero(static_cast<char*>(buffer->mData), size);
buffer->mNumberChannels = channelsPerFrame;
buffer->mDataByteSize = size;
@ -63,8 +64,7 @@ ring_array_init(ring_array * ra,
ra->tail = 0;
ra->count = 0;
ra->buffer_array = new AudioBuffer[ra->capacity];
PodZero(ra->buffer_array, ra->capacity);
ra->buffer_array = calloc(ra->capacity, sizeof(AudioBuffer));
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) {
operator delete(ra->buffer_array[i].mData);
free(ra->buffer_array[i].mData);
}
}
delete [] ra->buffer_array;
free(ra->buffer_array);
}
/** Get the allocated buffer to be stored with fresh data.
@ -111,7 +111,7 @@ ring_array_get_free_buffer(ring_array * ra)
}
assert(ra->count == 0 || (ra->tail + ra->count) % ra->capacity != ra->tail);
AudioBuffer * ret = &ra->buffer_array[(ra->tail + ra->count) % ra->capacity];
void * ret = &ra->buffer_array[(ra->tail + ra->count) % ra->capacity];
++ra->count;
assert(ra->count <= ra->capacity);
@ -131,7 +131,7 @@ ring_array_get_data_buffer(ring_array * ra)
if (ra->count == 0) {
return NULL;
}
AudioBuffer * ret = &ra->buffer_array[ra->tail];
void * ret = &ra->buffer_array[ra->tail];
ra->tail = (ra->tail + 1) % ra->capacity;
assert(ra->tail < ra->capacity);
@ -156,4 +156,8 @@ ring_array_get_dummy_buffer(ring_array * ra)
return &ra->buffer_array[0];
}
#if defined(__cplusplus)
}
#endif
#endif //CUBEB_RING_ARRAY_H

Просмотреть файл

@ -36,7 +36,7 @@ if CONFIG['OS_ARCH'] == 'OpenBSD':
if CONFIG['OS_TARGET'] == 'Darwin':
SOURCES += [
'cubeb_audiounit.cpp',
'cubeb_audiounit.c',
'cubeb_resampler.cpp'
]
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':

Просмотреть файл

@ -12,10 +12,9 @@ cp $1/src/cubeb-speex-resampler.h src
cp $1/src/cubeb.c src
cp $1/src/cubeb_alsa.c src
cp $1/src/cubeb_audiotrack.c src
cp $1/src/cubeb_audiounit.cpp src
cp $1/src/cubeb_audiounit.c src
cp $1/src/cubeb_jack.cpp src
cp $1/src/cubeb_opensl.c src
cp $1/src/cubeb_osx_run_loop.h src
cp $1/src/cubeb_panner.cpp src
cp $1/src/cubeb_panner.h src
cp $1/src/cubeb_pulse.c src