我已经使用OpenAL为我的应用程序实现了声音。看起来它工作正常,直到我关闭应用程序并试图清理每个声音相关的对象。基本上我有一个清理方法是这样的:用aclCloseDevice关闭设备时发生致命错误
public void cleanup(){
//looping through sources and deleting them like this:
alSourceStop(id);
alDeleteSources(id);
//ids of sources and buffers are not the same they are in different classes
//looping through buffers and deleting them like this:
alDeleteBuffers(id);
//destroying context
alcDestroyContext(context);
//closing device
alcCloseDevice(device);
}
当我评论alcCloseDevice
了,我得到这样的消息:
AL lib: (EE) alc_cleanup: 1 device not closed
如果我把它留在原来的位置:
A fatal error has been detected by the Java Runtime Environment ... Failed to write core dump ...
等等
我在Windows 7 64bit操作系统上使用LWJGL 3.1.0以及所有OpenGL和OpenAL相关的st uff由一个线程管理。
我成立这个样子的:
device = alcOpenDevice((ByteBuffer)null);
ALCCapabilities caps = ALC.createCapabilities(device);
context = alcCreateContext(device, (IntBuffer)null);
alcMakeContextCurrent(context);
AL.createCapabilities(caps);
设备和上下文没有问题产生。
这样创建缓冲区:
id = alGenBuffers();
try(STBVorbisInfo info = STBVorbisInfo.malloc()){
ShortBuffer buffer = /*decoding ogg here without problem*/
alBufferData(id, info.channels() == 1 ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16, buffer, info.sample_rate());
}
还设置了源和听众,但我并不认为会对它产生任何影响,实际上并没有创造任何源与听者的错误关闭装置的结果。
您正在使用哪种版本的LWJGL? – Vallentin
你可以添加更多的上下文,比如哪个操作系统?另外你如何设置OpenAL?一切都由同一个线程执行吗?因为我无法复制你的问题。 – Vallentin
@Vallentin我编辑了我的问题以提供更多的信息,当我关闭应用程序时,这个错误日志文件也生成了,可惜它没有告诉我很多,但我可以提供它,如果有帮助的话。 – eldo