aboutsummaryrefslogtreecommitdiff
path: root/backends/midi
diff options
context:
space:
mode:
authorMax Horn2011-12-28 23:13:39 +0100
committerMax Horn2012-01-14 19:36:24 +0100
commitad1c2a45f12bb5401ae5c0d73ef948dea734c467 (patch)
tree9d209869334a3159c68c7859790840e27c08f65a /backends/midi
parent22e00a710fe98b291d7b0972fb32f2b18a37efc8 (diff)
downloadscummvm-rg350-ad1c2a45f12bb5401ae5c0d73ef948dea734c467.tar.gz
scummvm-rg350-ad1c2a45f12bb5401ae5c0d73ef948dea734c467.tar.bz2
scummvm-rg350-ad1c2a45f12bb5401ae5c0d73ef948dea734c467.zip
MACOSX: Default to new CoreAudio API on x86, and to old on PowerPC
The new API has been present since Mac OS X 10.5 (released four years ago, in October 2007), and also since iOS 2.0 (thus, the iOS port may be able to use it, too). Moreover, 10.5 was the last system to support PowerPC.
Diffstat (limited to 'backends/midi')
-rw-r--r--backends/midi/coreaudio.cpp44
1 files changed, 29 insertions, 15 deletions
diff --git a/backends/midi/coreaudio.cpp b/backends/midi/coreaudio.cpp
index 4b707eace6..0c251a2d8d 100644
--- a/backends/midi/coreaudio.cpp
+++ b/backends/midi/coreaudio.cpp
@@ -27,22 +27,36 @@
#ifdef MACOSX
-// HACK to disable deprecated warnings under Mac OS X 10.5. Apple deprecated the
+// 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.
-// If you want to retain compatibility with old systems, enable the following
-// switch. But Apple will eventually remove these APIs, at which point the
-// switch needs to be disabled.
//
-// Also note that only the new API is available on the iPhone!
-#define USE_DEPRECATED_COREAUDIO_API
-
+// 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
+ #define USE_DEPRECATED_COREAUDIO_API 1
+ #else
+ #define USE_DEPRECATED_COREAUDIO_API 0
+ #endif
+#endif
-#ifdef USE_DEPRECATED_COREAUDIO_API
-#include <AvailabilityMacros.h>
-#undef DEPRECATED_ATTRIBUTE
-#define DEPRECATED_ATTRIBUTE
+#if USE_DEPRECATED_COREAUDIO_API
+ #include <AvailabilityMacros.h>
+ // Try to silence warnings about use of deprecated APIs
+ #undef DEPRECATED_ATTRIBUTE
+ #define DEPRECATED_ATTRIBUTE
#endif
@@ -114,7 +128,7 @@ int MidiDriver_CORE::open() {
RequireNoErr(NewAUGraph(&_auGraph));
AUNode outputNode, synthNode;
-#ifdef USE_DEPRECATED_COREAUDIO_API
+#if USE_DEPRECATED_COREAUDIO_API
ComponentDescription desc;
#else
AudioComponentDescription desc;
@@ -126,7 +140,7 @@ int MidiDriver_CORE::open() {
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
desc.componentFlags = 0;
desc.componentFlagsMask = 0;
-#ifdef USE_DEPRECATED_COREAUDIO_API
+#if USE_DEPRECATED_COREAUDIO_API
RequireNoErr(AUGraphNewNode(_auGraph, &desc, 0, NULL, &outputNode));
#else
RequireNoErr(AUGraphAddNode(_auGraph, &desc, &outputNode));
@@ -136,7 +150,7 @@ int MidiDriver_CORE::open() {
desc.componentType = kAudioUnitType_MusicDevice;
desc.componentSubType = kAudioUnitSubType_DLSSynth;
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
-#ifdef USE_DEPRECATED_COREAUDIO_API
+#if USE_DEPRECATED_COREAUDIO_API
RequireNoErr(AUGraphNewNode(_auGraph, &desc, 0, NULL, &synthNode));
#else
RequireNoErr(AUGraphAddNode(_auGraph, &desc, &synthNode));
@@ -150,7 +164,7 @@ int MidiDriver_CORE::open() {
RequireNoErr(AUGraphInitialize(_auGraph));
// Get the music device from the graph.
-#ifdef USE_DEPRECATED_COREAUDIO_API
+#if USE_DEPRECATED_COREAUDIO_API
RequireNoErr(AUGraphGetNodeInfo(_auGraph, synthNode, NULL, NULL, NULL, &_synth));
#else
RequireNoErr(AUGraphNodeInfo(_auGraph, synthNode, NULL, &_synth));