本文整理汇总了C++中SoundPtr::GetHandle方法的典型用法代码示例。如果您正苦于以下问题:C++ SoundPtr::GetHandle方法的具体用法?C++ SoundPtr::GetHandle怎么用?C++ SoundPtr::GetHandle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoundPtr
的用法示例。
在下文中一共展示了SoundPtr::GetHandle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QueueBuffers
void SoundChannel::QueueBuffers()
{
// See that we do have waiting sounds and they're ready to play
if (!pending_sounds_.size())
return;
if ((*pending_sounds_.begin())->GetHandle() == 0)
return;
// Create source now if did not exist already
if (!CreateSource())
{
state_ = Foundation::SoundServiceInterface::Stopped;
pending_sounds_.clear();
return;
}
bool queued = false;
// Buffer pending sounds, move them to playing vector
while (pending_sounds_.size())
{
SoundPtr sound = *pending_sounds_.begin();
ALuint buffer = sound->GetHandle();
// If no valid handle yet, cannot play this one, break out
if (!buffer)
return;
alGetError();
alSourceQueueBuffers(handle_, 1, &buffer);
ALenum error = alGetError();
if (error != AL_NONE)
{
// If queuing fails, we may have changed sound format. Stop, flush queue & retry
alSourceStop(handle_);
alSourcei(handle_, AL_BUFFER, 0);
alSourceQueueBuffers(handle_, 1, &buffer);
ALenum error = alGetError();
if (error != AL_NONE)
OpenALAudioModule::LogError("Could not queue OpenAL sound buffer: " + ToString<int>(error));
else
{
playing_sounds_.push_back(sound);
queued = true;
}
}
else
{
playing_sounds_.push_back(sound);
queued = true;
}
pending_sounds_.pop_front();
}
// If at least one sound queued, start playback if not already playing
if (queued)
{
ALint playing;
alGetSourcei(handle_, AL_SOURCE_STATE, &playing);
if (playing != AL_PLAYING)
alSourcePlay(handle_);
state_ = Foundation::SoundServiceInterface::Playing;
}
}