The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
OS X deprecated warning about deprecated Carbon Audio units
Dominus


Joined: 13 Oct 2009
Posts: 127
When I start our app Exult, I get the warning:
Quote:
WARNING: 140: This application, or a library it uses, is using the deprecated Carbon Component Manager for hosting Audio Units. Support for this will be removed in a future release. Also, this makes the host incompatible with version 3 audio units. Please transition to the API's in AudioComponent.h.

Since we got rid of this, I think this comes from your code.
From what I understand your CoreAudio code kept things compatible to OS X version <=10.5. Since you support only 10.7 and above you can discard some of that code and use the same code as the iOS one.

I made these changes that I need to confirm yet but from what we did in Exult and ScummVM did, this looks mostly correct.
I'm posting this first here before I do it in bugzilla, since I first need to test this. Most importantly, do you think I'm right or totally wrong?

Code:
diff --git a/src/audio/coreaudio/SDL_coreaudio.c b/src/audio/coreaudio/SDL_coreaudio.c
--- a/src/audio/coreaudio/SDL_coreaudio.c
+++ b/src/audio/coreaudio/SDL_coreaudio.c
@@ -406,13 +406,7 @@
             AudioUnitSetProperty(this->hidden->audioUnit,
                                  kAudioUnitProperty_SetRenderCallback,
                                  scope, bus, &callback, sizeof(callback));
-
-            #if MACOSX_COREAUDIO
-            CloseComponent(this->hidden->audioUnit);
-            #else
             AudioComponentInstanceDispose(this->hidden->audioUnit);
-            #endif
-
             this->hidden->audioUnitOpened = 0;
         }
         SDL_free(this->hidden->buffer);
@@ -482,13 +476,8 @@
 {
     OSStatus result = noErr;
     AURenderCallbackStruct callback;
-#if MACOSX_COREAUDIO
-    ComponentDescription desc;
-    Component comp = NULL;
-#else
     AudioComponentDescription desc;
     AudioComponent comp = NULL;
-#endif
     const AudioUnitElement output_bus = 0;
     const AudioUnitElement input_bus = 1;
     const AudioUnitElement bus = ((iscapture) ? input_bus : output_bus);
@@ -507,11 +496,10 @@
 
 #if MACOSX_COREAUDIO
     desc.componentSubType = kAudioUnitSubType_DefaultOutput;
-    comp = FindNextComponent(NULL, &desc);
 #else
     desc.componentSubType = kAudioUnitSubType_RemoteIO;
+#endif
     comp = AudioComponentFindNext(NULL, &desc);
-#endif
 
     if (comp == NULL) {
         SDL_SetError("Couldn't find requested CoreAudio component");
@@ -519,17 +507,12 @@
     }
 
     /* Open & initialize the audio unit */
-#if MACOSX_COREAUDIO
-    result = OpenAComponent(comp, &this->hidden->audioUnit);
-    CHECK_RESULT("OpenAComponent");
-#else
     /*
        AudioComponentInstanceNew only available on iPhone OS 2.0 and Mac OS X 10.6
        We can't use OpenAComponent on iPhone because it is not present
      */
     result = AudioComponentInstanceNew(comp, &this->hidden->audioUnit);
     CHECK_RESULT("AudioComponentInstanceNew");
-#endif
 
     this->hidden->audioUnitOpened = 1;
 
diff --git a/src/audio/coreaudio/SDL_coreaudio.h b/src/audio/coreaudio/SDL_coreaudio.h
--- a/src/audio/coreaudio/SDL_coreaudio.h
+++ b/src/audio/coreaudio/SDL_coreaudio.h
@@ -32,9 +32,9 @@
 #if MACOSX_COREAUDIO
 #include <CoreAudio/CoreAudio.h>
 #include <CoreServices/CoreServices.h>
-#else
+#endif
 #include <AudioToolbox/AudioToolbox.h>
-#endif
+
 
 #include <AudioUnit/AudioUnit.h>
Dominus


Joined: 13 Oct 2009
Posts: 127
With my little test of Exult, CoreAudio does still work with these changes and the deprecated warning is gone.
OS X deprecated warning about deprecated Carbon Audio units
Alex Szpakowski
Guest

SDL for OS X must be built using the 10.7 or newer SDK, however it still deploys down to Mac OS 10.5 at runtime.

That said, I’m very much in favor of dropping runtime support for OS X 10.5 – even Steam hasn’t supported 10.5 for a while now. I’d still expect 10.6 to be supported though.

There is also an existing bugzilla report for removing the remaining Carbon code inside SDL: https://bugzilla.libsdl.org/show_bug.cgi?id=1756
The warning you got hasn’t been posted there yet though.

Quote:
On Sep 21, 2015, at 5:21 PM, Dominus wrote:
From what I understand your CoreAudio code kept things compatible to OS X version <=10.5. Since you support only 10.7 and above you can discard some of that code and use the same code as the iOS one.

Dominus


Joined: 13 Oct 2009
Posts: 127
Right, I see about 10.5 deployment. This can be fixed by additional
#if MAC_OS_X_VERSION_MAX_ALLOWED <= 1050

(which will make it that much uglier... Smile)

I'll add an updated patch.

My bug report about this is https://bugzilla.libsdl.org/show_bug.cgi?id=3127
Dominus


Joined: 13 Oct 2009
Posts: 127
Added three patches to my bug report https://bugzilla.libsdl.org/show_bug.cgi?id=3127
- for SDL2, removing 10.5 compatibility
- for SDL2, keeping 10.5 compatibility
- for SDL1.2x Smile
Dominus


Joined: 13 Oct 2009
Posts: 127
On the keeping OS X 10.5 as deployment system...
How does one even compile an app with anything other than SDK 10.5 (or smaller) so that it works on an actual 10.5 machine?
I'm always stumbling over the /usr/lib/libstdc++.6.dylib problem (http://stackoverflow.com/questions/16358957/os-x-10-6sdk-compatible-with-10-5-leopard-system-znkst13bad-exception4whatev) and the app always crashes on 10.5...