Skip to content

Commit

Permalink
coreaudio: Move off deprecated APIs.
Browse files Browse the repository at this point in the history
Fixes SDL 1.2 audio on macOS 11.0 beta ("Big Sur").
  • Loading branch information
icculus committed Jul 17, 2020
1 parent 7bf353e commit a2047dc
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/audio/macosx/SDL_coreaudio.c
Expand Up @@ -193,7 +193,7 @@ void Core_CloseAudio(_THIS)
return;
}

result = CloseComponent(outputAudioUnit);
result = AudioComponentInstanceDispose(outputAudioUnit);
if (result != noErr) {
SDL_SetError("Core_CloseAudio: CloseComponent");
return;
Expand All @@ -212,8 +212,8 @@ void Core_CloseAudio(_THIS)
int Core_OpenAudio(_THIS, SDL_AudioSpec *spec)
{
OSStatus result = noErr;
Component comp;
ComponentDescription desc;
AudioComponent comp;
AudioComponentDescription desc;
struct AURenderCallbackStruct callback;
AudioStreamBasicDescription requestedDesc;

Expand All @@ -233,23 +233,23 @@ int Core_OpenAudio(_THIS, SDL_AudioSpec *spec)
requestedDesc.mBytesPerFrame = requestedDesc.mBitsPerChannel * requestedDesc.mChannelsPerFrame / 8;
requestedDesc.mBytesPerPacket = requestedDesc.mBytesPerFrame * requestedDesc.mFramesPerPacket;


/* Locate the default output audio unit */
SDL_memset(&desc, '\0', sizeof (desc));
desc.componentType = kAudioUnitType_Output;
desc.componentSubType = kAudioUnitSubType_DefaultOutput;
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
desc.componentFlags = 0;
desc.componentFlagsMask = 0;

comp = FindNextComponent (NULL, &desc);
comp = AudioComponentFindNext(NULL, &desc);
if (comp == NULL) {
SDL_SetError ("Failed to start CoreAudio: FindNextComponent returned NULL");
SDL_SetError ("Failed to start CoreAudio: AudioComponentFindNext returned NULL");
return -1;
}

/* Open & initialize the default output audio unit */
result = OpenAComponent (comp, &outputAudioUnit);
CHECK_RESULT("OpenAComponent")
result = AudioComponentInstanceNew (comp, &outputAudioUnit);
CHECK_RESULT("AudioComponentInstanceNew")

result = AudioUnitInitialize (outputAudioUnit);
CHECK_RESULT("AudioUnitInitialize")
Expand Down

0 comments on commit a2047dc

Please sign in to comment.