Jump to content

Releasing OpenAL Sound Buffers


OTHGMars

Recommended Posts

I'm posting this here hoping to save someone debugging time. We use looping music during our game menus and the music changes as you switch menus. I noticed memory usage would increase every time the music changed. You can see the issue with devhead or release and full template by doing the following:

Launch game, make sure OpenAL is the sound provider and open the guiMusicPlayer.

exec("core/scripts/gui/guiMusicPlayer.cs"); toggleMusicPlayer();

Select "art/sound/environment/amb.ogg" (because it's big).

Click play, then stop and repeat several times while watching the apps memory usage and you'll see the memory usage continue to climb and never return to it's original baseline state. If you then switch to DirectSound and repeat the experiment, you'll see the baseline memory usage remains pretty constant.

The problem turned out to be related to the sound streaming. The descriptions are set to isStreaming = true; If those are changed to isStreaming = false; both OpenAL and DirectSound release all memory reserved for the sound buffers when the sound is stopped and do not hold a large chunk until the app exits. Another work-around would be to manage all of the sound sources from script and not recreate them as the sounds are played/stopped, but in our case in addition to menus, we have multiple music tracks that will play depending on where the user is in a level, so that is not an appealing option.

Link to comment
Share on other sites

I'm having some issues with OpenAL streaming buffers trying to fix the broken SFXSound::setPosition(x), too.

Maybe it's related, thanks for the info.


By the way, if anybody wants to test streaming sounds make them from sound files longer than 24 seconds. Otherwise they're internally treated like non-streaming samples and the issues don't show.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...