Commit ea2239b3 authored by Ryan C. Gordon's avatar Ryan C. Gordon

Fixed CoreAudio to compile with Mac OS X 10.6 SDK and 64-bit targets.

--HG--
branch : SDL-1.2
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/branches/SDL-1.2%403797
parent 39abd7a2
...@@ -21,8 +21,10 @@ ...@@ -21,8 +21,10 @@
*/ */
#include "SDL_config.h" #include "SDL_config.h"
#include <CoreAudio/CoreAudio.h>
#include <CoreServices/CoreServices.h>
#include <AudioUnit/AudioUnit.h> #include <AudioUnit/AudioUnit.h>
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER #if MAC_OS_X_VERSION_MAX_ALLOWED <= 1050
#include <AudioUnit/AUNTComponent.h> #include <AudioUnit/AUNTComponent.h>
#endif #endif
...@@ -92,18 +94,24 @@ AudioBootStrap COREAUDIO_bootstrap = { ...@@ -92,18 +94,24 @@ AudioBootStrap COREAUDIO_bootstrap = {
/* The CoreAudio callback */ /* The CoreAudio callback */
static OSStatus audioCallback (void *inRefCon, static OSStatus audioCallback (void *inRefCon,
AudioUnitRenderActionFlags inActionFlags, AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp *inTimeStamp, const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber, UInt32 inBusNumber,
AudioBuffer *ioData) UInt32 inNumberFrames,
AudioBufferList *ioData)
{ {
SDL_AudioDevice *this = (SDL_AudioDevice *)inRefCon; SDL_AudioDevice *this = (SDL_AudioDevice *)inRefCon;
UInt32 remaining, len; UInt32 remaining, len;
AudioBuffer *abuf;
void *ptr; void *ptr;
UInt32 i;
/* Only do anything if audio is enabled and not paused */ /* Only do anything if audio is enabled and not paused */
if ( ! this->enabled || this->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; return 0;
} }
...@@ -115,8 +123,10 @@ static OSStatus audioCallback (void *inRefCon, ...@@ -115,8 +123,10 @@ static OSStatus audioCallback (void *inRefCon,
assert(this->spec.channels == ioData->mNumberChannels); assert(this->spec.channels == ioData->mNumberChannels);
*/ */
remaining = ioData->mDataByteSize; for (i = 0; i < ioData->mNumberBuffers; i++) {
ptr = ioData->mData; abuf = &ioData->mBuffers[i];
remaining = abuf->mDataByteSize;
ptr = abuf->mData;
while (remaining > 0) { while (remaining > 0) {
if (bufferOffset >= bufferSize) { if (bufferOffset >= bufferSize) {
/* Generate the data */ /* Generate the data */
...@@ -136,6 +146,7 @@ static OSStatus audioCallback (void *inRefCon, ...@@ -136,6 +146,7 @@ static OSStatus audioCallback (void *inRefCon,
remaining -= len; remaining -= len;
bufferOffset += len; bufferOffset += len;
} }
}
return 0; return 0;
} }
...@@ -159,7 +170,7 @@ Uint8 *Core_GetAudioBuf(_THIS) ...@@ -159,7 +170,7 @@ Uint8 *Core_GetAudioBuf(_THIS)
void Core_CloseAudio(_THIS) void Core_CloseAudio(_THIS)
{ {
OSStatus result; OSStatus result;
struct AudioUnitInputCallback callback; struct AURenderCallbackStruct callback;
/* stop processing the audio unit */ /* stop processing the audio unit */
result = AudioOutputUnitStop (outputAudioUnit); result = AudioOutputUnitStop (outputAudioUnit);
...@@ -172,7 +183,7 @@ void Core_CloseAudio(_THIS) ...@@ -172,7 +183,7 @@ void Core_CloseAudio(_THIS)
callback.inputProc = 0; callback.inputProc = 0;
callback.inputProcRefCon = 0; callback.inputProcRefCon = 0;
result = AudioUnitSetProperty (outputAudioUnit, result = AudioUnitSetProperty (outputAudioUnit,
kAudioUnitProperty_SetInputCallback, kAudioUnitProperty_SetRenderCallback,
kAudioUnitScope_Input, kAudioUnitScope_Input,
0, 0,
&callback, &callback,
...@@ -203,7 +214,7 @@ int Core_OpenAudio(_THIS, SDL_AudioSpec *spec) ...@@ -203,7 +214,7 @@ int Core_OpenAudio(_THIS, SDL_AudioSpec *spec)
OSStatus result = noErr; OSStatus result = noErr;
Component comp; Component comp;
ComponentDescription desc; ComponentDescription desc;
struct AudioUnitInputCallback callback; struct AURenderCallbackStruct callback;
AudioStreamBasicDescription requestedDesc; AudioStreamBasicDescription requestedDesc;
/* Setup a AudioStreamBasicDescription with the requested format */ /* Setup a AudioStreamBasicDescription with the requested format */
...@@ -224,9 +235,9 @@ int Core_OpenAudio(_THIS, SDL_AudioSpec *spec) ...@@ -224,9 +235,9 @@ int Core_OpenAudio(_THIS, SDL_AudioSpec *spec)
/* Locate the default output audio unit */ /* Locate the default output audio unit */
desc.componentType = kAudioUnitComponentType; desc.componentType = kAudioUnitType_Output;
desc.componentSubType = kAudioUnitSubType_Output; desc.componentSubType = kAudioUnitSubType_DefaultOutput;
desc.componentManufacturer = kAudioUnitID_DefaultOutput; desc.componentManufacturer = kAudioUnitManufacturer_Apple;
desc.componentFlags = 0; desc.componentFlags = 0;
desc.componentFlagsMask = 0; desc.componentFlagsMask = 0;
...@@ -256,7 +267,7 @@ int Core_OpenAudio(_THIS, SDL_AudioSpec *spec) ...@@ -256,7 +267,7 @@ int Core_OpenAudio(_THIS, SDL_AudioSpec *spec)
callback.inputProc = audioCallback; callback.inputProc = audioCallback;
callback.inputProcRefCon = this; callback.inputProcRefCon = this;
result = AudioUnitSetProperty (outputAudioUnit, result = AudioUnitSetProperty (outputAudioUnit,
kAudioUnitProperty_SetInputCallback, kAudioUnitProperty_SetRenderCallback,
kAudioUnitScope_Input, kAudioUnitScope_Input,
0, 0,
&callback, &callback,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment