Import some changes from internal

This commit is contained in:
Drake Arconis
2013-03-12 06:03:06 -04:00
parent 9bce5d479a
commit 20cdb35172
5 changed files with 84 additions and 93 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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());
// <ALCH:LL> 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;
}
}*/
// </ALCH:LL>
const S32 LEGEND_WIDTH = 220;
{
@@ -516,6 +517,20 @@ void LLFastTimerView::draw()
++it)
{
LLFastTimer::NamedTimer* idp = (*it);
// <ALCH:LL> 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;
// </ALCH:LL>
// <FS:LO> Making the ledgend part of fast timers scrollable
if(mScrollOffset_tmp)
{