Streaming Audio problem
by Sam Redfern · in Torque Game Engine · 12/20/2006 (2:44 pm) · 12 replies
I've been wrestling with a strange problem (bug, I think?) with streaming audio (TGE1.4) and I think I have it narrowed down to this situation:
When a 2D streaming audio source is playing at the main menu, and is allowed to continue into the 3D game (which is what I would prefer to happen), then 3D looping sound sources in the game often play the wrong data: they actually play stuff out of the streaming source's buffers rather than their own, though with their own length, attenuation, and with looping on.
Is there some kind of initialisation that OpenAL does when the 3D world is entered? Is it an unspoken work-around that we're all encouraged to shut off menu music and start mission-specific music when we hit the 3D world?
When a 2D streaming audio source is playing at the main menu, and is allowed to continue into the 3D game (which is what I would prefer to happen), then 3D looping sound sources in the game often play the wrong data: they actually play stuff out of the streaming source's buffers rather than their own, though with their own length, attenuation, and with looping on.
Is there some kind of initialisation that OpenAL does when the 3D world is entered? Is it an unspoken work-around that we're all encouraged to shut off menu music and start mission-specific music when we hit the 3D world?
About the author
#2
12/21/2006 (6:04 am)
I'm not sure it has anything to do with what Sam describes, though I could be wrong and I probably am. I just wanted to chime in that I also had this issue back when I used the stock OpenAL Audio implementation.
#3
12/21/2006 (6:08 am)
Thanks Stefan... what else could it be though, given those precise symptoms?
#4
Here is one thread that I had bookmarked that you might find interesting and hopefully it has the solution to your problems.
Playing music problems alxSourcef
Edit: Scroll down until you find the part about void alxCloseHandles ().
Good luck!
12/21/2006 (6:22 am)
No clue. It could very well be what you described, I just can't remember that was the solution. It was a while ago though, so don't trust my memory.Here is one thread that I had bookmarked that you might find interesting and hopefully it has the solution to your problems.
Playing music problems alxSourcef
Edit: Scroll down until you find the part about void alxCloseHandles ().
Good luck!
#5
Anyway, I have given up and decided to use a shorter looping piece of music in the lobby and then fade it out and replace it with a longer streaming piece once the mission starts.. thanks..
12/21/2006 (6:30 am)
Yeah, I looked at that one yesterday.. I think they're talking about a slightly different bug! In any case, it didn't solve my problems, which don't seem to be related to culling quiet sounds. Anyway, I have given up and decided to use a shorter looping piece of music in the lobby and then fade it out and replace it with a longer streaming piece once the mission starts.. thanks..
#6
Ogg has some issues with situational sounds, Simply they get mixed up.
Its been my findings that ogg is good for steady music, or ambient music, and WAV is best used for the momentary sounds like, "Bip" "Boom" "Pow"!
12/21/2006 (6:46 am)
Are you using ogg or wav?Ogg has some issues with situational sounds, Simply they get mixed up.
Its been my findings that ogg is good for steady music, or ambient music, and WAV is best used for the momentary sounds like, "Bip" "Boom" "Pow"!
#7
12/21/2006 (7:01 am)
In my tests it did not matter whether I used OGG or not. At least not in 1.4 (though back in 1.12 that was the case)
#8
12/21/2006 (7:04 am)
I'm using ogg. I did try wav for the sound in the 3d world that triggered the problem, but it didn't help. It seems to be a streamsource problem rather than an ogg problem.
#9
Hopefully GG will be rewriting the audio code soon...
12/21/2006 (8:47 am)
There's quite a few issues with the audio code in Torque currently, including a few memory leaks (try streaming a large (a few MB) OGG file and watch the memory get used up but never released.Hopefully GG will be rewriting the audio code soon...
#10
http://www.garagegames.com/mg/forums/result.thread.php?qt=53220
Once we did that our memory footprint stopped increasing after streaming and restreaming music
12/28/2006 (8:37 pm)
One of my coworkers fixed the only streaming audio leak we found.http://www.garagegames.com/mg/forums/result.thread.php?qt=53220
Once we did that our memory footprint stopped increasing after streaming and restreaming music
#11
Thanks
12/29/2006 (1:36 am)
Don't suppose you would like to post that where everyone else can see it too? That is a Torque Game Builder's forum.Thanks
#12
http://www.garagegames.com/mg/forums/result.thread.php?qt=53220
12/29/2006 (11:40 am)
Reposting from Richard McKinney's post at http://www.garagegames.com/mg/forums/result.thread.php?qt=53220
Quote:There is a bug in the streaming ogg code that causes a 532,480 byte memory leak every time a streaming ogg is started and stopped. You can see more details on the bug here: http://www.garagegames.com/mg/forums/result.thread.php?qt=53193
Code to fix this leak follows. You can just add two lines to VorbisStreamSource, but I changed it like this:
In audio/VorbisStreamSource.h, add the following line in the private section (just above clearBuffers() is fine):
void deleteBuffers();
In audio/VorbisStreamSource.cc:
in VorbisStreamSource::Clear() change
if(mBufferList[0] != 0) alDeleteBuffers(NUMBUFFERS, mBufferList); for(int i = 0; i < NUMBUFFERS; i++) mBufferList[i] = 0;
to
deleteBuffers();
in VorbisStreamSource::freeStream() change
if(mBufferList[0] != 0) alDeleteBuffers(NUMBUFFERS, mBufferList); for(int i = 0; i < NUMBUFFERS; i++) mBufferList[i] = 0;
to
deleteBuffers();
and finally add the deleteBuffers method just below VorbisStreamSource::freeStream():
void VorbisStreamSource::deleteBuffers() { // Ensure that the refCount on the buffers is zero: alSourceUnqueueBuffers (mSource, NUMBUFFERS, mBufferList); if(mBufferList[0] != 0) alDeleteBuffers(NUMBUFFERS, mBufferList); for(int i = 0; i < NUMBUFFERS; i++) mBufferList[i] = 0; }
If you're lazy you could just add that call to alSourceUnqueueBuffers() to both freeStream() and clear() instead of calling deleteBuffers().
Torque Owner Sam Redfern