How to get OpenAL working with Torque in Mac OSX "Tiger"
by Tim Newell · 08/07/2005 (1:05 am) · 6 comments
Download Code File
I decided to make a resource on this because looking through the forums can be very confusing on exactly how this problem is fixed. I am detailing what was required to get it working on my mac mini with Tiger. Either way I have links in this article on some important threads I used to get it to work. I'll start with a background then get into the tutorial.
Josh at GG told me why the problem was caused and what to look for on the forums and web to fix my problem. Many hours of searching later I found it. This problem will be fixed in the next release of Torque and Torque2d but here is the fix now if you cannot wait that long. :) This article will show you what you need to modify in xcode 2.0 to get Openal working in Torque and Torque 2d on Mac OSX "Tiger". The reason you have no sound on Tiger is because it comes bundled with OpenAL 1.2 and Torque only works with version 1.0.8. So the solution is to compile your framework from the 1.0.8 source from the cvs on openal.org (from Mac pre 1.2 tag) and bundle it in your App's executable folder (MyApp.app/Contents/Frameworks) To save from explaining how to compile the framework to work this way and to keep you from having to download the openal cvs and compile it, I have included a zip file containing the OpenAL.Framework compiled for you. You simply need to drop it into Torque/lib/openal/macosx (you will have to create the macosx directory. You can also put it anywhere you want, this was just a recommended directory that was recommended in Paul Scott's .plan See his plan if you want to compile the framework yourself at www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=8300)
After doing Paul Scott's .plan torque would still not load the correct version of openal for me (you can check console to see what version loads, at this point mine kept loading 1.2) So I was searching the forums and found this thread: www.garagegames.com/mg/forums/result.thread.php?qt=27401
Using David "FenrirWolf" Grace's Source code fix to make Torque look in your Myapp.app/Contents/Frameworks first before looking in the system made Torque load the correct version (1.0.8). And after that I was done. Now on to the tutorial on exactly what you need to do to get this working.
Step 1: Download the zip file with this tutorial and unzip it to Torque/lib/openal/macosx folder then open Xcode 2.0.
Step 2: You need to add this framework to your project. Click on the frameworks folder in the left pane and right click it and Add->Existing Frameworks. then navigate to the OpenAL.framework and click add.
Step 3: Setup a Copy Files build step to copy the files over after compile (This saves you from having to hand copy over the framework) Expand the Targets in the left pane and choose your compile target (the executable your compiling) and expand that to see all of its build steps. If the last step is already a Copy Files then you don't need to add one just edit it. If you do not have one then right click your target and click Add->New Build Phase->New Copy Files Build Phase. You need to set the properties of the Copy Files step to Frameworks under Destination Drop Down. (you can bring this up by right clicking the Copy Files build step and click Get Info.. leave the other path empty) Now all you need to do is click on the frameworks folder.. then click on the OpenAL.framework and drag it to the Copy Files build step. This will setup xcode to copy those files into the frameworks directory in your executables folder automatically for you.
Step 4: Make the code changes to macCarbWindow.cc (located in platformMacCarb folder). Open that file and go down to around line 188 where you see the line *bundlePtr = NULL; Before that line you need to paste the following code. (code originally posted by David "FenrirWolf" Grace in forum post linked above)
Now all is left is to compile your code. If you get a compile error after copying it over, make sure you removed the newline that broke the long line in the middle of the code. You can test to see if it worked by opening the console after starting torque and see if it says OpenAL version 1.2 or 1.0.8. If it says 1.0.8 then you are good to go.
I'd like to Thank Josh, Paul, and David for their help and contributions.
-Tim
I decided to make a resource on this because looking through the forums can be very confusing on exactly how this problem is fixed. I am detailing what was required to get it working on my mac mini with Tiger. Either way I have links in this article on some important threads I used to get it to work. I'll start with a background then get into the tutorial.
Josh at GG told me why the problem was caused and what to look for on the forums and web to fix my problem. Many hours of searching later I found it. This problem will be fixed in the next release of Torque and Torque2d but here is the fix now if you cannot wait that long. :) This article will show you what you need to modify in xcode 2.0 to get Openal working in Torque and Torque 2d on Mac OSX "Tiger". The reason you have no sound on Tiger is because it comes bundled with OpenAL 1.2 and Torque only works with version 1.0.8. So the solution is to compile your framework from the 1.0.8 source from the cvs on openal.org (from Mac pre 1.2 tag) and bundle it in your App's executable folder (MyApp.app/Contents/Frameworks) To save from explaining how to compile the framework to work this way and to keep you from having to download the openal cvs and compile it, I have included a zip file containing the OpenAL.Framework compiled for you. You simply need to drop it into Torque/lib/openal/macosx (you will have to create the macosx directory. You can also put it anywhere you want, this was just a recommended directory that was recommended in Paul Scott's .plan See his plan if you want to compile the framework yourself at www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=8300)
After doing Paul Scott's .plan torque would still not load the correct version of openal for me (you can check console to see what version loads, at this point mine kept loading 1.2) So I was searching the forums and found this thread: www.garagegames.com/mg/forums/result.thread.php?qt=27401
Using David "FenrirWolf" Grace's Source code fix to make Torque look in your Myapp.app/Contents/Frameworks first before looking in the system made Torque load the correct version (1.0.8). And after that I was done. Now on to the tutorial on exactly what you need to do to get this working.
Step 1: Download the zip file with this tutorial and unzip it to Torque/lib/openal/macosx folder then open Xcode 2.0.
Step 2: You need to add this framework to your project. Click on the frameworks folder in the left pane and right click it and Add->Existing Frameworks. then navigate to the OpenAL.framework and click add.
Step 3: Setup a Copy Files build step to copy the files over after compile (This saves you from having to hand copy over the framework) Expand the Targets in the left pane and choose your compile target (the executable your compiling) and expand that to see all of its build steps. If the last step is already a Copy Files then you don't need to add one just edit it. If you do not have one then right click your target and click Add->New Build Phase->New Copy Files Build Phase. You need to set the properties of the Copy Files step to Frameworks under Destination Drop Down. (you can bring this up by right clicking the Copy Files build step and click Get Info.. leave the other path empty) Now all you need to do is click on the frameworks folder.. then click on the OpenAL.framework and drag it to the Copy Files build step. This will setup xcode to copy those files into the frameworks directory in your executables folder automatically for you.
Step 4: Make the code changes to macCarbWindow.cc (located in platformMacCarb folder). Open that file and go down to around line 188 where you see the line *bundlePtr = NULL; Before that line you need to paste the following code. (code originally posted by David "FenrirWolf" Grace in forum post linked above)
// first, lets 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 apps 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 Torques usual bundle load logicNow all is left is to compile your code. If you get a compile error after copying it over, make sure you removed the newline that broke the long line in the middle of the code. You can test to see if it worked by opening the console after starting torque and see if it says OpenAL version 1.2 or 1.0.8. If it says 1.0.8 then you are good to go.
I'd like to Thank Josh, Paul, and David for their help and contributions.
-Tim
About the author
#2
08/08/2005 (11:38 pm)
We need more good Mac info like this! Great work, Tim.
#3
08/17/2005 (4:35 am)
I followed these instructions to get OpenAL working on Mac OS X 10.3.9 - Because I wasn't getting any sound at all. Now; in the console it shows that OpenAL 1.0.8 is loaded. But I'm still not getting any sound... Any clues that might prevent the sound from playing still? Or does this patch solely work for Mac OS X "Tiger"?
#4
08/30/2005 (8:47 pm)
I'm not completely sure as I dont have 10.3.9 to test on. But Id assume that it would work on the older ones as well. Have you tried other torque stuff to see if it works on your system?
#5
08/31/2005 (7:07 pm)
Bless you Tim!!! This saved my buttocks.
#6
09/30/2006 (2:59 am)
I'm having trouble with this... have stepped thru the code and David Grace's search for frameworks in the local app. bundle is working correctly and finding openal, however the console is still reporting openal 1.1, and of course no sound... I'm running Tiger on a Mac Mini. Anyone have any ideas....?
Torque Owner Edward Gardner