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?
You should allocate as many sources as you can at game startup, and leave them alone until game exit.
Cas :)
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?
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 :)