Shutdown Hook Errors

Hi everyone,

I recently started work on incorporating JOAL into my engine. Things were going really well until they went horribly wrong :slight_smile:

The problem is that sound gets loaded as an engine module on startup (along with other things like graphics and networking). When startup is complete I register a shutdown hook to make sure that all modules are closed properly.

When shutting down I get the following:


java.lang.IllegalMonitorStateException: Not Owner 
at net.java.games.joal.ALCImpl$Mutex.release(ALCImpl.java:219) 
at net.java.games.joal.ALCImpl.alcFreeCurrentContext(ALCImpl.java:89) 
at net.java.games.joal.util.ALut.alutExit(ALut.java:126)

The JVM needs to then be manually killed off as the mutex waits indefinately for the original thread to come back. This is obviously not ideal when I’m just trying to shut the system down cleanly.

Any help or thoughts are much appreciated.

This should be a relaitvely easy fix. I’ll take a look at it today.

Thank you very much, looking forward to it

Hi,

Any progress on this?

Thanks

Hello!

I have exactly the same Error in my Sound Engine and have no idea how to fix this… Did someone had success fixing it?

Ok, lets get more detailed! My Sound-Engine ist of course a part of game… At startup an instance of this engine will be created, on which an “INIT”-Method is started, which looks like that:

public void init() {
try {
ALut.alutInit();
al = ALFactory.getAL();
} catch (OpenALException e) {
e.printStackTrace();
}
al.alGetError();

    if(loadALData() == AL.AL_FALSE) {    
    }
    setListenerValues();
}

now the game is running until someone presses the “QUIT” button. Beneath other shutdowns in other parts of the game, the Method “destroy” is called on the SoundEngine which looks like this:

public void destroy() {
al.alDeleteBuffers(NUM_BUFFERS, buffers);
al.alDeleteSources(NUM_SOURCES, sources);

    ALut.alutExit();  
}

The result is the postet Error-Message, instead of a shutdown… what could there be wrong???

A Friend of mine has fixed the problem! It was quite simple: The Thread which initialised OpenAL is the one who has to destroy the context. Anther Thread isnt allowed to do this, which causes the error!