aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOystein Eftevaag2012-01-14 14:00:40 -0800
committerOystein Eftevaag2012-01-14 14:00:40 -0800
commit85c8bd6e655b42dfa84bc7c909a500917c48468a (patch)
tree676ccb5b217d9d908ac48d03bea9ddbb4635e31d
parentc4d9f7beebff75fc88a2da198f585963d0e3ea46 (diff)
parentf57b66e9845586a8457f68b52436ecbc97f80607 (diff)
downloadscummvm-rg350-85c8bd6e655b42dfa84bc7c909a500917c48468a.tar.gz
scummvm-rg350-85c8bd6e655b42dfa84bc7c909a500917c48468a.tar.bz2
scummvm-rg350-85c8bd6e655b42dfa84bc7c909a500917c48468a.zip
Merge pull request #157 from fingolfin/coreaudio
MACOSX: Use modern CoreAudio API on modern systems by default, cleanup
-rw-r--r--backends/midi/coreaudio.cpp44
-rw-r--r--gui/browser_osx.mm6
2 files changed, 30 insertions, 20 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));
diff --git a/gui/browser_osx.mm b/gui/browser_osx.mm
index 017b31b9a8..b8aa7c50ee 100644
--- a/gui/browser_osx.mm
+++ b/gui/browser_osx.mm
@@ -62,11 +62,7 @@ int BrowserDialog::runModal() {
NSOpenPanel * panel = [NSOpenPanel openPanel];
[panel setCanChooseDirectories:YES];
if ([panel runModalForTypes:nil] == NSOKButton) {
-#ifdef __POWERPC__
- const char *filename = [[panel filename] cString];
-#else
- const char *filename = [[panel filename] cStringUsingEncoding:NSUTF8StringEncoding];
-#endif
+ const char *filename = [[panel filename] UTF8String];
_choice = Common::FSNode(filename);
choiceMade = true;
}