PDA

View Full Version : [OpenAL] alDeleteSources is way too slow!



chronozphere
21-11-2007, 03:27 PM
Hey everyone :)

I got this little problem. When running my application, i see hickups when sounds stop playing.

When sound-sources have stopped playing, i delete them, when the "UpdateSound" routine is executed. I narrowed the whole problem down to the alDeleteSources routine.

I got this code:


procedure TN2D_SoundSource.Delete;
begin
if alIsSource(fSource) then
begin
BeepEx(1000,5);
alDeleteSources(1,@fSource);
BeepEx(800,5);
end;

inherited;
end;


When a sound stopped playing, this delete routine is called, and the soundsource will be destroyed. As you can see, i added 2 beeps in this routine. This way, i could easily check how long it takes to execute alDeleteSources.

Sometimes it just takes some miliseconds, and the two beeps are both played in a short period of time. But sometimes, it takes up to a second, before the game continues to execute.

Is this normal, or is there a sollution available?? Should i save up those stopped sounds, and delete 10 of them with a single call? Should i reuse the soundsources by changing their soundbuffers?

I know some of you guys have experience with OpenAL. Can someone give me a good hint on this?

Thanx a bunch :)

JernejL
21-11-2007, 05:53 PM
This doesn't seem right, it should delete right away..

Here's a useful hint: re-use sources instead of deleting them (just let them stay when not needed and when they are, queve another wave buffer.. ).

chronozphere
21-11-2007, 07:30 PM
Thanx! ;)... i'm going to try that. i will post again with any results :)

chronozphere
22-11-2007, 02:48 PM
I turns out that calling alSourcei(fSource,AL_BUFFER,?????); is also very slow.

I measured the time, and sometimes it took up to 3 seconds to execute this. This is realy weird since i have a realy up to date system (AMD Dual core, 2GB ram and Geforce 8600GT). :?

Any more tips?

JernejL
22-11-2007, 05:51 PM
change openal output device.. try installing creative's sdk..

P.S. you don't happen to be on vista, are you?

chronozphere
22-11-2007, 06:51 PM
P.S. you don't happen to be on vista, are you?


eeh... actualy i am :) Are there issues with vista then?

I rewrote my sound module. Now, i give each soundbuffer a predefined ammount of sources, so i dont have to change the buffer for any source. The problem seems to be solved, but ATM i have many unused sources. Is that a problem?

You have experience with OpenAL. Can you explain me how your Sound-module deals with buffers/sources?

Thanx ;)

JernejL
22-11-2007, 09:08 PM
P.S. you don't happen to be on vista, are you?


eeh... actualy i am :) Are there issues with vista then?

I rewrote my sound module. Now, i give each soundbuffer a predefined ammount of sources, so i dont have to change the buffer for any source. The problem seems to be solved, but ATM i have many unused sources. Is that a problem?

You have experience with OpenAL. Can you explain me how your Sound-module deals with buffers/sources?

Thanx ;)

There is a part on that in my sig :P

My OpenAL audio wrapper with Intelligent Source Manager:
http://www.pascalgamedevelopment.com/viewtopic.php?p=25428#25428

That's the exact thing i use in my game, plus some additional stuff, you can see it has some advanced stuff such as some soucre management, and sound distance culling, etc...

My openal lib just initializes all sources when it loads, and then uses the sources handles whenever it needs them.. it queves a wave buffer, and after it plays back it stops.

The wrapper for openal is more than just a wrapper and sources manager, it actually supports pausing the entire system at any state, which makes it possible in the future to actually halt the program, save the audio library state to disk, and reload it back later, i haven't implemented the actual routines for saving and loading yet, but it has everything ready for that and pausing already works.