OpenAL music file stops playing during high processing
by Ian Omroth Hardingham · in Technical Issues · 03/30/2011 (5:48 am) · 15 replies
Hey guys.
I have my music playing through a simple alxPlay.
If my game does something complex like AI calculations (this is a turn based game) which takes more than around 2 seconds without stopping, the music just stops - as if alxStop were called (but it isn't).
Can anyone advise?
Thanks,
Ian
I have my music playing through a simple alxPlay.
If my game does something complex like AI calculations (this is a turn based game) which takes more than around 2 seconds without stopping, the music just stops - as if alxStop were called (but it isn't).
Can anyone advise?
Thanks,
Ian
About the author
Designer and lead programmer on Frozen Synapse, Frozen Endzone, and Determinance. Co-owner of Mode 7 Games.
#3
03/30/2011 (12:11 pm)
Can you post your audio profile and description? How long is the sound file you're trying to play?
#4
volume = 1.0;
is3D = false;
isLooping = false;
isStreaming = true;
}
Preload is off.
The sound file is 5 minutes long.
03/30/2011 (12:13 pm)
new AudioDescription() {volume = 1.0;
is3D = false;
isLooping = false;
isStreaming = true;
}
Preload is off.
The sound file is 5 minutes long.
#5
03/30/2011 (12:14 pm)
wav file or ogg?
#6
03/30/2011 (12:14 pm)
ogg.
#7
You are streaming the ogg file into the audio engine. You stream in a chunk and OpenAL plays it independent of the engine until it needs a new chunk.
Rather than play the same stream chunk over and over (which I thought is what happened) it doesn't get a new chunk, assumes the channel is no longer active and stops it. This is probably dependent on your hardware.
A work around would be to go into the engine and increase the stream chunk size so it doesn't run out.
I do not have source in front of me or I could advise on exactly where to do this.
03/30/2011 (12:17 pm)
Off the top of my head my guess is this:You are streaming the ogg file into the audio engine. You stream in a chunk and OpenAL plays it independent of the engine until it needs a new chunk.
Rather than play the same stream chunk over and over (which I thought is what happened) it doesn't get a new chunk, assumes the channel is no longer active and stops it. This is probably dependent on your hardware.
A work around would be to go into the engine and increase the stream chunk size so it doesn't run out.
I do not have source in front of me or I could advise on exactly where to do this.
#8
03/30/2011 (12:18 pm)
Thanks Chris, that's great - I'll try that tomorrow.
#9
The correct way to make this work is to let your AI function have breaks to let everything else update, or to run it in a thread of it's own, which lends itself to even more difficulties.
Ideal solution, let your AI process in smaller chunks so the rest of the engine gets process ticks to update.
03/30/2011 (12:20 pm)
A couple notes... I do not think preloading the file will matter since it preloads it into memory but still streams it to your audio hardware in chunks.The correct way to make this work is to let your AI function have breaks to let everything else update, or to run it in a thread of it's own, which lends itself to even more difficulties.
Ideal solution, let your AI process in smaller chunks so the rest of the engine gets process ticks to update.
#10
I've done some rudiemntary poking around and haven't been able to find a chunk size variable. Have you any idea where it might be?
Thanks,
Ian
03/31/2011 (3:56 am)
Hi Chris.I've done some rudiemntary poking around and haven't been able to find a chunk size variable. Have you any idea where it might be?
Thanks,
Ian
#11
#define CHUNKSIZE 4096
vorbisStreamSource.cc LN 10
#define BUFFERSIZE 32768
#define CHUNKSIZE 4096
lib\libvorbis\vorbisfile.c LN 61
#define CHUNKSIZE 65536
... Just did a quick search. I am guessing that it is the vorbisfile.c reference which requires you to recompile the lib. Makes sense since 65,000 samples is roughly 1.5 seconds at 20,000 Hz, which is what your audio file probably plays at.
03/31/2011 (5:56 am)
AudioBuffer.cc LN 75#define CHUNKSIZE 4096
vorbisStreamSource.cc LN 10
#define BUFFERSIZE 32768
#define CHUNKSIZE 4096
lib\libvorbis\vorbisfile.c LN 61
#define CHUNKSIZE 65536
... Just did a quick search. I am guessing that it is the vorbisfile.c reference which requires you to recompile the lib. Makes sense since 65,000 samples is roughly 1.5 seconds at 20,000 Hz, which is what your audio file probably plays at.
#12
04/05/2011 (4:31 am)
BUFFERSIZE in vorbisStreamSource.cc did it - thanks again Chris.
#13
I would simply quadruple them and I admit I am without knowledge of adverse affects that may directly have.
- I am currently in the initial steps of building a game around music and this causes direct concerns for me and my counterparts. Thx
04/05/2011 (5:48 am)
do either of you guys have suggestions to modernize these numbers ?I would simply quadruple them and I admit I am without knowledge of adverse affects that may directly have.
- I am currently in the initial steps of building a game around music and this causes direct concerns for me and my counterparts. Thx
#14
04/05/2011 (5:51 am)
pain in the butt - I'd license T3D and use FMOD - openAL is unmitigated ****.
#15
#define BUFFERSIZE 32768 * 4 * 4
(16x the default) is going to cause me any problems?
Thanks,
Ian
04/20/2011 (2:40 am)
Guys, does anyone know if a buffer size of#define BUFFERSIZE 32768 * 4 * 4
(16x the default) is going to cause me any problems?
Thanks,
Ian
Torque Owner Chris Labombard
Premium Preferred