Skip to content

Commit

Permalink
coreaudio: fix build for older versions / against older sdks after co…
Browse files Browse the repository at this point in the history
…mmit 45055c6
  • Loading branch information
sezero committed Jul 18, 2020
1 parent a2047dc commit ba62b1c
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/audio/macosx/SDL_coreaudio.c
Expand Up @@ -33,6 +33,21 @@
#include "../SDL_sysaudio.h"
#include "SDL_coreaudio.h"

#if (MAC_OS_X_VERSION_MIN_REQUIRED < 1060) || \
(!defined(AUDIO_UNIT_VERSION) || ((AUDIO_UNIT_VERSION + 0) < 1060))
typedef struct ComponentDescription AudioComponentDesc_t;
typedef Component AudioComponent_t;
#define AudioComponentInstanceNew_fn OpenAComponent
#define AudioComponentInstanceDispose_fn CloseComponent
#define AudioComponentFindNext_fn FindNextComponent
#else
typedef AudioComponentDescription AudioComponentDesc_t;
typedef AudioComponent AudioComponent_t;
#define AudioComponentInstanceNew_fn AudioComponentInstanceNew
#define AudioComponentInstanceDispose_fn AudioComponentInstanceDispose
#define AudioComponentFindNext_fn AudioComponentFindNext
#endif


/* Audio driver functions */

Expand Down Expand Up @@ -193,7 +208,7 @@ void Core_CloseAudio(_THIS)
return;
}

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

Expand Down Expand Up @@ -241,14 +256,14 @@ int Core_OpenAudio(_THIS, SDL_AudioSpec *spec)
desc.componentFlags = 0;
desc.componentFlagsMask = 0;

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

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

result = AudioUnitInitialize (outputAudioUnit);
Expand Down

0 comments on commit ba62b1c

Please sign in to comment.