LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: baegsi on February 04, 2005, 18:15:41

Title: Resource management in OpenAL
Post by: baegsi on February 04, 2005, 18:15:41
When should I create source and buffer objects in OpenAL? Currently, I allocate all sound buffers that are needed at loading time, but the sources are created and deleted on demand during execution time (the game's main loop). I'm not sure if this is the best way to do regarding memory management vs. performance. What do you think?
Title: Resource management in OpenAL
Post by: princec on February 05, 2005, 14:23:11
You should allocate as many sources as you can at game startup, and leave them alone until game exit.

Cas :)
Title: Resource management in OpenAL
Post by: baegsi on February 07, 2005, 14:27:57
Thanks! Is there a way to find out how many source objects are available? Would it have a drawback to create more sources than needed?
Title: Resource management in OpenAL
Post by: princec on February 07, 2005, 16:28:38
The current implementation of AL is a bit crappy here, but it seems that you could try allocating one source at a time until it returns a failure code. It only allows hardware sources so it should always give you maximum performance for a given number of sources.

Cas :)