# HG changeset patch # User Ryan C. Gordon # Date 1252767872 0 # Node ID 95213cf5efcc20c9244bc84f2a2ef9e09cc3f71f # Parent 9701c96e2cbbc683708a96fe5077c7caf4c32281 Fixed CoreAudio to compile with Mac OS X 10.6 SDK and 64-bit targets. diff -r 9701c96e2cbb -r 95213cf5efcc src/audio/macosx/SDL_coreaudio.c --- a/src/audio/macosx/SDL_coreaudio.c Sat Sep 12 14:05:39 2009 +0000 +++ b/src/audio/macosx/SDL_coreaudio.c Sat Sep 12 15:04:32 2009 +0000 @@ -21,8 +21,10 @@ */ #include "SDL_config.h" +#include +#include #include -#ifdef AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER +#if MAC_OS_X_VERSION_MAX_ALLOWED <= 1050 #include #endif @@ -91,19 +93,25 @@ }; /* The CoreAudio callback */ -static OSStatus audioCallback (void *inRefCon, - AudioUnitRenderActionFlags inActionFlags, - const AudioTimeStamp *inTimeStamp, - UInt32 inBusNumber, - AudioBuffer *ioData) +static OSStatus audioCallback (void *inRefCon, + AudioUnitRenderActionFlags *ioActionFlags, + const AudioTimeStamp *inTimeStamp, + UInt32 inBusNumber, + UInt32 inNumberFrames, + AudioBufferList *ioData) { SDL_AudioDevice *this = (SDL_AudioDevice *)inRefCon; UInt32 remaining, len; + AudioBuffer *abuf; void *ptr; + UInt32 i; /* Only do anything if audio is enabled and not paused */ if ( ! this->enabled || this->paused ) { - SDL_memset(ioData->mData, this->spec.silence, ioData->mDataByteSize); + for (i = 0; i < ioData->mNumberBuffers; i++) { + abuf = &ioData->mBuffers[i]; + SDL_memset(abuf->mData, this->spec.silence, abuf->mDataByteSize); + } return 0; } @@ -114,29 +122,32 @@ assert(!this->convert.needed); assert(this->spec.channels == ioData->mNumberChannels); */ - - remaining = ioData->mDataByteSize; - ptr = ioData->mData; - while (remaining > 0) { - if (bufferOffset >= bufferSize) { - /* Generate the data */ - SDL_memset(buffer, this->spec.silence, bufferSize); - SDL_mutexP(this->mixer_lock); - (*this->spec.callback)(this->spec.userdata, - buffer, bufferSize); - SDL_mutexV(this->mixer_lock); - bufferOffset = 0; + + for (i = 0; i < ioData->mNumberBuffers; i++) { + abuf = &ioData->mBuffers[i]; + remaining = abuf->mDataByteSize; + ptr = abuf->mData; + while (remaining > 0) { + if (bufferOffset >= bufferSize) { + /* Generate the data */ + SDL_memset(buffer, this->spec.silence, bufferSize); + SDL_mutexP(this->mixer_lock); + (*this->spec.callback)(this->spec.userdata, + buffer, bufferSize); + SDL_mutexV(this->mixer_lock); + bufferOffset = 0; + } + + len = bufferSize - bufferOffset; + if (len > remaining) + len = remaining; + SDL_memcpy(ptr, (char *)buffer + bufferOffset, len); + ptr = (char *)ptr + len; + remaining -= len; + bufferOffset += len; } - - len = bufferSize - bufferOffset; - if (len > remaining) - len = remaining; - SDL_memcpy(ptr, (char *)buffer + bufferOffset, len); - ptr = (char *)ptr + len; - remaining -= len; - bufferOffset += len; } - + return 0; } @@ -159,7 +170,7 @@ void Core_CloseAudio(_THIS) { OSStatus result; - struct AudioUnitInputCallback callback; + struct AURenderCallbackStruct callback; /* stop processing the audio unit */ result = AudioOutputUnitStop (outputAudioUnit); @@ -172,7 +183,7 @@ callback.inputProc = 0; callback.inputProcRefCon = 0; result = AudioUnitSetProperty (outputAudioUnit, - kAudioUnitProperty_SetInputCallback, + kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, 0, &callback, @@ -203,7 +214,7 @@ OSStatus result = noErr; Component comp; ComponentDescription desc; - struct AudioUnitInputCallback callback; + struct AURenderCallbackStruct callback; AudioStreamBasicDescription requestedDesc; /* Setup a AudioStreamBasicDescription with the requested format */ @@ -224,9 +235,9 @@ /* Locate the default output audio unit */ - desc.componentType = kAudioUnitComponentType; - desc.componentSubType = kAudioUnitSubType_Output; - desc.componentManufacturer = kAudioUnitID_DefaultOutput; + desc.componentType = kAudioUnitType_Output; + desc.componentSubType = kAudioUnitSubType_DefaultOutput; + desc.componentManufacturer = kAudioUnitManufacturer_Apple; desc.componentFlags = 0; desc.componentFlagsMask = 0; @@ -256,7 +267,7 @@ callback.inputProc = audioCallback; callback.inputProcRefCon = this; result = AudioUnitSetProperty (outputAudioUnit, - kAudioUnitProperty_SetInputCallback, + kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, 0, &callback,