OpenAL utility toolkit hang

Recommended Posts

I'm having some difficulty with alut. When I close my program the last few sounds that are played gets repeated/stutters, extremely annoying. I am initializing OpenAL with alutInit(0,0) and I set an exit function.

void openALexit(){  if(alutExit()!=AL_TRUE){    error.writeToLog("alutExit error");  }}...// InitializationalutInit(0,0);alGetError();atexit(openALexit);

Before the program has exited I unbind all my buffers (using AL_NONE) and free them using alDeleteBuffers. This is wrapped in the function deleteAllSoundBuffers(). I then delete the sources:

OpenALObject::~OpenALObject(){  deleteAllSoundBuffers(); // Deletes all openal buffers  for(int i=0;i<MAX_CHANNELS;i++){    alDeleteSources(1,&mGSoundSource[i].mSource);    if(alGetError()!=AL_NO_ERROR){      error.writeToLog("alDeleteSources error.");    }  }}

The program deletes all my buffers and sources before the atexit function is called. I have also tried running the program without the atexit function and directly call alutexit() when the program reaches the end, same problem. I have absolutely no clue why the stuttering can be heard. There should be no sources or buffers present.

Any help appreciated.

Share on other sites
I got the same problem but I can't really remember what I have done to get rid of the audio artifacts. Did you have tried to stop the sources before deleting them, even if deleting the sources should stop the sound automatically ?

Share on other sites
Quote:
 Original post by Ashaman73I got the same problem but I can't really remember what I have done to get rid of the audio artifacts. Did you have tried to stop the sources before deleting them, even if deleting the sources should stop the sound automatically ?

Thanks for the reply. Yes sorry forgot to mention that, the sources are stopped before they are deleted using alSourceStop.

Share on other sites
Well, it seems that the topic is wrong. I still get the sound stutters on exit even when I have removed alut from the project. So the cause must lay in OpenAL itself.

I now use a wave loader I found at Creative labs (CWaves.cpp/CWaves.h). I am no closer to solving the problem however.

... After a bit of testing I found out that the stutters disappears when not using the default device. Instead I specify "Generic Software" as the device. I guess this will leave out some hardware effects :P well, I didn't plan on using any of them anyway.

[Edited by - O-san on October 14, 2010 8:45:41 AM]

Share on other sites
This is the way I setup my open al context/device:
	// open device	m_device = alcOpenDevice((ALubyte*)"DirectSound3D");	logErrorStatus();	// success ?	if (m_device == NULL)	{		BsDebug::trace("FATAL ERROR: can't open device");		return false;	}	//Create context(s)	m_context = alcCreateContext(m_device, NULL);	logErrorStatus();	//Set active context	alcMakeContextCurrent(m_context);	logErrorStatus();

This way I shut it down:
	//Get active context	m_context=alcGetCurrentContext();	//Get device for active context	m_device=alcGetContextsDevice(m_context);	//Disable context	alcMakeContextCurrent(NULL);	//Release context(s)	alcDestroyContext(m_context);	//Close device	alcCloseDevice(m_device);

Thought I still use direct sound under vista, hmm...

Share on other sites
My God,
OpenAL is good good to use,due to complexity of it.
I write an audio engine(GAudio---short for Game Audio Engine)(this library is designed for my game engine-GEngine.)
You can use it for learn freely!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

• Forum Statistics

• Total Topics
628345
• Total Posts
2982187

• 9
• 24
• 9
• 9
• 13