Skip to content

Commit

Permalink
Merge pull request #157 from fingolfin/coreaudio
Browse files Browse the repository at this point in the history
MACOSX: Use modern CoreAudio API on modern systems by default, cleanup
  • Loading branch information
vinterstum committed Jan 14, 2012
2 parents c4d9f7b + f57b66e commit 85c8bd6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 20 deletions.
44 changes: 29 additions & 15 deletions backends/midi/coreaudio.cpp
Expand Up @@ -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


Expand Down Expand Up @@ -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;
Expand All @@ -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));
Expand All @@ -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));
Expand All @@ -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));
Expand Down
6 changes: 1 addition & 5 deletions gui/browser_osx.mm
Expand Up @@ -62,11 +62,7 @@
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;
}
Expand Down

0 comments on commit 85c8bd6

Please sign in to comment.