OpenAL无效操作

时间:2014-12-19 15:55:48

标签: openal

尝试删除缓冲区时,我收到OpenAL“无效操作”错误。 我已经使用alIsBuffer和alIsSource检查了我的源代码和缓冲区是有效的OpenAL对象,就是这种情况。

    assert(alIsBuffer(m_buffer) == AL_TRUE);
    assert(alIsSource(m_source) == AL_TRUE);

    alErrorChecking(alSourcei(m_source, AL_BUFFER, NULL));
    alErrorChecking(alDeleteBuffers(1, &m_buffer)); //Here i'm getting the Invalid Operation error
    m_buffer = 0;

2 个答案:

答案 0 :(得分:1)

缓冲区无法附加到源。 假设m_buffer正在m_source上播放,则在删除缓冲区之前需要此行:

alSourceUnqueueBuffers( m_source, 1, &m_buffer); 

答案 1 :(得分:0)

以下是我用来关闭OpenAL的内容

ALenum errorCode = 0;

// Stop the sources
alSourceStopv(1, & streaming_source[0]);        //      streaming_source

// Clean-up
alDeleteSources(1, &streaming_source[0]);
alDeleteBuffers(16, &streaming_source[0]);
errorCode = alGetError();
alcMakeContextCurrent(NULL);
errorCode = alGetError();
alcDestroyContext(openal_output_context);
alcCloseDevice(openal_output_device);

在我的标题中我有

#include  <AL/al.h>
#include  <AL/alc.h>

ALuint streaming_source[1];

ALCdevice * openal_output_device;
ALCcontext * openal_output_context;