alBufferData仍返回AL

alBufferData仍返回AL

本文介绍了OpenAL:即使输入变量*看起来*正常,alBufferData仍返回AL_INVALID_VALUE.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我正在构建一个线程IMA ADPCM解码器,将音频数据流传输到OpenAL (请参见下面的简短描述),但遇到了一些麻烦.

So, I'm building a threaded IMA ADPCM decoder streaming audio data to OpenAL (see below for short description) but I've run into some trouble.

我的问题之一是有时我对alBufferData的调用:

One of my issues is that sometimes my call to alBufferData:

alBufferData(* bufferID,format,pcmData,sizeInBytes,bitRate);

返回 AL_INVALID_VALUE ,例如:

bufferID ='109770616',format ='AL_FORMAT_STEREO16',dataPtr ='109754188',sizeInBytes ='8164'

任何线索,有人吗?发生这种情况时,正在播放的实际声音有点断断续续,并且错误通常会连续发生约10次(同一声音).通常,当我反复发出相同的声音时(例如,用LMG ...短拍...时),也会发生这种情况.

Any clues, anyone? The actual sound being played sort of stutteres when this happens, and the error usually happens ~10 times in a row (on the same sound). It also usually happens when I repeatedly start the same sound (for example when shooting short bursts with an LMG... ;))

streaming-decoder-module-thing的快速简化导览

声音的播放方式:

  1. 触发声音播放.
  2. 其中一个缓冲区大小的音频被解码,其余的则排队等待进一步解码.
  3. OpenAL被触发以开始播放声音.

解码/流循环

  1. 对于排队等待解码的每种声音,请解码bufferSize值的音频.
  2. 已解码的音频将使用适当的bufferID添加到alBuffer(请参见上面的调用).

推荐答案

如果还不算太晚,我将告诉您BufferData遇到的类似问题,这是解决问题的方法.虽然,请记住,我不知道您的线程程序的细节.

if it's not too late I'll tell you the similar problems I had with BufferData and here's how I fixed it. Although, keep in mind, I don't know the specifics of your threaded program.

返回无效值的原因有很多,据我所知是...
-对新缓冲区(流媒体源)进行排队(如果源已经分配了bufferID)(因为如果设置了缓冲区ID,则将其设置为静态).如果是这样,请删除源属性中的ID.
-在播放中更改缓冲区格式.一旦源开始播放,就不能更改缓冲区数据本身以外的任何缓冲区设置(fmt,samplerate),即使该源位于另一个队列中也是如此.

Invalid value is returned for a number of reasons, the ones I know of are...
-Queuing new buffers (to a streaming source) if the source already has a bufferID assigned (because it gets set to static if you set buffer id). If so, remove the ID in the source property.
-Changing the buffer format mid play. You can't change any buffer setting (fmt,samplerate) except for the buffer data itself once a source starts playing, even if it is on another queued one.

听起来您可能正在另一个线程中更改这些设置之一.

It sounds like you might be changing one of these settings in another thread.

另一种可能引起爆裂的声音是重放声音.再次调用play只会使音源停止播放,然后倒回当前缓冲区并从头开始播放.像那样弹枪的声音听起来并不像您想要的(我认为是分层的).2个选项,将剩余的枪声混合到缓冲区中,然后重播它,但这可能不起作用.另一个愚蠢的证据是仅使用多个来源并旋转每次枪支射击时会调用的来源.

Another thing that may cause pops is replaying the sound. Calling play again just stops the source cold, then rewinds the current buffer and starts playing from the beginning. Playing a gun sound like that won't sound like you want it (layered i assume). 2 options, mix the remaining gun sound into the buffer then replay it, but this might not work. another fool proof is just to use multiple sources and rotate which ones get called on each gun fire.

祝你项目顺利.

这篇关于OpenAL:即使输入变量*看起来*正常,alBufferData仍返回AL_INVALID_VALUE.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 16:51