Embedding OpenAL inside app bundle
by Fenrir Wolf · in Torque Game Engine · 03/15/2005 (3:53 am) · 6 replies
Okay, after wrangling with Torque for a few hours after seeing this thread, I've managed to get OpenAL framework loading from the application bundle.
First, you'll need to compile the application as usual. Make sure the OpenAL framework lives in /Library/Frameworks, otherwise Xcode isn't happy. You will need to add a build step to copy files. Set the destination directory to frameworks. Then drag your OpenAL reference from frameworks into that directory.
Next, modify macCarbWindow.cc. Scroll down to around line 188 (in LoadFrameworkBundle). Add this section of code before *bundlePtr = NULL;:
What this does is first look in the application's bundle, under frameworks. Therefore, if you add the build step I talked about above, OpenAL should now load from inside the app bundle. You can remove it from Library/Frameworks to test it out.
I haven't tested my code on another Mac to make sure this is good, but I suspect it is.
(That should have been BEFORE *bundleptr, not after.)
First, you'll need to compile the application as usual. Make sure the OpenAL framework lives in /Library/Frameworks, otherwise Xcode isn't happy. You will need to add a build step to copy files. Set the destination directory to frameworks. Then drag your OpenAL reference from frameworks into that directory.
Next, modify macCarbWindow.cc. Scroll down to around line 188 (in LoadFrameworkBundle). Add this section of code before *bundlePtr = NULL;:
*bundlePtr = NULL;
// first, let's look in our app bundle, under frameworks
CFURLRef privFrameworksURL = NULL ;
CFBundleRef appBundle = NULL;
appBundle = CFBundleGetMainBundle();
bool localfind = false ;
privFrameworksURL = CFBundleCopyPrivateFrameworksURL (appBundle) ;
if (privFrameworksURL) {
bundleURL = CFURLCreateCopyAppendingPathComponent(kCFAllocatorSystemDefault, privFrameworksURL, framework, false);
if (bundleURL) {
*bundlePtr = CFBundleCreate(kCFAllocatorSystemDefault, bundleURL);
if (*bundlePtr) {
if ( CFBundleLoadExecutable( *bundlePtr ) ) {
//found it under the app's private framework
localfind = true ;
}
}
}
}
if (privFrameworksURL)
CFRelease (privFrameworksURL) ;
if (bundleURL)
CFRelease (bundleURL) ;
if (*bundlePtr)
CFRelease(*bundlePtr);
if (localfind) // Yay! We found it, so return with no error..
return noErr ;
// Otherwise, fall through to Torque's usual bundle load logicWhat this does is first look in the application's bundle, under frameworks. Therefore, if you add the build step I talked about above, OpenAL should now load from inside the app bundle. You can remove it from Library/Frameworks to test it out.
I haven't tested my code on another Mac to make sure this is good, but I suspect it is.
(That should have been BEFORE *bundleptr, not after.)
#2
Macintosh HD/System/Library/Frameworks
However, I still get no sound effects! I don't under stand the build step you're talking about. I just got this Mac yesterday so a better description of how to add that build step would help. Thanks!
04/16/2005 (4:02 pm)
I used the code you posted and I have the AGL.Framework under Macintosh HD/System/Library/Frameworks
However, I still get no sound effects! I don't under stand the build step you're talking about. I just got this Mac yesterday so a better description of how to add that build step would help. Thanks!
#3
04/16/2005 (4:14 pm)
Figured it out.
#4
04/16/2005 (10:27 pm)
I still can't get the sound to work no matter where I put the OpenAL.framework. It appears to be copied anyway if you just place the OpenAL.framework in your Torque SDK /lib/openal/macCarb folder. Adding the second copy phase seems to be redundant as it's already including the framework in the bundle if I'm not mistaken ... so long as you actually have the framework in that /lib/openal/macCarb folder. Ugh!
#5
04/17/2005 (4:03 pm)
Well, I got the old drivers ... but I can't seem to get it included in the App bundle ... or rather I can't get the Torque app to use the version of OpenAL included in the bundle. It always tries to reference the one on the mac and if I delete it like you suggested then the Torque app won't even start.
Torque Owner Jeff Greenland