本文整理汇总了C++中SoundChannel类的典型用法代码示例。如果您正苦于以下问题:C++ SoundChannel类的具体用法?C++ SoundChannel怎么用?C++ SoundChannel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SoundChannel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_loadPlayWithFade
void test_loadPlayWithFade()
{
xtime xt;
Ogre::ResourceManager::ResourceMapIterator it =
SoundManager::getSingleton().getResourceIterator();
while (it.hasMoreElements())
{
SoundResourcePtr soundres = it.getNext();
SoundStream *sound = new SoundStream(soundres);
SoundChannel *channel = new SoundChannel(sound, soundres->getName());
if (channel)
{
channel->play();
xtime_get(&xt, boost::TIME_UTC);
xt.sec += 10;
thread::sleep(xt);
channel->stop();
xtime_get(&xt, boost::TIME_UTC);
xt.sec += 5;
thread::sleep(xt);
}
}
CPPUNIT_ASSERT(true);
}
示例2: SoundInstance
SoundInstance * Sound::Play()
{
if(TYPE_STREAMED == type && soundInstances.size())
{
return soundInstances.front();
}
SoundChannel * ch = SoundSystem::Instance()->FindChannel(priority);
if(!ch)
{
return 0;
}
if(TYPE_STREAMED == type)
{
provider->Init();
provider->Rewind();
PrepareDynamicBuffers();
}
SoundInstance * inst = new SoundInstance();
inst->buddyChannel = ch;
AddSoundInstance(inst);
ch->SetVolume(volume);
ch->Play(this, looping);
return inst;
}
示例3:
SoundChannel * SoundSystem::FindChannel(int32 priority)
{
Deque<SoundChannel*>::iterator it;
Deque<SoundChannel*>::iterator itEnd = channelsPool.end();
for(it = channelsPool.begin(); it != itEnd; ++it)
{
SoundChannel * ch = *it;
if(SoundChannel::STATE_FREE == ch->GetState())
{
return ch;
}
}
for(it = channelsPool.begin(); it != itEnd; ++it)
{
SoundChannel * ch = *it;
if(ch->GetProirity() < priority)
{
ch->Stop();
return ch;
}
}
return 0;
}
示例4: Update
void SoundSystem::Update()
{
Deque<SoundChannel*>::iterator it;
Deque<SoundChannel*>::iterator itEnd = channelsPool.end();
for(it = channelsPool.begin(); it != itEnd; ++it)
{
SoundChannel * ch = *it;
if(SoundChannel::STATE_FREE != ch->GetState())
{
ch->Update();
}
}
List<SoundInstance*>::iterator sit = soundInstances.begin();
List<SoundInstance*>::iterator sEnd = soundInstances.end();
while(sit != sEnd)
{
if(!(*sit)->Update())
{
sit = soundInstances.begin();
continue;
}
++sit;
}
}
示例5: allocateChannel_l
SoundChannel* SoundPool::allocateChannel_l(int priority)
{
List<SoundChannel*>::iterator iter;
SoundChannel* channel = NULL;
// allocate a channel
if (!mChannels.empty()) {
iter = mChannels.begin();
if (priority >= (*iter)->priority()) {
channel = *iter;
mChannels.erase(iter);
ALOGV("Allocated active channel");
}
}
// update priority and put it back in the list
if (channel) {
channel->setPriority(priority);
for (iter = mChannels.begin(); iter != mChannels.end(); ++iter) {
if (priority < (*iter)->priority()) {
break;
}
}
mChannels.insert(iter, channel);
}
return channel;
}
示例6: while
int SoundPool::run()
{
mRestartLock.lock();
while (!mQuit) {
mCondition.wait(mRestartLock);
LOGV("awake");
if (mQuit) break;
while (!mRestart.empty()) {
SoundChannel* channel;
LOGV("Getting channel from list");
List<SoundChannel*>::iterator iter = mRestart.begin();
channel = *iter;
mRestart.erase(iter);
if (channel) channel->nextEvent();
if (mQuit) break;
}
}
mRestart.clear();
mCondition.signal();
mRestartLock.unlock();
LOGV("goodbye");
return 0;
}
示例7: test_PlayLoop
void test_PlayLoop()
{
xtime xt;
/* Ogre::ResourceManager::ResourceMapIterator it =
SoundManager::getSingleton().getResourceIterator();
while (it.hasMoreElements()) */
{
SoundSample *sound = new SoundSample("test.ogg");
sound->setLooping(true);
sound->load();
SoundChannel *channel = new SoundChannel(sound, sound->getName());
if (channel)
{
channel->play();
xtime_get(&xt, TIME_UTC);
xt.sec+=10;
thread::sleep(xt);
delete sound;
}
}
CPPUNIT_ASSERT(true);
}
示例8: lock
void SoundPool::setVolume(int channelID, float leftVolume, float rightVolume)
{
Mutex::Autolock lock(&mLock);
SoundChannel* channel = findChannel(channelID);
if (channel) {
channel->setVolume(leftVolume, rightVolume);
}
}
示例9: LOGV
void SoundPool::pause(int channelID)
{
LOGV("pause(%d)", channelID);
Mutex::Autolock lock(&mLock);
SoundChannel* channel = findChannel(channelID);
if (channel) {
channel->pause();
}
}
示例10: ALOGV
void SoundPool::setLoop(int channelID, int loop)
{
ALOGV("setLoop(%d, %d)", channelID, loop);
Mutex::Autolock lock(&mLock);
SoundChannel* channel = findChannel(channelID);
if (channel) {
channel->setLoop(loop);
}
}
示例11: while
void SoundDevice::releaseAllChannels()
{
while(m_activeChannels.size() > 0)
{
SoundChannel* channel = m_activeChannels.back();
channel->stop();
delete channel;
m_activeChannels.pop_back();
}
}
示例12: callback
void SoundChannel::callback(int event, void* user, void *info)
{
unsigned long toggle = (unsigned long)user & 1;
SoundChannel* channel = static_cast<SoundChannel*>((void *)((unsigned long)user & ~1));
if (channel->mToggle != toggle) {
LOGV("callback with wrong toggle");
return;
}
channel->process(event, info);
}
示例13: DVASSERT
SoundInstance * Sound::Play()
{
#ifdef __DAVAENGINE_ANDROID__
SLresult result;
if(TYPE_STATIC == type)
{
result = (*playerBufferQueue)->Clear(playerBufferQueue);
DVASSERT(SL_RESULT_SUCCESS == result);
buffer->FullFill(provider, playerBufferQueue);
}
if(TYPE_STREAMED == type)
{
result = (*playerSeek)->SetPosition(playerSeek, 0, SL_SEEKMODE_FAST);
DVASSERT(SL_RESULT_SUCCESS == result);
}
result = (*playerPlay)->SetPlayState(playerPlay, SL_PLAYSTATE_PLAYING);
DVASSERT(SL_RESULT_SUCCESS == result);
soundInstances.clear();
SoundInstance * inst = new SoundInstance(this);
AddSoundInstance(inst);
return soundInstances.front();
#else
if(TYPE_STREAMED == type && soundInstances.size())
{
return soundInstances.front();
}
SoundChannel * ch = SoundSystem::Instance()->FindChannel(priority);
if(!ch)
{
return 0;
}
if(TYPE_STREAMED == type)
{
PrepareDynamicBuffers();
}
SoundInstance * inst = new SoundInstance();
inst->buddyChannel = ch;
AddSoundInstance(inst);
ch->SetVolume(volume);
ch->Play(this, looping);
return inst;
#endif //#ifdef __DAVAENGINE_ANDROID__
}
示例14:
/**
* @author JoSch
* @date 03-11-2005
*/
SoundObject::~SoundObject()
{
if (mMovableObject)
{
SoundChannel *sc = dynamic_cast<SoundChannel*>(mMovableObject);
if (sc)
{
sc->stop();
}
delete mMovableObject;
}
}
示例15: Suspend
void SoundSystem::Suspend()
{
Deque<SoundChannel*>::iterator it;
Deque<SoundChannel*>::iterator itEnd = channelsPool.end();
for(it = channelsPool.begin(); it != itEnd; ++it)
{
SoundChannel * ch = *it;
if(SoundChannel::STATE_PLAYING == ch->GetState())
{
ch->Pause(true);
}
}
#ifdef __DAVASOUND_AL__
alcSuspendContext(context);
#endif
}