From 20cdb3517218391c4d0f07cbbe17f6d4de9f56a5 Mon Sep 17 00:00:00 2001 From: Drake Arconis Date: Tue, 12 Mar 2013 06:03:06 -0400 Subject: [PATCH] Import some changes from internal --- indra/llaudio/llaudioengine_openal.cpp | 104 +++++++++++++++---------- indra/llaudio/llaudioengine_openal.h | 4 +- indra/llcommon/lltimer.cpp | 2 +- indra/llmath/llcalcparser.cpp | 46 ----------- indra/newview/llfasttimerview.cpp | 21 ++++- 5 files changed, 84 insertions(+), 93 deletions(-) delete mode 100644 indra/llmath/llcalcparser.cpp diff --git a/indra/llaudio/llaudioengine_openal.cpp b/indra/llaudio/llaudioengine_openal.cpp index 887c79179..17c5d860f 100644 --- a/indra/llaudio/llaudioengine_openal.cpp +++ b/indra/llaudio/llaudioengine_openal.cpp @@ -38,6 +38,8 @@ #include "lllistener_openal.h" +const float LLAudioEngine_OpenAL::WIND_BUFFER_SIZE_SEC = 0.05f; + LLAudioEngine_OpenAL::LLAudioEngine_OpenAL() : mWindGen(NULL), @@ -185,6 +187,8 @@ LLAudioChannelOpenAL::~LLAudioChannelOpenAL() void LLAudioChannelOpenAL::cleanup() { alSourceStop(mALSource); + alSourcei(mALSource, AL_BUFFER, AL_NONE); + mCurrentBufferp = NULL; } @@ -324,7 +328,14 @@ void LLAudioBufferOpenAL::cleanup() { if(mALBuffer != AL_NONE) { + alGetError(); // clear error alDeleteBuffers(1, &mALBuffer); + + ALenum error = alutGetError(); + if(ALC_NO_ERROR != error) + { + LL_WARNS("OpenAL") << "Error: " << alutGetErrorString( error ) << " when cleaning up a buffer" << LL_ENDL; + } mALBuffer = AL_NONE; } } @@ -441,6 +452,7 @@ void LLAudioEngine_OpenAL::updateWind(LLVector3 wind_vec, F32 camera_altitude) F64 pitch; F64 center_freq; ALenum error; + ALuint *buffers = NULL; if (!mEnableWind) return; @@ -484,58 +496,68 @@ void LLAudioEngine_OpenAL::updateWind(LLVector3 wind_vec, F32 camera_altitude) mNumEmptyWindALBuffers = llmax(mNumEmptyWindALBuffers, 0); //llinfos << "mNumEmptyWindALBuffers: " << mNumEmptyWindALBuffers <<" (" << unprocessed << ":" << processed << ")" << llendl; - - while(processed--) // unqueue old buffers + + //delete the old wind buffers + buffers = new ALuint[processed]; + alGetError(); /* clear error */ + alSourceUnqueueBuffers(mWindSource, processed, &buffers[0]); + error = alGetError(); + if(error != AL_NO_ERROR) { - ALuint buffer; - ALenum error; - alGetError(); /* clear error */ - alSourceUnqueueBuffers(mWindSource, 1, &buffer); - error = alGetError(); - if(error != AL_NO_ERROR) - { - llwarns << "LLAudioEngine_OpenAL::updateWind() error swapping (unqueuing) buffers" << llendl; - } - else - { - alDeleteBuffers(1, &buffer); - } + llwarns << "LLAudioEngine_OpenAL::updateWind() error swapping (unqueuing) buffers" << llendl; + } + else + { + alDeleteBuffers(processed, &buffers[0]); + } + // We dont need to keep track of the buffers' id now. + delete[] buffers; + buffers = NULL; + + //create the buffers for the empty wind buffers + unprocessed += mNumEmptyWindALBuffers; + buffers = new ALuint[mNumEmptyWindALBuffers]; + alGetError(); /* clear error */ + alGenBuffers(mNumEmptyWindALBuffers,&buffers[0]); + if((error=alGetError()) != AL_NO_ERROR) + { + llwarns << "LLAudioEngine_OpenAL::updateWind() Error creating wind buffer: " << error << llendl; + //break; } - unprocessed += mNumEmptyWindALBuffers; - while (mNumEmptyWindALBuffers > 0) // fill+queue new buffers + //fill the buffers with generated wind. + int errors = 0; + for(int i = 0; i < mNumEmptyWindALBuffers; i++) { - ALuint buffer; - alGetError(); /* clear error */ - alGenBuffers(1,&buffer); - if((error=alGetError()) != AL_NO_ERROR) - { - llwarns << "LLAudioEngine_OpenAL::updateWind() Error creating wind buffer: " << error << llendl; - break; - } - - alBufferData(buffer, - AL_FORMAT_STEREO16, - mWindGen->windGenerate(mWindBuf, - mWindBufSamples), - mWindBufBytes, - mWindBufFreq); + alBufferData(buffers[i], + AL_FORMAT_STEREO16, + mWindGen->windGenerate(mWindBuf, + mWindBufSamples), + mWindBufBytes, + mWindBufFreq); error = alGetError(); if(error != AL_NO_ERROR) { llwarns << "LLAudioEngine_OpenAL::updateWind() error swapping (bufferdata) buffers" << llendl; + errors++; } - - alSourceQueueBuffers(mWindSource, 1, &buffer); - error = alGetError(); - if(error != AL_NO_ERROR) - { - llwarns << "LLAudioEngine_OpenAL::updateWind() error swapping (queuing) buffers" << llendl; - } - - --mNumEmptyWindALBuffers; } + //queue the buffers + alSourceQueueBuffers(mWindSource, mNumEmptyWindALBuffers, &buffers[0]); + error = alGetError(); + if(error != AL_NO_ERROR) + { + llwarns << "LLAudioEngine_OpenAL::updateWind() error swapping (queuing) buffers" << llendl; + } + + mNumEmptyWindALBuffers = errors; + // We dont need to keep track of the buffers' id now. + delete[] buffers; + buffers = NULL; + + + //restart playing if not playing ALint playing; alGetSourcei(mWindSource, AL_SOURCE_STATE, &playing); if(playing != AL_PLAYING) diff --git a/indra/llaudio/llaudioengine_openal.h b/indra/llaudio/llaudioengine_openal.h index f274c2185..ecfdbfe77 100644 --- a/indra/llaudio/llaudioengine_openal.h +++ b/indra/llaudio/llaudioengine_openal.h @@ -72,8 +72,8 @@ class LLAudioEngine_OpenAL : public LLAudioEngine ALuint mWindSource; int mNumEmptyWindALBuffers; - static const int MAX_NUM_WIND_BUFFERS = 80; - static const float WIND_BUFFER_SIZE_SEC = 0.05f; // 1/20th sec + static const int MAX_NUM_WIND_BUFFERS = 80; + static const float WIND_BUFFER_SIZE_SEC; // 1/20th sec }; class LLAudioChannelOpenAL : public LLAudioChannel diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index fa81302cb..7e5d648fa 100644 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -48,7 +48,7 @@ // Locally used constants // const U32 SEC_PER_DAY = 86400; -const F64 SEC_TO_MICROSEC = 1000000.f; +const F64 SEC_TO_MICROSEC = 1000000.0; const U64 SEC_TO_MICROSEC_U64 = 1000000; const F64 USEC_TO_SEC_F64 = 0.000001; diff --git a/indra/llmath/llcalcparser.cpp b/indra/llmath/llcalcparser.cpp deleted file mode 100644 index fd55376fa..000000000 --- a/indra/llmath/llcalcparser.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * LLCalcParser.cpp - * SecondLife - * - * Created by Aimee Walton on 28/09/2008. - * Copyright 2008 Aimee Walton. - * - */ - -#include "linden_common.h" - -#include "llcalcparser.h" -using namespace boost::spirit::classic; - -F32 LLCalcParser::lookup(const std::string::iterator& start, const std::string::iterator& end) const -{ - LLCalc::calc_map_t::iterator iter; - - std::string name(start, end); - - if (mConstants) - { - iter = mConstants->find(name); - if (iter != mConstants->end()) - { - return (*iter).second; - } - } - else - { - // This should never happen! - throw_(end, std::string("Missing constants table")); - } - - if (mVariables) - { - iter = mVariables->find(name); - if (iter != mVariables->end()) - { - return (*iter).second; - } - } - - throw_(end, std::string("Unknown symbol " + name)); - return 0.f; -} diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 6dc930df1..30864755c 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -484,8 +484,8 @@ void LLFastTimerView::draw() sTimerColors[&LLFastTimer::NamedTimer::getRootNamedTimer()] = LLColor4::grey; F32 hue = 0.f; - - for (timer_tree_iterator_t it = begin_timer_tree(LLFastTimer::NamedTimer::getRootNamedTimer()); + // Move color generation down to be in the next loop. + /*for (timer_tree_iterator_t it = begin_timer_tree(LLFastTimer::NamedTimer::getRootNamedTimer()); it != timer_tree_iterator_t(); ++it) { @@ -502,7 +502,8 @@ void LLFastTimerView::draw() child_color.setHSL(hue, saturation, lightness); sTimerColors[idp] = child_color; - } + }*/ + // const S32 LEGEND_WIDTH = 220; { @@ -516,6 +517,20 @@ void LLFastTimerView::draw() ++it) { LLFastTimer::NamedTimer* idp = (*it); + // Move color generation down to be in the next loop. + const F32 HUE_INCREMENT = 0.23f; + hue = fmodf(hue + HUE_INCREMENT, 1.f); + // saturation increases with depth + F32 saturation = clamp_rescale((F32)idp->getDepth(), 0.f, 3.f, 0.f, 1.f); + // lightness alternates with depth + F32 lightness = idp->getDepth() % 2 ? 0.5f : 0.6f; + + LLColor4 child_color; + child_color.setHSL(hue, saturation, lightness); + + sTimerColors[idp] = child_color; + // + // Making the ledgend part of fast timers scrollable if(mScrollOffset_tmp) {