aboutsummaryrefslogtreecommitdiff
path: root/backends/midi
diff options
context:
space:
mode:
authorMax Horn2011-12-12 16:43:17 +0100
committerMax Horn2011-12-12 16:46:50 +0100
commit9095de46741c9044c2deff8ecfc911903203b6fe (patch)
tree77a73eeea52dcb61894618853f10665c3ca7e2ea /backends/midi
parent5bbca0293871f445d3738f2114069aaf69600340 (diff)
downloadscummvm-rg350-9095de46741c9044c2deff8ecfc911903203b6fe.tar.gz
scummvm-rg350-9095de46741c9044c2deff8ecfc911903203b6fe.tar.bz2
scummvm-rg350-9095de46741c9044c2deff8ecfc911903203b6fe.zip
MACOSX: Optionally allow building against "new" (10.5+) CoreAudio API
This silences a bunch of deprecation warnings when compiling on any current system. Moreover, the new API is available on the iPhone, so perhaps this is interesting for the iPhone port, too. On the long run, ScummVM will have to switch to the new API, as Apple will eventually drop the old one.
Diffstat (limited to 'backends/midi')
-rw-r--r--backends/midi/coreaudio.cpp38
1 files changed, 31 insertions, 7 deletions
diff --git a/backends/midi/coreaudio.cpp b/backends/midi/coreaudio.cpp
index 305b462836..4b707eace6 100644
--- a/backends/midi/coreaudio.cpp
+++ b/backends/midi/coreaudio.cpp
@@ -26,15 +26,24 @@
#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... :)
+
+// HACK to disable deprecated warnings under Mac OS X 10.5. 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
+
+
+#ifdef USE_DEPRECATED_COREAUDIO_API
#include <AvailabilityMacros.h>
#undef DEPRECATED_ATTRIBUTE
#define DEPRECATED_ATTRIBUTE
+#endif
#include "common/config-manager.h"
@@ -105,7 +114,11 @@ int MidiDriver_CORE::open() {
RequireNoErr(NewAUGraph(&_auGraph));
AUNode outputNode, synthNode;
+#ifdef USE_DEPRECATED_COREAUDIO_API
ComponentDescription desc;
+#else
+ AudioComponentDescription desc;
+#endif
// The default output device
desc.componentType = kAudioUnitType_Output;
@@ -113,13 +126,21 @@ int MidiDriver_CORE::open() {
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
desc.componentFlags = 0;
desc.componentFlagsMask = 0;
+#ifdef 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;
+#ifdef 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 +150,11 @@ int MidiDriver_CORE::open() {
RequireNoErr(AUGraphInitialize(_auGraph));
// Get the music device from the graph.
+#ifdef 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")) {