I'm trying to engage myself into the Libgdx OpenGL framework. I've used LwjglApplication
for creating some simple apps that render boxes, some meshes and some textures. I came across Aurelien Ribon's app that creates rigid Box2D bodies. He used the LwjglCanvas
to integrate with Java's Swing. I tried making one myself, I created a JFrame
then added the LwjglCanvas
. Then set the JFrame
's default operation on close to EXIT_ON_CLOSE
.
However everytime I close the application, this logs to my console:
AL lib: alc_cleanup: 1 device not closed
.
I don't know what it means and it's not doing me any harm. I just want to know what it means. According to LwjglCanvas
docs:
All OpenGL calls are done on the EDT. This is slightly less efficient then a dedicated thread, but greatly simplifies synchronization. Note that you may need to call stop() or a Swing application may deadlock on System.exit due to how LWJGL and/or Swing deal with shutdown hooks.
Where should I bind the LwjglCanvas.stop()
, should I add it to the EventDispatchThread
queue or should I bind it to the JFrame.addWindowListener
?
And what does "AL lib: alc_cleanup: 1 device not closed" really mean?
Thanks a lot!
The AL lib is the "audio library" used by Libgdx (one of the OpenAL variants).
I believe this message just means that the audio library is cleaning up some (in your case just one) audio streams/handles for you. If you see this at exit, its harmless as all resources will be cleaned up by the OS.
If you internally cleanup your audio before exiting, the message should go away.
For more details, look for alc_cleanup
in here:
http://repo.or.cz/w/openal-soft.git/blob/HEAD:/Alc/ALc.c
AL.destroy();
must be called before the application shuts down. this call is normally included in a finally block, but if the application calls System.exit(0)
, finally blocks are no longer executed.
You should try always closing your app with the piece of code below:
Gdx.app.exit();
I usually put it in my pause() method, because there was no reason for my app to run in the background.
This static method tells the framework that your application is planning on closing and will thus release all resources effectively. The error you're getting is because the JNI interface has loaded an OpenAL library, but the System is closed before that library is properly unloaded and released. I had the same problem as you did, but this solved it. As stated in the JavaDoc, the exit() method:
Schedule[s] an exit from the application. On android, this will cause a call to pause() and dispose() some time in the future, it will not immediately finish your application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With