本文整理汇总了C++中LLAudioData::getBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ LLAudioData::getBuffer方法的具体用法?C++ LLAudioData::getBuffer怎么用?C++ LLAudioData::getBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LLAudioData
的用法示例。
在下文中一共展示了LLAudioData::getBuffer方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupChannel
bool LLAudioSource::setupChannel()
{
LLAudioData *adp = getCurrentData();
if (!adp->getBuffer())
{
// We're not ready to play back the sound yet, so don't try and allocate a channel for it.
//llwarns << "Aborting, no buffer" << llendl;
return false;
}
if (!mChannelp)
{
// Update the priority, in case we need to push out another channel.
updatePriority();
setChannel(gAudiop->getFreeChannel(getPriority()));
}
if (!mChannelp)
{
// Ugh, we don't have any free channels.
// Now we have to reprioritize.
// For now, just don't play the sound.
//llwarns << "Aborting, no free channels" << llendl;
return false;
}
mChannelp->setSource(this);
return true;
}
示例2: update
void LLAudioSource::update()
{
if(mCorrupted)
{
return ; //no need to update
}
if (!getCurrentBuffer())
{
LLAudioData *adp = getCurrentData();
if (adp)
{
// Hack - try and load the sound. Will do this as a callback
// on decode later.
if (adp->load() && adp->getBuffer())
{
play(adp->getID());
}
else if (adp->hasCompletedDecode()) // Only mark corrupted after decode is done
{
llwarns << "Marking LLAudioSource corrupted for " << adp->getID() << llendl;
mCorrupted = true ;
}
}
}
}
示例3: 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);
}
}
示例4: update
void LLAudioSource::update()
{
if(mCorrupted)
{
return ; //no need to update
}
// If data is queued up and we aren't playing it, shuffle it to current and try to load it.
if(isQueueSounds() && mPlayedOnce && mQueuedDatap && !mChannelp)
{
mCurrentDatap = mQueuedDatap;
mQueuedDatap = NULL;
//Make sure this source looks like its brand new again to prevent removal.
mPlayedOnce = false;
mAgeTimer.reset();
}
LLAudioData *adp = getCurrentData();
if (adp && !adp->getBuffer())
{
if(adp->getLoadState() == LLAudioData::STATE_LOAD_ERROR)
{
LL_WARNS("AudioEngine") << "Marking LLAudioSource corrupted for " << adp->getID() << LL_ENDL;
mCorrupted = true ;
}
else if(adp->getLoadState() == LLAudioData::STATE_LOAD_READY)
{
// Update the audio buffer first - load a sound if we have it.
// Note that this could potentially cause us to waste time updating buffers
// for sounds that actually aren't playing, although this should be mitigated
// by the fact that we limit the number of buffers, and we flush buffers based
// on priority.
adp->load(); //If it fails, just try again next update.
}
else
{
//The sound wasn't preloaded yet... so we must kick off the process.
adp->updateLoadState();
}
}
}
示例5: idle
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;
}
}
//Iterate down all queued sources. Remove finished ones, sort active ones by priority. Find highest priority 'master' source if present.
LLAudioSource *sync_masterp = NULL; //Highest priority syncmaster
LLAudioSource *sync_slavep = NULL; //Highest priority syncslave
//Priority queue that will be filled with soundsources that have a high likeleyhood of being able to start [re]playing this idle tick.
//Sort order: Primary: priority. Secondary: syncmaster. Tertiary: syncslave
std::priority_queue<LLAudioSource*,std::vector<LLAudioSource*,boost::pool_allocator<LLAudioSource*> >,SourcePriorityComparator> queue;
//Have to put syncslaves into a temporary list until the syncmaster state is determined.
//If the syncmaster might be started, or just looped, insert all pending/looping syncslaves into the priority queue.
//If the there is no active syncmaster, then stop any currently looping syncslaves and add none to the priority queue.
//This is necessary as any looping soundsources to be stopped, MUST be stopped before iterating down the priority queue.
static std::vector<LLAudioSource*> slave_list;
slave_list.clear();
//Iterate over all sources. Update their decode or 'done' state, as well as their priorities.
//Also add sources that might be able to start playing to the priority queue.
//Only sources without channels should be added to priority queue.
//Syncslaves must put into the slave list instead of the priority queue.
for (source_map::iterator iter = mAllSources.begin(); iter != mAllSources.end();)
{
LLAudioSource *sourcep = iter->second;
//Load/decode/queue pop
sourcep->update();
//Done after update, as failure to load might mark source as corrupt, which causes isDone to return true.
if (sourcep->isDone())
{
// The source is done playing, clean it up.
delete sourcep;
mAllSources.erase(iter++);
continue;
}
// Increment iter here (it is not used anymore), so we can use continue below to move on to the next source.
++iter;
if(!sourcep->isLoop() && sourcep->mPlayedOnce && (!sourcep->mChannelp || !sourcep->mChannelp->isPlaying()))
{
continue;
}
LLAudioData *adp = sourcep->getCurrentData();
//If there is no current data at all, or if it hasn't loaded, we must skip this source.
if (!adp || !adp->getBuffer())
{
continue;
}
sourcep->updatePriority(); //Calculates current priority. 1.f=ambient. 0.f=muted. Otherwise based off of distance.
if (sourcep->getPriority() < F_APPROXIMATELY_ZERO)
{
// Muted, or nothing queued, or too far, so we don't care.
continue;
}
else if(sourcep->isSyncMaster())
{
if(!sync_masterp || sourcep->getPriority() > sync_masterp->getPriority())
{
if(sync_masterp && !sync_masterp->getChannel())
queue.push(sync_masterp); //Add lower-priority soundmaster to the queue as a normal sound.
sync_masterp = sourcep;
//Don't add master to the queue yet.
//Add it after highest-priority sound slave is found so we can outrank its priority.
continue;
}
//Else fall through like a normal sound.
}
else if(sourcep->isSyncSlave())
{
if(!sync_slavep || sourcep->getPriority() > sync_slavep->getPriority())
{
sync_slavep = sourcep;
}
//Don't add to the priority queue quite yet. Best primary syncmaster candidate may not have been determined yet.
slave_list.push_back(sourcep);
continue;
}
//.........这里部分代码省略.........