【发布时间】:2017-08-12 00:29:09
【问题描述】:
我已经使用 OpenAL 在我的应用程序中实现了声音。似乎它工作正常,直到我关闭应用程序并尝试清理每个与声音相关的对象。基本上我有一个清理方法是这样的:
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 64 位操作系统上使用 LWJGL 3.1.0,所有 OpenGL 和 OpenAL 相关的东西都由一个线程管理。
我的设置如下:
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?
-
您能否添加更多上下文,例如哪个操作系统?另外,您如何设置 OpenAL?一切都是由同一个线程执行的吗?因为我无法复制您的问题。
-
@Vallentin 我编辑了我的问题以提供更多信息,当我关闭应用程序时,也会生成此错误日志文件,遗憾的是它并没有告诉我太多信息,但如果有帮助,我可以提供。