backport fix for bug #1566. (2.0 commits a9a8e029a84b, 180ef9af767b). SDL-1.2
authorOzkan Sezer <sezeroz@gmail.com>
Sat, 06 Oct 2018 23:39:50 +0300
branchSDL-1.2
changeset 8669b5e07988c0f
parent 865 3ffb22a2755b
child 867 e15d7af3e3b6
backport fix for bug #1566. (2.0 commits a9a8e029a84b, 180ef9af767b).
native_midi/native_midi_macosx.c
     1.1 --- a/native_midi/native_midi_macosx.c	Sat Oct 06 23:20:10 2018 +0300
     1.2 +++ b/native_midi/native_midi_macosx.c	Sat Oct 06 23:39:50 2018 +0300
     1.3 @@ -26,7 +26,8 @@
     1.4  
     1.5  #if __MACOSX__
     1.6  
     1.7 -#include <Carbon/Carbon.h>
     1.8 +#include <CoreServices/CoreServices.h>		/* ComponentDescription */
     1.9 +#include <AudioUnit/AudioUnit.h>
    1.10  #include <AudioToolbox/AudioToolbox.h>
    1.11  #include <AvailabilityMacros.h>
    1.12  
    1.13 @@ -107,7 +108,7 @@
    1.14          if (AUGraphGetIndNode(graph, i, &node) != noErr)
    1.15              continue;  /* better luck next time. */
    1.16  
    1.17 -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 /* this is deprecated, but works back to 10.0 */
    1.18 +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1050 /* this is deprecated, but works back to 10.0 */
    1.19          {
    1.20              struct ComponentDescription desc;
    1.21              UInt32 classdatasize = 0;
    1.22 @@ -123,6 +124,14 @@
    1.23          }
    1.24          #else  /* not deprecated, but requires 10.5 or later */
    1.25          {
    1.26 +        # if !defined(AUDIO_UNIT_VERSION) || ((AUDIO_UNIT_VERSION + 0) < 1060)
    1.27 +         /* AUGraphAddNode () is changed to take an AudioComponentDescription*
    1.28 +          * desc parameter instead of a ComponentDescription* in the 10.6 SDK.
    1.29 +          * AudioComponentDescription is in 10.6 or newer, but it is actually
    1.30 +          * the same as struct ComponentDescription with 20 bytes of size and
    1.31 +          * the same offsets of all members, therefore, is binary compatible. */
    1.32 +        #   define AudioComponentDescription ComponentDescription
    1.33 +        # endif
    1.34              AudioComponentDescription desc;
    1.35              if (AUGraphNodeInfo(graph, node, &desc, aunit) != noErr)
    1.36                  continue;
    1.37 @@ -185,10 +194,20 @@
    1.38      free(buf);
    1.39      buf = NULL;
    1.40  
    1.41 -    #if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 /* this is deprecated, but works back to 10.3 */
    1.42 +    #if MAC_OS_X_VERSION_MIN_REQUIRED < 1050
    1.43 +    /* MusicSequenceLoadSMFData() (avail. in 10.2, no 64 bit) is
    1.44 +     * equivalent to calling MusicSequenceLoadSMFDataWithFlags()
    1.45 +     * with a flags value of 0 (avail. in 10.3, avail. 64 bit).
    1.46 +     * So, we use MusicSequenceLoadSMFData() for powerpc versions
    1.47 +     * but the *WithFlags() on intel which require 10.4 anyway. */
    1.48 +    # if defined(__ppc__) || defined(__POWERPC__)
    1.49 +    if (MusicSequenceLoadSMFData(song->sequence, data) != noErr)
    1.50 +        goto fail;
    1.51 +    # else
    1.52      if (MusicSequenceLoadSMFDataWithFlags(retval->sequence, data, 0) != noErr)
    1.53          goto fail;
    1.54 -    #else  /* not deprecated, but requires 10.5 or later */
    1.55 +    # endif
    1.56 +    #else  /* MusicSequenceFileLoadData() requires 10.5 or later.  */
    1.57      if (MusicSequenceFileLoadData(retval->sequence, data, 0, 0) != noErr)
    1.58          goto fail;
    1.59      #endif