diff options
author | Willem Jan Palenstijn | 2013-04-18 23:35:23 +0200 |
---|---|---|
committer | Willem Jan Palenstijn | 2013-05-08 20:40:58 +0200 |
commit | 9c2341678ef4984bf92b3878295250faf980b066 (patch) | |
tree | 2fb4805e05e16b9924e80c9947e6bad723b28c4b /backends/midi/coreaudio.cpp | |
parent | 8172d679df5148a4a32f46074b20cb6caf91844f (diff) | |
parent | a5f4ff36ffc386d48f2da49387a9655ce9295a4d (diff) | |
download | scummvm-rg350-9c2341678ef4984bf92b3878295250faf980b066.tar.gz scummvm-rg350-9c2341678ef4984bf92b3878295250faf980b066.tar.bz2 scummvm-rg350-9c2341678ef4984bf92b3878295250faf980b066.zip |
Merge branch 'master'
Diffstat (limited to 'backends/midi/coreaudio.cpp')
-rw-r--r-- | backends/midi/coreaudio.cpp | 56 |
1 files changed, 47 insertions, 9 deletions
diff --git a/backends/midi/coreaudio.cpp b/backends/midi/coreaudio.cpp index 305b462836..43c801287d 100644 --- a/backends/midi/coreaudio.cpp +++ b/backends/midi/coreaudio.cpp @@ -26,15 +26,38 @@ #ifdef MACOSX -// HACK to disable deprecated warnings under Mac OS X 10.5. -// Apple depracted the AUGraphNewNode & AUGraphGetNodeInfo APIs -// in favor of the new AUGraphAddNode & AUGraphNodeInfo APIs. -// While it would be trivial to switch to those, this would break -// binary compatibility with all pre-10.5 systems, so we don't want -// to do that just now. Maybe when 10.6 comes... :) #include <AvailabilityMacros.h> -#undef DEPRECATED_ATTRIBUTE -#define DEPRECATED_ATTRIBUTE + +// With the release of Mac OS X 10.5 in October 2007, Apple deprecated the +// AUGraphNewNode & AUGraphGetNodeInfo APIs in favor of the new AUGraphAddNode & +// AUGraphNodeInfo APIs. While it is easy to switch to those, it breaks +// compatibility with all pre-10.5 systems. +// +// Since 10.5 was the last system to support PowerPC, we use the old, deprecated +// APIs on PowerPC based systems by default. On all other systems (such as Mac +// OS X running on Intel hardware, or iOS running on ARM), we use the new API by +// default. +// +// This leaves Mac OS X 10.4 running on x86 processors as the only system +// combination that this code will not support by default. It seems quite +// reasonable to assume that anybody with an Intel system has since then moved +// on to a newer Mac OS X release. But if for some reason you absolutely need to +// build an x86 version of this code using the old, deprecated API, you can +// simply do so by manually enable the USE_DEPRECATED_COREAUDIO_API switch (e.g. +// by adding setting it suitably in CPPFLAGS). +#if !defined(USE_DEPRECATED_COREAUDIO_API) + #if TARGET_CPU_PPC || TARGET_CPU_PPC64 || !defined(MAC_OS_X_VERSION_10_6) + #define USE_DEPRECATED_COREAUDIO_API 1 + #else + #define USE_DEPRECATED_COREAUDIO_API 0 + #endif +#endif + +#if USE_DEPRECATED_COREAUDIO_API + // Try to silence warnings about use of deprecated APIs + #undef DEPRECATED_ATTRIBUTE + #define DEPRECATED_ATTRIBUTE +#endif #include "common/config-manager.h" @@ -105,7 +128,11 @@ int MidiDriver_CORE::open() { RequireNoErr(NewAUGraph(&_auGraph)); AUNode outputNode, synthNode; +#if USE_DEPRECATED_COREAUDIO_API ComponentDescription desc; +#else + AudioComponentDescription desc; +#endif // The default output device desc.componentType = kAudioUnitType_Output; @@ -113,13 +140,21 @@ int MidiDriver_CORE::open() { desc.componentManufacturer = kAudioUnitManufacturer_Apple; desc.componentFlags = 0; desc.componentFlagsMask = 0; +#if USE_DEPRECATED_COREAUDIO_API RequireNoErr(AUGraphNewNode(_auGraph, &desc, 0, NULL, &outputNode)); +#else + RequireNoErr(AUGraphAddNode(_auGraph, &desc, &outputNode)); +#endif // The built-in default (softsynth) music device desc.componentType = kAudioUnitType_MusicDevice; desc.componentSubType = kAudioUnitSubType_DLSSynth; desc.componentManufacturer = kAudioUnitManufacturer_Apple; +#if USE_DEPRECATED_COREAUDIO_API RequireNoErr(AUGraphNewNode(_auGraph, &desc, 0, NULL, &synthNode)); +#else + RequireNoErr(AUGraphAddNode(_auGraph, &desc, &synthNode)); +#endif // Connect the softsynth to the default output RequireNoErr(AUGraphConnectNodeInput(_auGraph, synthNode, 0, outputNode, 0)); @@ -129,8 +164,11 @@ int MidiDriver_CORE::open() { RequireNoErr(AUGraphInitialize(_auGraph)); // Get the music device from the graph. +#if USE_DEPRECATED_COREAUDIO_API RequireNoErr(AUGraphGetNodeInfo(_auGraph, synthNode, NULL, NULL, NULL, &_synth)); - +#else + RequireNoErr(AUGraphNodeInfo(_auGraph, synthNode, NULL, &_synth)); +#endif // Load custom soundfont, if specified if (ConfMan.hasKey("soundfont")) { |