Possible fix for OpenAL problems...
by Jim Rowley · in Torque Game Engine · 03/03/2004 (12:48 am) · 7 replies
In AudioBuffer::getALBuffer() there seems to be a problem.
...
if (alIsBuffer(malBuffer))
return malBuffer;
alGenBuffers(1, &malBuffer);
...
The problem with this code is that when malBuffer is initialized to zero, current openAL source code will return TRUE for alIsBuffer() -- who knows why it does that -- but it causes Torque to return without creating the buffer. This has caused me many crashes and headaches with Torque sound. When I change the first line above to this, it works much better:
if (malBuffer && alIsBuffer(malBuffer))
return malBuffer;
...
if (alIsBuffer(malBuffer))
return malBuffer;
alGenBuffers(1, &malBuffer);
...
The problem with this code is that when malBuffer is initialized to zero, current openAL source code will return TRUE for alIsBuffer() -- who knows why it does that -- but it causes Torque to return without creating the buffer. This has caused me many crashes and headaches with Torque sound. When I change the first line above to this, it works much better:
if (malBuffer && alIsBuffer(malBuffer))
return malBuffer;
#2
--Rick
03/05/2004 (8:37 am)
OpenAL while a great idea has been a moving target since we started using it. If you can generate a patch for me I will roll you changes into the HEAD. Thanks for all the work.--Rick
#3
03/05/2004 (8:26 pm)
Is there a preferred method of submitting a patch?
#5
03/06/2004 (10:34 pm)
Thanks Nicolas, I just emailed it...
#6
01/03/2005 (2:44 pm)
Aparently this patch didn't make it into 1.3 cvs is there a reason for that?
#7
-c
01/03/2005 (3:10 pm)
Hmm ok I just put in a test to see if alIsBuffer returns true when malBuffer is null and aparently it doesn't, at least for me. perhaps this has been changed in openal? or maybe the patch that was made fixed it? either way looks like this is not my problem :)-c
Torque 3D Owner Jim Rowley
I wrote to Garin Heibert of the OpenAL community asking why OpenAL always returns true now for alIsBuffer(0). This was his reply:
Upon further testing, I've found that Torque should be able to use its original code above using buffer zero when EAX is properly bound... OpenAL has a fix built in now which holds a valid buffer zero whenever EAX is present. The HEAD version of Torque which I have is having an issue because it is trying to check alIsExtensionPresent("EAX") before it has created a valid context to check for the extension. In the HEAD version, that line is commented out, and the EAX functions are just bound all the time regardless. This causes crashing when EAX is not truly present through OpenAL (because buffer0 is then never created).
I have made a change to Torque which defers checking for EAX until after a context is created and made current. This change allows the original code above to function with plain-vanilla OpenAL on my system now, and everything is working for me. This change may also help if someone is going to attempt to re-implement the EAX environment code. Personally, I would still recommend implementing the change I mentioned above as well, so that Torque doesn't try to use buffer zero for purposes other than what AL needs it for.
Yay ! :
blah blah blah...
Loading compiled script common/client/cursor.cs.
Loading compiled script common/client/help.cs.
Loading compiled script common/client/recordings.cs.
OpenAL Driver Init:
OpenAL
Vendor: Creative Labs Inc.
Version: OpenAL version 1.0
Renderer: Sound Blaster Audigy
Extensions: EAX
EAX1.0
EAX2.0
EAX3.0
EAX-AC3
Loading compiled script fps/client/scripts/audioProfiles.cs.
Loading compiled script fps/client/ui/defaultGameProfiles.cs.
blah blah blah...