当前位置: 首页>>代码示例>>C++>>正文


C++ SoundPtr::GetHandle方法代码示例

本文整理汇总了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;
     }
 }
开发者ID:Belsepubi,项目名称:naali,代码行数:65,代码来源:SoundChannel.cpp


注:本文中的SoundPtr::GetHandle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。