What does “AL lib: alc_cleanup: 1 device not closed” mean?

喜夏-厌秋 提交于 2019-11-30 15:31:23

问题


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!


回答1:


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




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/16161714/what-does-al-lib-alc-cleanup-1-device-not-closed-mean

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!