From 0d6e49a45dfc150c9ca973c27d3e246e2a0a195f Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 11 Aug 2012 23:21:14 -0700 Subject: [PATCH] Fixed bug 1566 - make native_midi_osx to use AUGraphAddNode() on 10.5 Ozkan Sezer 2012-08-10 02:53:51 PDT Current native_midi_osx uses AUGraphAddNode() only on 10.6 because of struct AudioComponentDescription being a 10.6 SDK thing. However, AudioComponentDescription is actually the same as struct ComponentDescription with 20 bytes of size and the same offsets of all members, therefore, is binary compatible. So, defining AudioComponentDescription as ComponentDescription when compiling against 10.5 SDK does the trick. A patch is attached. --- native_midi/native_midi_macosx.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/native_midi/native_midi_macosx.c b/native_midi/native_midi_macosx.c index 8fefbc96..38ffee06 100644 --- a/native_midi/native_midi_macosx.c +++ b/native_midi/native_midi_macosx.c @@ -26,7 +26,8 @@ #if __MACOSX__ -#include +#include /* ComponentDescription */ +#include #include #include @@ -107,7 +108,7 @@ GetSequenceAudioUnit(MusicSequence sequence, AudioUnit *aunit) if (AUGraphGetIndNode(graph, i, &node) != noErr) continue; /* better luck next time. */ -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 /* this is deprecated, but works back to 10.0 */ +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1050 /* this is deprecated, but works back to 10.0 */ { struct ComponentDescription desc; UInt32 classdatasize = 0; @@ -123,6 +124,14 @@ GetSequenceAudioUnit(MusicSequence sequence, AudioUnit *aunit) } #else /* not deprecated, but requires 10.5 or later */ { + # if !defined(AUDIO_UNIT_VERSION) || ((AUDIO_UNIT_VERSION + 0) < 1060) + /* AUGraphAddNode () is changed to take an AudioComponentDescription* + * desc parameter instead of a ComponentDescription* in the 10.6 SDK. + * AudioComponentDescription is in 10.6 or newer, but it is actually + * the same as struct ComponentDescription with 20 bytes of size and + * the same offsets of all members, therefore, is binary compatible. */ + # define AudioComponentDescription ComponentDescription + # endif AudioComponentDescription desc; if (AUGraphNodeInfo(graph, node, &desc, aunit) != noErr) continue;