Re: Attempting to use OpenAL in C++ for a video game
Chris Robinson <[email protected]>
| Newsgroups | gmane.comp.lib.openal |
|---|---|
| Message-ID | <[email protected]> |
Hi.
On Sunday, May 01, 2011 7:44:55 PM Colin DeClue wrote:
> // Create the Audio Buffers
> alGenBuffers( MAX_AUDIO_BUFFERS, mAudioBuffers );
[...]
> mAudioBuffers[bufferID] = alutCreateBufferFromFile(filename.c_str());
You're leaking buffers, here. The buffer IDs are first generated and stored by
alGenBuffers, and are then overwritten by the return value of
alutCreateBufferFromFile, which is a new buffer ID. If you're using
alutCreateBufferFromFile to load your sounds, there's no need for the
alGenBuffers (just make sure the buffer IDs are initialized to 0, instead of
leaving the array filled with random memory).
> mAudioBuffers[bufferID] = alutCreateBufferFromFile(filename.c_str());
> if ( checkALError("loadWAV::alutCreateBufferFromFile: ") )
> return false;
That's not the right way to check for Alut errors. The function will return 0
if loading fails, it doesn't generate an AL error.
Make sure the filename being given to Alut is correct (print it out somewhere
right before calling to verify), if you can. Also, make sure the sounds are
normal PCM wave. Alut doesn't handle MP3 or Ogg or anything fancy like that
(wav files can have MP3, or other compressed formats, sometimes).
If you're still having trouble, please write back.
_______________________________________________
Openal mailing list
[email protected]
http://opensource.creative.com/mailman/listinfo/openal