From 63209fe123241072961ef0344c11e5241be8f0ca Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Wed, 14 Jul 2010 01:59:21 -0700 Subject: Applied slviewer-0-v12350-StutteringAndLagInAudioEngine_v2.patch from Cool Viewer by Henri Beauchamp --- linden/indra/llaudio/audioengine.cpp | 34 +++++++++++++++++++++++++++++----- linden/indra/llaudio/audioengine.h | 3 ++- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/linden/indra/llaudio/audioengine.cpp b/linden/indra/llaudio/audioengine.cpp index 5f1c060..7cec920 100644 --- a/linden/indra/llaudio/audioengine.cpp +++ b/linden/indra/llaudio/audioengine.cpp @@ -31,6 +31,8 @@ * $/LicenseInfo$ */ +#include + #include "linden_common.h" #include "audioengine.h" @@ -430,7 +432,10 @@ void LLAudioEngine::idle(F32 max_decode_time) else { channelp->setWaiting(false); - channelp->play(); + if (channelp->mCurrentBufferp) + { + channelp->play(); + } } } } @@ -632,7 +637,7 @@ bool LLAudioEngine::updateBufferForData(LLAudioData *adp, const LLUUID &audio_uu { if (adp->hasDecodedData()) { - adp->load(); + return adp->load(); } else if (adp->hasLocalData()) { @@ -667,6 +672,9 @@ void LLAudioEngine::enableWind(bool enable) LLAudioBuffer *LLAudioEngine::getFreeBuffer() { + static clock_t last_info = 0; + static bool spamming = FALSE; + S32 i; for (i = 0; i < MAX_BUFFERS; i++) { @@ -698,8 +706,18 @@ LLAudioBuffer *LLAudioEngine::getFreeBuffer() if (buffer_id >= 0) { - LL_INFOS("AudioEngine") << "Taking over unused buffer " << buffer_id << llendl; - //LL_INFOS("AudioEngine") << "Flushing unused buffer!" << llendl; + if (clock() - last_info > CLOCKS_PER_SEC) + { + // Do not spam us with such messages... + llinfos << "Taking over unused buffer " << buffer_id << llendl; + last_info = clock(); + } + else if (!spamming) + { + // ... but warn us *once* when the buffer freeing frequency is abnormal. + llwarns << "Excessive buffer freeing frequency, info messages throttled." << llendl; + spamming = true; + } mBuffers[buffer_id]->mAudioDatap->mBufferp = NULL; delete mBuffers[buffer_id]; mBuffers[buffer_id] = createBuffer(); @@ -1841,6 +1859,8 @@ LLAudioData::LLAudioData(const LLUUID &uuid) : bool LLAudioData::load() { + static clock_t last_info = 0; + // For now, just assume we're going to use one buffer per audiodata. if (mBufferp) { @@ -1853,7 +1873,11 @@ bool LLAudioData::load() if (!mBufferp) { // No free buffers, abort. - llinfos << "Not able to allocate a new audio buffer, aborting." << llendl; + if (clock() - last_info > CLOCKS_PER_SEC) // Do not spam us with such messages + { + llinfos << "Not able to allocate a new audio buffer, aborting." << llendl; + last_info = clock(); + } return false; } diff --git a/linden/indra/llaudio/audioengine.h b/linden/indra/llaudio/audioengine.h index 574ed95..e990eb7 100644 --- a/linden/indra/llaudio/audioengine.h +++ b/linden/indra/llaudio/audioengine.h @@ -58,7 +58,8 @@ const F32 ATTACHED_OBJECT_TIMEOUT = 5.0f; const F32 DEFAULT_MIN_DISTANCE = 2.0f; #define MAX_CHANNELS 30 -#define MAX_BUFFERS 40 // Some extra for preloading, maybe? +// Number of maximum rezzed objects with sounds + sounds without an object + UI sounds. +#define MAX_BUFFERS 100 // This define is intended to allow us to switch from os based wav // file loading to vfs based wav file loading. The problem is that I -- cgit v1.1