本文整理汇总了C++中AudioBuffer::checkSize方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioBuffer::checkSize方法的具体用法?C++ AudioBuffer::checkSize怎么用?C++ AudioBuffer::checkSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AudioBuffer
的用法示例。
在下文中一共展示了AudioBuffer::checkSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: alBufferData
void alBufferData(ALuint buffer, ALenum format, const ALvoid *data, ALsizei size, ALsizei freq)
{
debuglog(LCF_OPENAL, __func__, " call - copy buffer data of format ", format, ", size ", size, " and frequency ", freq, " into buffer ", buffer);
AudioBuffer* ab = audiocontext.getBuffer(buffer);
if (ab == nullptr) {
ALSETERROR(AL_INVALID_NAME);
return;
}
std::lock_guard<std::mutex> lock(audiocontext.mutex);
/* Fill the buffer informations */
ab->size = size;
ab->frequency = freq;
switch(format) {
case AL_FORMAT_MONO8:
ab->format = SAMPLE_FMT_U8;
ab->nbChannels = 1;
break;
case AL_FORMAT_MONO16:
ab->format = SAMPLE_FMT_S16;
ab->nbChannels = 1;
break;
case AL_FORMAT_STEREO8:
ab->format = SAMPLE_FMT_U8;
ab->nbChannels = 2;
break;
case AL_FORMAT_STEREO16:
ab->format = SAMPLE_FMT_S16;
ab->nbChannels = 2;
break;
case AL_FORMAT_MONO_FLOAT32:
ab->format = SAMPLE_FMT_FLT;
ab->nbChannels = 1;
break;
case AL_FORMAT_STEREO_FLOAT32:
ab->format = SAMPLE_FMT_FLT;
ab->nbChannels = 2;
break;
case AL_FORMAT_MONO_DOUBLE_EXT:
ab->format = SAMPLE_FMT_DBL;
ab->nbChannels = 1;
break;
case AL_FORMAT_STEREO_DOUBLE_EXT:
ab->format = SAMPLE_FMT_DBL;
ab->nbChannels = 2;
break;
case AL_FORMAT_MONO_MSADPCM_SOFT:
ab->format = SAMPLE_FMT_MSADPCM;
ab->nbChannels = 1;
if (ab->blockSamples == 0)
ab->blockSamples = 64;
break;
case AL_FORMAT_STEREO_MSADPCM_SOFT:
ab->format = SAMPLE_FMT_MSADPCM;
ab->nbChannels = 2;
if (ab->blockSamples == 0)
ab->blockSamples = 64;
break;
default:
debuglog(LCF_OPENAL | LCF_ERROR, "Unsupported format: ", format);
return;
}
ab->update();
/* Check for size validity */
if (! ab->checkSize()) {
ALSETERROR(AL_INVALID_VALUE);
return;
}
/* Copy the data into our buffer */
ab->samples.clear();
ab->samples.insert(ab->samples.end(), &((uint8_t*)data)[0], &((uint8_t*)data)[size]);
}