Sign in to follow this  
O-san

OpenAL utility toolkit hang

Recommended Posts

O-san    1900
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");
}
}

...

// Initialization
alutInit(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 this post


Link to post
Share on other sites
Ashaman73    13715
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 this post


Link to post
Share on other sites
O-san    1900
Quote:
Original post by Ashaman73
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 ?


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

Share this post


Link to post
Share on other sites
O-san    1900
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.

[edit]

... 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 this post


Link to post
Share on other sites
Ashaman73    13715
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 this post


Link to post
Share on other sites
ccsdu2004    100
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!

Share this post


Link to post
Share on other sites

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

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this