开发者

openAL - alBufferData and AL_INVALID_VALUE

i have a problem. When I buffer data, I get the 40963 error back, meaning AL_INVALID_VALUE. The programmers guide (http://connect.creativelabs.com/openal/Documentation/OpenAL_Programmers_Guide.pdf) says data is either null, buffer in use or size parameter is not valid.

I know for a fact that data is Not null, and the buffer is Not in use. 开发者_StackOverflow中文版 But what does "size parameter not valid" really mean? For example, each packet I want to buffer is 20ms, and the size of the data is 320. My rate is 8000khz.

Thanks


I ran into this problem in java JOAL and found this in another post. My code was the following:

 ALut.alutLoadWAVFile(Sound.class.getResourceAsStream("/sound/sound.wav"), format, data, size, freq, loop);
        if (al.alGetError() != AL.AL_NO_ERROR) {
            System.err.println("Error in load.");
            return AL.AL_FALSE;
        }
        al.alBufferData(buffer[0], format[0], data[0], size[0], freq[0]);
        if (al.alGetError() != AL.AL_NO_ERROR) {
            System.err.println("Error in alBufferData.");
            System.err.println(buffer[0]);
            System.err.println(format[0]);
            System.err.println(data[0]);
            System.err.println(size[0]);
            System.err.println(freq[0]);
            
            return AL.AL_FALSE;
        }
        return AL.AL_TRUE;

It printed this:

Error in alBufferData.
1
4355
java.nio.DirectByteBuffer[pos=0 lim=507538 cap=507904]
507538
44100

So I tried the following:

      return AL.AL_FALSE;
}
//Size needs to be adjusted to a multiple of 8
size[0] -= size[0]%8; 
        
al.alBufferData(buffer[0], format[0], data[0], size[0], freq[0]);

That worked for me, but in your case size is multiple of 4 and 8. There could be a minimum size for buffering data, so making bigger packets and adjusting their sizes could work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜