本文整理汇总了C++中LLAudioChannel类的典型用法代码示例。如果您正苦于以下问题:C++ LLAudioChannel类的具体用法?C++ LLAudioChannel怎么用?C++ LLAudioChannel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LLAudioChannel类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: removeAudioData
// <FS:Ansariel> Asset blacklisting
void LLAudioEngine::removeAudioData(const LLUUID& audio_uuid)
{
if (audio_uuid.isNull())
{
return;
}
data_map::iterator iter = mAllData.find(audio_uuid);
if (iter != mAllData.end())
{
uuid_vec_t delete_list;
source_map::iterator iter2;
for (iter2 = mAllSources.begin(); iter2 != mAllSources.end(); ++iter2)
{
LLAudioSource* sourcep = iter2->second;
if (sourcep && sourcep->getCurrentData() && sourcep->getCurrentData()->getID() == audio_uuid)
{
delete_list.push_back(iter2->first);
}
}
uuid_vec_t::iterator delete_list_end = delete_list.end();
for (uuid_vec_t::iterator del_it = delete_list.begin(); del_it != delete_list_end; ++del_it)
{
LLUUID source_id = *del_it;
LLAudioSource* sourcep = mAllSources[source_id];
LLAudioChannel* chan = sourcep->getChannel();
delete sourcep;
mAllSources.erase(source_id);
if (chan)
{
chan->cleanup();
}
}
LLAudioData* data = iter->second;
if (data)
{
LLAudioBuffer* buf = data->getBuffer();
if (buf)
{
S32 i;
for (i = 0; i < MAX_BUFFERS; ++i)
{
if (mBuffers[i] == buf)
{
mBuffers[i] = NULL;
}
}
delete buf;
}
delete data;
}
mAllData.erase(audio_uuid);
}
}
示例2: createBuffer
LLAudioBuffer * LLAudioEngine::getFreeBuffer()
{
//checkStates(); //Fails
S32 i;
for (i = 0; i < MAX_BUFFERS; i++)
{
if (!mBuffers[i])
{
mBuffers[i] = createBuffer();
return mBuffers[i];
}
}
//checkStates(); // Fails
// Grab the oldest unused buffer
F32 max_age = -1.f;
S32 buffer_id = -1;
for (i = 0; i < MAX_BUFFERS; i++)
{
if (mBuffers[i])
{
if (!mBuffers[i]->mInUse)
{
if (mBuffers[i]->mLastUseTimer.getElapsedTimeF32() > max_age)
{
max_age = mBuffers[i]->mLastUseTimer.getElapsedTimeF32();
buffer_id = i;
}
}
}
}
//checkStates(); //Fails
if (buffer_id >= 0)
{
LL_DEBUGS("AudioEngine") << "Taking over unused buffer! max_age=" << max_age << LL_ENDL;
mBuffers[buffer_id]->mAudioDatap->mBufferp = NULL;
for (U32 i = 0; i < MAX_CHANNELS; i++)
{
LLAudioChannel* channelp = mChannels[i];
if(channelp && channelp->mCurrentBufferp == mBuffers[buffer_id])
{
channelp->cleanup();
llassert(channelp->mCurrentBufferp == NULL);
}
}
delete mBuffers[buffer_id];
mBuffers[buffer_id] = createBuffer();
return mBuffers[buffer_id];
}
//checkStates(); //Fails
return NULL;
}
示例3: createChannel
LLAudioChannel * LLAudioEngine::getFreeChannel(const F32 priority)
{
S32 i;
for (i = 0; i < mNumChannels; i++)
{
if (!mChannels[i])
{
// No channel allocated here, use it.
mChannels[i] = createChannel();
return mChannels[i];
}
else
{
// Channel is allocated but not playing right now, use it.
if (!mChannels[i]->isPlaying() && !mChannels[i]->isWaiting())
{
LL_DEBUGS("AudioEngine") << "Replacing unused channel" << llendl;
mChannels[i]->cleanup();
if (mChannels[i]->getSource())
{
mChannels[i]->getSource()->setChannel(NULL);
}
return mChannels[i];
}
}
}
// All channels used, check priorities.
// Find channel with lowest priority and see if we want to replace it.
F32 min_priority = 10000.f;
LLAudioChannel *min_channelp = NULL;
for (i = 0; i < mNumChannels; i++)
{
LLAudioChannel *channelp = mChannels[i];
LLAudioSource *sourcep = channelp->getSource();
if (sourcep->getPriority() < min_priority)
{
min_channelp = channelp;
min_priority = sourcep->getPriority();
}
}
if (min_priority > priority || !min_channelp)
{
// All playing channels have higher priority, return.
return NULL;
}
LL_DEBUGS("AudioEngine") << "Flushing min channel" << llendl;
// Flush the minimum priority channel, and return it.
min_channelp->cleanup();
return min_channelp;
}
示例4: getFreeChannel
void LLAudioEngine::idle(F32 max_decode_time)
{
if (max_decode_time <= 0.f)
{
max_decode_time = default_max_decode_time;
}
// "Update" all of our audio sources, clean up dead ones.
// Primarily does position updating, cleanup of unused audio sources.
// Also does regeneration of the current priority of each audio source.
S32 i;
for (i = 0; i < MAX_BUFFERS; i++)
{
if (mBuffers[i])
{
mBuffers[i]->mInUse = false;
}
}
F32 max_priority = -1.f;
LLAudioSource *max_sourcep = NULL; // Maximum priority source without a channel
source_map::iterator iter;
for (iter = mAllSources.begin(); iter != mAllSources.end();)
{
LLAudioSource *sourcep = iter->second;
// Update this source
sourcep->update();
sourcep->updatePriority();
if (sourcep->isDone())
{
// The source is done playing, clean it up.
delete sourcep;
mAllSources.erase(iter++);
continue;
}
if (sourcep->isMuted())
{
++iter;
continue;
}
if (!sourcep->getChannel() && sourcep->getCurrentBuffer())
{
// We could potentially play this sound if its priority is high enough.
if (sourcep->getPriority() > max_priority)
{
max_priority = sourcep->getPriority();
max_sourcep = sourcep;
}
}
// Move on to the next source
iter++;
}
// Now, do priority-based organization of audio sources.
// All channels used, check priorities.
// Find channel with lowest priority
if (max_sourcep)
{
LLAudioChannel *channelp = getFreeChannel(max_priority);
if (channelp)
{
//llinfos << "Replacing source in channel due to priority!" << llendl;
max_sourcep->setChannel(channelp);
channelp->setSource(max_sourcep);
if (max_sourcep->isSyncSlave())
{
// A sync slave, it doesn't start playing until it's synced up with the master.
// Flag this channel as waiting for sync, and return true.
channelp->setWaiting(true);
}
else
{
channelp->setWaiting(false);
channelp->play();
}
}
}
// Do this BEFORE we update the channels
// Update the channels to sync up with any changes that the source made,
// such as changing what sound was playing.
updateChannels();
// Update queued sounds (switch to next queued data if the current has finished playing)
for (iter = mAllSources.begin(); iter != mAllSources.end(); ++iter)
{
// This is lame, instead of this I could actually iterate through all the sources
// attached to each channel, since only those with active channels
// can have anything interesting happen with their queue? (Maybe not true)
LLAudioSource *sourcep = iter->second;
if (!sourcep->mQueuedDatap || sourcep->isMuted())
{
// Muted, or nothing queued, so we don't care.
//.........这里部分代码省略.........
示例5: if
//.........这里部分代码省略.........
(*iter)->getChannel()->cleanup();
}
}
//If the syncmaster already has a channel and hasn't looped, then we can skip syncslaves this idle tick (there's nothing to do).
else if((!sync_masterp->getChannel() || sync_masterp->getChannel()->mLoopedThisFrame))
{
//Add syncslaves that we might want to [re]start.
if(!(*iter)->getChannel() || (*iter)->isLoop())
queue.push((*iter));
}
}
if(sync_masterp)
{
//Syncmaster must have priority greater than or equal to priority of highest priority syncslave.
//The case of slave priority equaling master priority is handled in the comparator (SourcePriorityComparator).
if(sync_slavep)
sync_masterp->setPriority(sync_slavep->getPriority());
if(!sync_masterp->getChannel())
{
queue.push(sync_masterp);
}
}
// Dispatch all soundsources.
bool syncmaster_started = sync_masterp && sync_masterp->getChannel() && sync_masterp->getChannel()->mLoopedThisFrame;
while(!queue.empty())
{
LLAudioSource *sourcep = queue.top();
queue.pop();
//If the syncmaster hasn't just started playing, or hasn't just looped then skip this soundslave,
//as there's nothing to do with it yet.
if (sourcep->isSyncSlave() && !syncmaster_started)
{
continue;
}
LLAudioChannel *channelp = sourcep->getChannel();
if (!channelp)
{
//No more channels. We can break here, as in theory, any lower priority sounds should have had their
//channel already stolen. There should be nothing playing, nor playable, when iterating beyond this point.
if(!(channelp = getFreeChannel(sourcep->getPriority())))
{
break;
}
//If this is the primary syncmaster that we just started, then [re]start syncslaves further down in the priority queue.
//Due to sorting and priority fudgery, the syncmaster is ALWAYS before any syncslaves in this loop.
syncmaster_started |= (sourcep == sync_masterp);
//setSource calls updateBuffer and update3DPosition, and resets the source mAgeTimer
channelp->setSource(sourcep);
}
if(sourcep->isSyncSlave())
channelp->playSynced(sync_masterp->getChannel());
else
channelp->play();
}
// Sync up everything that the audio engine needs done.
commitDeferredChanges();
// Flush unused buffers that are stale enough
for (i = 0; i < MAX_BUFFERS; i++)
{
if (mBuffers[i])
{
if (!mBuffers[i]->mInUse && mBuffers[i]->mLastUseTimer.getElapsedTimeF32() > 30.f)
{
LL_DEBUGS("AudioEngine") << "Flushing unused buffer!" << LL_ENDL;
mBuffers[i]->mAudioDatap->mBufferp = NULL;
delete mBuffers[i];
mBuffers[i] = NULL;
}
}
}
// Clear all of the looped flags for the channels
for (i = 0; i < MAX_CHANNELS; i++)
{
if (mChannels[i])
{
mChannels[i]->mLoopedThisFrame = false;
}
}
// Decode audio files
gAudioDecodeMgrp->processQueue(max_decode_time);
// Just call here every frame. It makes little sense to call elsewhere,
// as it's throttled to one active preloading loading sound at a time anyhow
startNextTransfer();
updateInternetStream();
}