diff options
author | Chris Robinson <[email protected]> | 2011-09-14 02:01:35 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2011-09-14 02:01:35 -0700 |
commit | 97024151e49d97ed3ae9d73a9426de0f1a9ebb0f (patch) | |
tree | 841c413a23725d55a6b872b531bcc38689ba96cd /Alc/backends/coreaudio.c | |
parent | 62dfea43c699cb18a7538980794106d3ac0edca6 (diff) |
Return an error from the CaptureSamples method instead of setting it
Diffstat (limited to 'Alc/backends/coreaudio.c')
-rw-r--r-- | Alc/backends/coreaudio.c | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/Alc/backends/coreaudio.c b/Alc/backends/coreaudio.c index b0c600d3..8cb50edf 100644 --- a/Alc/backends/coreaudio.c +++ b/Alc/backends/coreaudio.c @@ -642,43 +642,42 @@ static ALCuint ca_available_samples(ALCdevice *device) return RingBufferSize(data->ring) / data->sampleRateRatio; } -static void ca_capture_samples(ALCdevice *device, ALCvoid *buffer, ALCuint samples) +static ALCenum ca_capture_samples(ALCdevice *device, ALCvoid *buffer, ALCuint samples) { ca_data *data = (ca_data*)device->ExtraData; + AudioBufferList *list; + UInt32 frameCount; + OSStatus err; - if(samples <= ca_available_samples(device)) - { - AudioBufferList *list; - UInt32 frameCount; - OSStatus err; + if(ca_available_samples(device) < samples) + return ALC_INVALID_VALUE; - // If no samples are requested, just return - if(samples == 0) - return; + // If no samples are requested, just return + if(samples == 0) + return ALC_NO_ERROR; - // Allocate a temporary AudioBufferList to use as the return resamples data - list = alloca(sizeof(AudioBufferList) + sizeof(AudioBuffer)); + // Allocate a temporary AudioBufferList to use as the return resamples data + list = alloca(sizeof(AudioBufferList) + sizeof(AudioBuffer)); - // Point the resampling buffer to the capture buffer - list->mNumberBuffers = 1; - list->mBuffers[0].mNumberChannels = data->format.mChannelsPerFrame; - list->mBuffers[0].mDataByteSize = samples * data->frameSize; - list->mBuffers[0].mData = buffer; - - // Resample into another AudioBufferList - frameCount = samples; - err = AudioConverterFillComplexBuffer(data->audioConverter, ca_capture_conversion_callback, device, - &frameCount, list, NULL); - if(err != noErr) - { - ERR("AudioConverterFillComplexBuffer error: %d\n", err); - alcSetError(device, ALC_INVALID_VALUE); - } + // Point the resampling buffer to the capture buffer + list->mNumberBuffers = 1; + list->mBuffers[0].mNumberChannels = data->format.mChannelsPerFrame; + list->mBuffers[0].mDataByteSize = samples * data->frameSize; + list->mBuffers[0].mData = buffer; + + // Resample into another AudioBufferList + frameCount = samples; + err = AudioConverterFillComplexBuffer(data->audioConverter, ca_capture_conversion_callback, + device, &frameCount, list, NULL); + if(err != noErr) + { + ERR("AudioConverterFillComplexBuffer error: %d\n", err); + return ALC_INVALID_VALUE; } - else - alcSetError(device, ALC_INVALID_VALUE); + return ALC_NO_ERROR; } + static const BackendFuncs ca_funcs = { ca_open_playback, ca_close_playback, |