diff --git a/autobuild.xml b/autobuild.xml
index b3f547659..a5327c0f4 100644
--- a/autobuild.xml
+++ b/autobuild.xml
@@ -2658,11 +2658,11 @@
archive
name
windows
diff --git a/indra/CMakeLists.txt b/indra/CMakeLists.txt
index 59735a520..b480efd8e 100644
--- a/indra/CMakeLists.txt
+++ b/indra/CMakeLists.txt
@@ -14,6 +14,9 @@ set(ROOT_PROJECT_NAME "Singularity" CACHE STRING
"The root project/makefile/solution name. Defaults to Singularity.")
project(${ROOT_PROJECT_NAME})
+string(REPLACE " " "" VIEWER_CHANNEL_NOSPACE ${VIEWER_CHANNEL})
+set(VIEWER_CHANNEL_NOSPACE ${VIEWER_CHANNEL_NOSPACE} CACHE STRING "Prefix used for resulting artifacts.")
+
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include(Variables)
diff --git a/indra/cmake/Boost.cmake b/indra/cmake/Boost.cmake
index 844d5dc49..81727aef6 100644
--- a/indra/cmake/Boost.cmake
+++ b/indra/cmake/Boost.cmake
@@ -36,6 +36,9 @@ else (STANDALONE)
set(Boost_THREAD_LIBRARY
optimized libboost_thread-mt
debug libboost_thread-mt-gd)
+ set(Boost_CHRONO_LIBRARY
+ optimized libboost_chrono-mt
+ debug libboost_chrono-mt-gd)
elseif (LINUX)
set(Boost_CONTEXT_LIBRARY
optimized boost_context-mt
@@ -58,6 +61,9 @@ else (STANDALONE)
set(Boost_THREAD_LIBRARY
optimized boost_thread-mt
debug boost_thread-mt-d)
+ set(Boost_CHRONO_LIBRARY
+ optimized libboost_chrono-mt
+ debug libboost_chrono-mt-d)
elseif (DARWIN)
set(Boost_CONTEXT_LIBRARY
optimized boost_context-mt
@@ -80,5 +86,8 @@ else (STANDALONE)
set(Boost_THREAD_LIBRARY
optimized boost_thread-mt
debug boost_thread-mt-d)
+ set(Boost_CHRONO_LIBRARY
+ optimized libboost_chrono-mt
+ debug libboost_chrono-mt-d)
endif (WINDOWS)
endif (STANDALONE)
diff --git a/indra/cmake/Variables.cmake b/indra/cmake/Variables.cmake
index ed2f43e01..28082a3a5 100644
--- a/indra/cmake/Variables.cmake
+++ b/indra/cmake/Variables.cmake
@@ -172,6 +172,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_OSX_ARCHITECTURES i386)
set(ARCH i386)
set(WORD_SIZE 32)
+ set(AUTOBUILD_PLATFORM_NAME "darwin")
set(LL_ARCH ${ARCH}_darwin)
set(LL_ARCH_DIR universal-darwin)
diff --git a/indra/llappearance/llavatarappearance.cpp b/indra/llappearance/llavatarappearance.cpp
index e016b4790..27519722a 100644
--- a/indra/llappearance/llavatarappearance.cpp
+++ b/indra/llappearance/llavatarappearance.cpp
@@ -489,25 +489,6 @@ void LLAvatarAppearance::computeBodySize()
mAvatarOffset.mV[VX] = 0.0f;
mAvatarOffset.mV[VY] = 0.0f;
- // Certain configurations of avatars can force the overall height (with offset) to go negative.
- // Enforce a constraint to make sure we don't go below 0.1 meters.
- // Camera positioning and other things start to break down when your avatar is "walking" while being fully underground
- if (new_body_size.mV[VZ] + mAvatarOffset.mV[VZ] < 0.1f)
- {
- mAvatarOffset.mV[VZ] = -(new_body_size.mV[VZ] - 0.11f); // avoid floating point rounding making the above check continue to fail.
-
- llassert(new_body_size.mV[VZ] + mAvatarOffset.mV[VZ] >= 0.1f);
-
- if (mWearableData && isSelf())
- {
- LLWearable* shape = mWearableData->getWearable(LLWearableType::WT_SHAPE, 0);
- if (shape)
- {
- shape->setVisualParamWeight(AVATAR_HOVER, mAvatarOffset.mV[VZ], false);
- }
- }
- }
-
if (new_body_size != mBodySize || old_offset != mAvatarOffset)
{
mBodySize = new_body_size;
@@ -595,8 +576,6 @@ BOOL LLAvatarAppearance::setupBone(const LLAvatarBoneInfo* info, LLJoint* parent
info->mRot.mV[VZ], LLQuaternion::XYZ));
joint->setScale(info->mScale);
- joint->setDefaultFromCurrentXform();
-
if (info->mIsJoint)
{
joint->setSkinOffset( info->mPivot );
@@ -696,6 +675,42 @@ void LLAvatarAppearance::clearSkeleton()
mSkeleton.clear();
}
+//------------------------------------------------------------------------
+// addPelvisFixup
+//------------------------------------------------------------------------
+void LLAvatarAppearance::addPelvisFixup( F32 fixup, const LLUUID& mesh_id )
+{
+ LLVector3 pos(0.0,0.0,fixup);
+ mPelvisFixups.add(mesh_id,pos);
+}
+
+//------------------------------------------------------------------------
+// addPelvisFixup
+//------------------------------------------------------------------------
+void LLAvatarAppearance::removePelvisFixup( const LLUUID& mesh_id )
+{
+ mPelvisFixups.remove(mesh_id);
+}
+
+//------------------------------------------------------------------------
+// hasPelvisFixup
+//------------------------------------------------------------------------
+bool LLAvatarAppearance::hasPelvisFixup( F32& fixup, LLUUID& mesh_id ) const
+{
+ LLVector3 pos;
+ if (mPelvisFixups.findActiveOverride(mesh_id,pos))
+ {
+ fixup = pos[2];
+ return true;
+ }
+ return false;
+}
+
+bool LLAvatarAppearance::hasPelvisFixup( F32& fixup ) const
+{
+ LLUUID mesh_id;
+ return hasPelvisFixup( fixup, mesh_id );
+}
//-----------------------------------------------------------------------------
// LLAvatarAppearance::buildCharacter()
// Deferred initialization and rebuild of the avatar.
diff --git a/indra/llappearance/llavatarappearance.h b/indra/llappearance/llavatarappearance.h
index f691d7378..00b485389 100644
--- a/indra/llappearance/llavatarappearance.h
+++ b/indra/llappearance/llavatarappearance.h
@@ -159,11 +159,17 @@ protected:
BOOL mIsBuilt; // state of deferred character building
typedef std::vector avatar_joint_list_t;
avatar_joint_list_t mSkeleton;
-
+ LLPosOverrideMap mPelvisFixups;
+
//--------------------------------------------------------------------
// Pelvis height adjustment members.
//--------------------------------------------------------------------
public:
+ void addPelvisFixup( F32 fixup, const LLUUID& mesh_id );
+ void removePelvisFixup( const LLUUID& mesh_id );
+ bool hasPelvisFixup( F32& fixup, LLUUID& mesh_id ) const;
+ bool hasPelvisFixup( F32& fixup ) const;
+
LLVector3 mBodySize;
LLVector3 mAvatarOffset;
protected:
diff --git a/indra/llappearance/llavatarappearancedefines.cpp b/indra/llappearance/llavatarappearancedefines.cpp
index f1c78946a..9c8d48914 100644
--- a/indra/llappearance/llavatarappearancedefines.cpp
+++ b/indra/llappearance/llavatarappearancedefines.cpp
@@ -212,6 +212,7 @@ LLAvatarAppearanceDictionary::BakedEntry::BakedEntry(ETextureIndex tex_index,
LLWearableType::EType t = (LLWearableType::EType)va_arg(argp,int);
mWearables.push_back(t);
}
+ va_end(argp);
}
// static
diff --git a/indra/llappearance/llavatarjointmesh.cpp b/indra/llappearance/llavatarjointmesh.cpp
index 4853a6670..64ec9cd8d 100644
--- a/indra/llappearance/llavatarjointmesh.cpp
+++ b/indra/llappearance/llavatarjointmesh.cpp
@@ -85,8 +85,6 @@ LLSkinJoint::~LLSkinJoint()
//-----------------------------------------------------------------------------
void LLSkinJoint::setupSkinJoint( LLJoint *joint)
{
- mRootToJointSkinOffset.clearVec();
- mRootToParentJointSkinOffset.clearVec();
// find the named joint
if (!(mJoint = joint))
@@ -96,6 +94,9 @@ void LLSkinJoint::setupSkinJoint( LLJoint *joint)
}
// compute the inverse root skin matrix
+ mRootToJointSkinOffset.clearVec();
+ mRootToParentJointSkinOffset.clearVec();
+
do
{
mRootToJointSkinOffset -= joint->getSkinOffset();
diff --git a/indra/llappearance/llpolymorph.cpp b/indra/llappearance/llpolymorph.cpp
index 873169cba..400a14066 100644
--- a/indra/llappearance/llpolymorph.cpp
+++ b/indra/llappearance/llpolymorph.cpp
@@ -680,8 +680,8 @@ BOOL LLPolyMorphTarget::setInfo(LLPolyMorphTargetInfo* info)
if (!mMorphData)
{
const std::string driven_tag = "_Driven";
- U32 pos = morph_param_name.find(driven_tag);
- if (pos > 0)
+ size_t pos = morph_param_name.find(driven_tag);
+ if (pos != std::string::npos)
{
morph_param_name = morph_param_name.substr(0,pos);
mMorphData = mMesh->getMorphData(morph_param_name);
diff --git a/indra/llappearance/lltexlayer.cpp b/indra/llappearance/lltexlayer.cpp
index b0f922b95..1648c1114 100644
--- a/indra/llappearance/lltexlayer.cpp
+++ b/indra/llappearance/lltexlayer.cpp
@@ -1557,13 +1557,13 @@ void LLTexLayer::renderMorphMasks(S32 x, S32 y, S32 width, S32 height, const LLC
}
U32 cache_index = alpha_mask_crc.getCRC();
- U8* alpha_data = NULL;//get_if_there(mAlphaCache,cache_index,(U8*)NULL);
+ U8* alpha_data = NULL;
// We believe we need to generate morph masks, do not assume that the cached version is accurate.
// We can get bad morph masks during login, on minimize, and occasional gl errors.
// We should only be doing this when we believe something has changed with respect to the user's appearance.
- //if (!alpha_data)
{
- // clear out a slot if we have filled our cache
+ LL_DEBUGS("Avatar") << "gl alpha cache of morph mask not found, doing readback: " << getName() << LL_ENDL;
+ // clear out a slot if we have filled our cache
S32 max_cache_entries = getTexLayerSet()->getAvatarAppearance()->isSelf() ? 4 : 1;
while ((S32)mAlphaCache.size() >= max_cache_entries)
{
@@ -1573,8 +1573,12 @@ void LLTexLayer::renderMorphMasks(S32 x, S32 y, S32 width, S32 height, const LLC
mAlphaCache.erase(iter2);
}
alpha_data = new U8[width * height];
+ U8* pixels_tmp = new U8[width * height * 4];
+ glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels_tmp);
+ for (int i = 0; i < width * height; ++i)
+ alpha_data[i] = pixels_tmp[i * 4 + 3];
+ delete[] pixels_tmp;
mAlphaCache[cache_index] = alpha_data;
- glReadPixels(x, y, width, height, GL_ALPHA, GL_UNSIGNED_BYTE, alpha_data);
}
getTexLayerSet()->getAvatarAppearance()->dirtyMesh();
@@ -1783,13 +1787,11 @@ LLTexLayer* LLTexLayerTemplate::getLayer(U32 i) const
/*virtual*/ void LLTexLayerTemplate::gatherAlphaMasks(U8 *data, S32 originX, S32 originY, S32 width, S32 height)
{
U32 num_wearables = updateWearableCache();
- for (U32 i = 0; i < num_wearables; i++)
+ U32 i = num_wearables - 1; // For rendering morph masks, we only want to use the top wearable
+ LLTexLayer *layer = getLayer(i);
+ if (layer)
{
- LLTexLayer *layer = getLayer(i);
- if (layer)
- {
- layer->addAlphaMask(data, originX, originY, width, height);
- }
+ layer->addAlphaMask(data, originX, originY, width, height);
}
}
diff --git a/indra/llappearance/llwearabledata.cpp b/indra/llappearance/llwearabledata.cpp
index 24c011d6f..1015cec69 100644
--- a/indra/llappearance/llwearabledata.cpp
+++ b/indra/llappearance/llwearabledata.cpp
@@ -178,8 +178,9 @@ bool LLWearableData::swapWearables(const LLWearableType::EType type, U32 index_a
}
wearableentry_vec_t& wearable_vec = wearable_iter->second;
- if (0 > index_a || index_a >= wearable_vec.size()) return false;
- if (0 > index_b || index_b >= wearable_vec.size()) return false;
+ // removed 0 > index_a and index_b comparisions - can never be true
+ if (index_a >= wearable_vec.size()) return false;
+ if (index_b >= wearable_vec.size()) return false;
LLWearable* wearable = wearable_vec[index_a];
wearable_vec[index_a] = wearable_vec[index_b];
diff --git a/indra/llaudio/llaudiodecodemgr.cpp b/indra/llaudio/llaudiodecodemgr.cpp
index 18635737b..5f5696e37 100644
--- a/indra/llaudio/llaudiodecodemgr.cpp
+++ b/indra/llaudio/llaudiodecodemgr.cpp
@@ -33,7 +33,6 @@
#include "llaudiodecodemgr.h"
-#include "llvorbisdecode.h"
#include "llaudioengine.h"
#include "lllfsthread.h"
#include "llvfile.h"
@@ -43,10 +42,12 @@
#include "llassetstorage.h"
#include "llrefcount.h"
+#include "llvorbisencode.h"
+
#include "vorbis/codec.h"
#include "vorbis/vorbisfile.h"
-#include "llvorbisencode.h"
-#include //VS2010
+#include
+#include
extern LLAudioEngine *gAudiop;
@@ -120,7 +121,7 @@ size_t vfs_read(void *ptr, size_t size, size_t nmemb, void *datasource)
}
}
-int vfs_seek(void *datasource, ogg_int64_t offset, int whence)
+S32 vfs_seek(void *datasource, ogg_int64_t offset, S32 whence)
{
LLVFile *file = (LLVFile *)datasource;
@@ -142,7 +143,7 @@ int vfs_seek(void *datasource, ogg_int64_t offset, int whence)
origin = -1;
break;
default:
- LL_ERRS() << "Invalid whence argument to vfs_seek" << LL_ENDL;
+ LL_ERRS("AudioEngine") << "Invalid whence argument to vfs_seek" << LL_ENDL;
return -1;
}
@@ -156,7 +157,7 @@ int vfs_seek(void *datasource, ogg_int64_t offset, int whence)
}
}
-int vfs_close (void *datasource)
+S32 vfs_close (void *datasource)
{
LLVFile *file = (LLVFile *)datasource;
delete file;
@@ -196,25 +197,25 @@ BOOL LLVorbisDecodeState::initDecode()
vfs_callbacks.close_func = vfs_close;
vfs_callbacks.tell_func = vfs_tell;
- //LL_INFOS() << "Initing decode from vfile: " << mUUID << LL_ENDL;
+ LL_DEBUGS("AudioEngine") << "Initing decode from vfile: " << mUUID << LL_ENDL;
mInFilep = new LLVFile(gVFS, mUUID, LLAssetType::AT_SOUND);
if (!mInFilep || !mInFilep->getSize())
{
- LL_WARNS() << "unable to open vorbis source vfile for reading" << LL_ENDL;
+ LL_WARNS("AudioEngine") << "unable to open vorbis source vfile for reading" << LL_ENDL;
delete mInFilep;
mInFilep = NULL;
return FALSE;
}
- int r = ov_open_callbacks(mInFilep, &mVF, NULL, 0, vfs_callbacks);
+ S32 r = ov_open_callbacks(mInFilep, &mVF, NULL, 0, vfs_callbacks);
if(r < 0)
{
- LL_WARNS() << r << " Input to vorbis decode does not appear to be an Ogg bitstream: " << mUUID << LL_ENDL;
+ LL_WARNS("AudioEngine") << r << " Input to vorbis decode does not appear to be an Ogg bitstream: " << mUUID << LL_ENDL;
return(FALSE);
}
- S32 sample_count = ov_pcm_total(&mVF, -1);
+ S32 sample_count = (S32)ov_pcm_total(&mVF, -1);
size_t size_guess = (size_t)sample_count;
vorbis_info* vi = ov_info(&mVF, -1);
size_guess *= (vi? vi->channels : 1);
@@ -228,13 +229,13 @@ BOOL LLVorbisDecodeState::initDecode()
if( vi->channels < 1 || vi->channels > LLVORBIS_CLIP_MAX_CHANNELS )
{
abort_decode = true;
- LL_WARNS() << "Bad channel count: " << vi->channels << LL_ENDL;
+ LL_WARNS("AudioEngine") << "Bad channel count: " << vi->channels << LL_ENDL;
}
}
else // !vi
{
abort_decode = true;
- LL_WARNS() << "No default bitstream found" << LL_ENDL;
+ LL_WARNS("AudioEngine") << "No default bitstream found" << LL_ENDL;
}
//
// This magic value is equivalent to 150MiB of data.
@@ -252,25 +253,25 @@ BOOL LLVorbisDecodeState::initDecode()
(size_t)sample_count <= 0)
{
abort_decode = true;
- LL_WARNS() << "Illegal sample count: " << sample_count << LL_ENDL;
+ LL_WARNS("AudioEngine") << "Illegal sample count: " << sample_count << LL_ENDL;
}
if( size_guess > LLVORBIS_CLIP_REJECT_SIZE ||
size_guess < 0)
{
abort_decode = true;
- LL_WARNS() << "Illegal sample size: " << size_guess << LL_ENDL;
+ LL_WARNS("AudioEngine") << "Illegal sample size: " << size_guess << LL_ENDL;
}
//
}
//
if( abort_decode )
{
- LL_WARNS() << "Canceling initDecode. Bad asset: " << mUUID << LL_ENDL;
+ LL_WARNS("AudioEngine") << "Canceling initDecode. Bad asset: " << mUUID << LL_ENDL;
vorbis_comment* comment = ov_comment(&mVF,-1);
if (comment && comment->vendor)
{
- LL_WARNS() << "Bad asset encoded by: " << comment->vendor << LL_ENDL;
+ LL_WARNS("AudioEngine") << "Bad asset encoded by: " << comment->vendor << LL_ENDL;
}
delete mInFilep;
mInFilep = NULL;
@@ -388,7 +389,7 @@ BOOL LLVorbisDecodeState::decodeSection()
{
if (!mInFilep)
{
- LL_WARNS() << "No VFS file to decode in vorbis!" << LL_ENDL;
+ LL_WARNS("AudioEngine") << "No VFS file to decode in vorbis!" << LL_ENDL;
return TRUE;
}
if (mDone)
@@ -413,7 +414,7 @@ BOOL LLVorbisDecodeState::decodeSection()
/* error in the stream. Not a problem, just reporting it in
case we (the app) cares. In this case, we don't. */
- LL_WARNS() << "BAD vorbis decode in decodeSection." << LL_ENDL;
+ LL_WARNS("AudioEngine") << "BAD vorbis decode in decodeSection." << LL_ENDL;
mValid = FALSE;
mDone = TRUE;
@@ -434,7 +435,7 @@ BOOL LLVorbisDecodeState::finishDecode()
{
if (!isValid())
{
- LL_WARNS() << "Bogus vorbis decode state for " << getUUID() << ", aborting!" << LL_ENDL;
+ LL_WARNS("AudioEngine") << "Bogus vorbis decode state for " << getUUID() << ", aborting!" << LL_ENDL;
return TRUE; // We've finished
}
@@ -515,7 +516,7 @@ BOOL LLVorbisDecodeState::finishDecode()
if (36 == data_length)
{
- LL_WARNS() << "BAD Vorbis decode in finishDecode!" << LL_ENDL;
+ LL_WARNS("AudioEngine") << "BAD Vorbis decode in finishDecode!" << LL_ENDL;
mValid = FALSE;
return TRUE; // we've finished
}
@@ -532,7 +533,7 @@ BOOL LLVorbisDecodeState::finishDecode()
{
if (mBytesRead == 0)
{
- LL_WARNS() << "Unable to write file in LLVorbisDecodeState::finishDecode" << LL_ENDL;
+ LL_WARNS("AudioEngine") << "Unable to write file in LLVorbisDecodeState::finishDecode" << LL_ENDL;
mValid = FALSE;
return TRUE; // we've finished
}
@@ -550,7 +551,7 @@ BOOL LLVorbisDecodeState::finishDecode()
LLVFile output(gVFS, mUUID, LLAssetType::AT_SOUND_WAV);
output.write(&mWAVBuffer[0], mWAVBuffer.size());
#endif
- //LL_INFOS() << "Finished decode for " << getUUID() << LL_ENDL;
+ LL_DEBUGS("AudioEngine") << "Finished decode for " << getUUID() << LL_ENDL;
return TRUE;
}
@@ -559,7 +560,7 @@ void LLVorbisDecodeState::flushBadFile()
{
if (mInFilep)
{
- LL_WARNS() << "Flushing bad vorbis file from VFS for " << mUUID << LL_ENDL;
+ LL_WARNS("AudioEngine") << "Flushing bad vorbis file from VFS for " << mUUID << LL_ENDL;
mInFilep->remove();
}
}
@@ -576,7 +577,7 @@ public:
void processQueue(const F32 num_secs = 0.005);
protected:
- LLLinkedQueue mDecodeQueue;
+ std::deque mDecodeQueue;
LLPointer mCurrentDecodep;
};
@@ -608,12 +609,16 @@ void LLAudioDecodeMgr::Impl::processQueue(const F32 num_secs)
if (mCurrentDecodep->isDone() && !mCurrentDecodep->isValid())
{
// We had an error when decoding, abort.
- LL_WARNS() << mCurrentDecodep->getUUID() << " has invalid vorbis data, aborting decode" << LL_ENDL;
+ LL_WARNS("AudioEngine") << mCurrentDecodep->getUUID() << " has invalid vorbis data, aborting decode" << LL_ENDL;
mCurrentDecodep->flushBadFile();
- LLAudioData *adp = gAudiop->getAudioData(mCurrentDecodep->getUUID());
- if(adp)
+
+ if (gAudiop)
{
- adp->setLoadState(LLAudioData::STATE_LOAD_ERROR);
+ LLAudioData *adp = gAudiop->getAudioData(mCurrentDecodep->getUUID());
+ if(adp)
+ {
+ adp->setLoadState(LLAudioData::STATE_LOAD_ERROR);
+ }
}
mCurrentDecodep = NULL;
done = TRUE;
@@ -626,13 +631,13 @@ void LLAudioDecodeMgr::Impl::processQueue(const F32 num_secs)
}
else if (mCurrentDecodep)
{
- if (mCurrentDecodep->finishDecode())
+ if (gAudiop && mCurrentDecodep->finishDecode())
{
// We finished!
LLAudioData *adp = gAudiop->getAudioData(mCurrentDecodep->getUUID());
if (!adp)
{
- LL_WARNS() << "Missing LLAudioData for decode of " << mCurrentDecodep->getUUID() << LL_ENDL;
+ LL_WARNS("AudioEngine") << "Missing LLAudioData for decode of " << mCurrentDecodep->getUUID() << LL_ENDL;
}
else if (mCurrentDecodep->isValid() && mCurrentDecodep->isDone())
{
@@ -645,7 +650,7 @@ void LLAudioDecodeMgr::Impl::processQueue(const F32 num_secs)
else
{
adp->setLoadState(LLAudioData::STATE_LOAD_ERROR);
- LL_INFOS() << "Vorbis decode failed for " << mCurrentDecodep->getUUID() << LL_ENDL;
+ LL_INFOS("AudioEngine") << "Vorbis decode failed for " << mCurrentDecodep->getUUID() << LL_ENDL;
}
mCurrentDecodep = NULL;
}
@@ -655,7 +660,7 @@ void LLAudioDecodeMgr::Impl::processQueue(const F32 num_secs)
if (!done)
{
- if (!mDecodeQueue.getLength())
+ if (mDecodeQueue.empty())
{
// Nothing else on the queue.
done = TRUE;
@@ -663,8 +668,9 @@ void LLAudioDecodeMgr::Impl::processQueue(const F32 num_secs)
else
{
LLUUID uuid;
- mDecodeQueue.pop(uuid);
- if (gAudiop->hasDecodedFile(uuid))
+ uuid = mDecodeQueue.front();
+ mDecodeQueue.pop_front();
+ if (!gAudiop || gAudiop->hasDecodedFile(uuid))
{
// This file has already been decoded, don't decode it again.
continue;
@@ -715,11 +721,26 @@ void LLAudioDecodeMgr::processQueue(const F32 num_secs)
bool LLAudioDecodeMgr::addDecodeRequest(const LLUUID &uuid)
{
- if(!uuid.notNull())
- return false;
- else if (!gAssetStorage || !gAssetStorage->hasLocalAsset(uuid, LLAssetType::AT_SOUND))
- return false;
-
- mImpl->mDecodeQueue.push(uuid);
- return true;
+ if(uuid.isNull())
+ {
+ return true;
+ }
+
+ if (gAudiop && gAudiop->hasDecodedFile(uuid))
+ {
+ // Already have a decoded version, don't need to decode it.
+ LL_DEBUGS("AudioEngine") << "addDecodeRequest for " << uuid << " has decoded file already" << LL_ENDL;
+ return true;
+ }
+
+ if (gAssetStorage && gAssetStorage->hasLocalAsset(uuid, LLAssetType::AT_SOUND))
+ {
+ // Just put it on the decode queue.
+ LL_DEBUGS("AudioEngine") << "addDecodeRequest for " << uuid << " has local asset file already" << LL_ENDL;
+ mImpl->mDecodeQueue.push_back(uuid);
+ return true;
+ }
+
+ LL_DEBUGS("AudioEngine") << "addDecodeRequest for " << uuid << " no file available" << LL_ENDL;
+ return false;
}
diff --git a/indra/llaudio/llaudiodecodemgr.h b/indra/llaudio/llaudiodecodemgr.h
index 3ff894dba..e2319a32f 100644
--- a/indra/llaudio/llaudiodecodemgr.h
+++ b/indra/llaudio/llaudiodecodemgr.h
@@ -28,7 +28,6 @@
#include "stdtypes.h"
-#include "lllinkedqueue.h"
#include "lluuid.h"
#include "llassettype.h"
diff --git a/indra/llaudio/llaudioengine.cpp b/indra/llaudio/llaudioengine.cpp
index 99e151f12..61aa25be1 100644
--- a/indra/llaudio/llaudioengine.cpp
+++ b/indra/llaudio/llaudioengine.cpp
@@ -1046,8 +1046,12 @@ void LLAudioEngine::cleanupAudioSource(LLAudioSource *asp)
LL_WARNS("AudioEngine") << "Cleaning up unknown audio source!" << LL_ENDL;
return;
}
- delete asp;
- mAllSources.erase(iter);
+ else
+ {
+ LL_DEBUGS("AudioEngine") << "Cleaning up audio sources for "<< asp->getID() <createDSP(&dspdesc, &mWindDSP), "FMOD::createDSP") || !mWindDSP)
+ mWindDSPDesc = new FMOD_DSP_DESCRIPTION();
+ memset(mWindDSPDesc, 0, sizeof(*mWindDSPDesc)); //Set everything to zero
+ mWindDSPDesc->pluginsdkversion = FMOD_PLUGIN_SDK_VERSION;
+ strncpy(mWindDSPDesc->name, "Wind Unit", sizeof(mWindDSPDesc->name)); //Set name to "Wind Unit"
+ mWindDSPDesc->numoutputbuffers = 1;
+ mWindDSPDesc->read = &windDSPCallback; //Assign callback.
+ if (Check_FMOD_Error(mSystem->createDSP(mWindDSPDesc, &mWindDSP), "FMOD::createDSP") || !mWindDSP)
return false;
int frequency = 44100;
@@ -518,9 +517,9 @@ bool LLAudioEngine_FMODSTUDIO::initWind()
mWindGen = new LLWindGen((U32)frequency);
if (!Check_FMOD_Error(mWindDSP->setUserData((void*)mWindGen), "FMOD::DSP::setUserData") &&
- !Check_FMOD_Error(mSystem->playDSP(mWindDSP, NULL, false, 0), "FMOD::System::playDSP") &&
!Check_FMOD_Error(mSystem->getSoftwareFormat(NULL, &mode, NULL), "FMOD::System::getSoftwareFormat") &&
- !Check_FMOD_Error(mWindDSP->setChannelFormat(FMOD_CHANNELMASK_STEREO, 2, mode), "FMOD::DSP::setChannelFormat"))
+ !Check_FMOD_Error(mWindDSP->setChannelFormat(FMOD_CHANNELMASK_STEREO, 2, mode), "FMOD::DSP::setChannelFormat") &&
+ !Check_FMOD_Error(mSystem->playDSP(mWindDSP, NULL, false, 0), "FMOD::System::playDSP"))
return true; //Success
}
@@ -540,6 +539,9 @@ void LLAudioEngine_FMODSTUDIO::cleanupWind()
mWindDSP = NULL;
}
+ delete mWindDSPDesc;
+ mWindDSPDesc = NULL;
+
delete mWindGen;
mWindGen = NULL;
}
@@ -885,7 +887,7 @@ bool LLAudioBufferFMODSTUDIO::loadWAV(const std::string& filename)
return false;
}
- if (!LLAPRFile::isExist(filename, LL_APR_RPB))
+ if (!gDirUtilp->fileExists(filename))
{
// File not found, abort.
return false;
diff --git a/indra/llaudio/llaudioengine_fmodstudio.h b/indra/llaudio/llaudioengine_fmodstudio.h
index 730a702a1..ff45d3ecb 100644
--- a/indra/llaudio/llaudioengine_fmodstudio.h
+++ b/indra/llaudio/llaudioengine_fmodstudio.h
@@ -48,6 +48,7 @@ namespace FMOD
class Sound;
class DSP;
}
+typedef struct FMOD_DSP_DESCRIPTION FMOD_DSP_DESCRIPTION;
//Interfaces
class LLAudioEngine_FMODSTUDIO : public LLAudioEngine
@@ -81,6 +82,7 @@ protected:
LLWindGen *mWindGen;
+ FMOD_DSP_DESCRIPTION *mWindDSPDesc;
FMOD::DSP *mWindDSP;
FMOD::System *mSystem;
bool mEnableProfiler;
diff --git a/indra/llaudio/lllistener.cpp b/indra/llaudio/lllistener.cpp
index df2366c8c..0723fdbeb 100644
--- a/indra/llaudio/lllistener.cpp
+++ b/indra/llaudio/lllistener.cpp
@@ -28,15 +28,18 @@
#include "lllistener.h"
-#define DEFAULT_AT 0.0f,0.0f,-1.0f
-#define DEFAULT_UP 0.0f,1.0f,0.0f
+const LLVector3 DEFAULT_AT(0.0f, 0.0f, -1.0f);
+const LLVector3 DEFAULT_UP(0.0f, 1.0f, 0.0f);
//-----------------------------------------------------------------------
// constructor
//-----------------------------------------------------------------------
LLListener::LLListener()
+ : mPosition(LLVector3::zero),
+ mListenAt(DEFAULT_AT),
+ mListenUp(DEFAULT_UP),
+ mVelocity(LLVector3::zero)
{
- init();
}
//-----------------------------------------------------------------------
@@ -44,15 +47,6 @@ LLListener::~LLListener()
{
}
-//-----------------------------------------------------------------------
-void LLListener::init(void)
-{
- mPosition.zeroVec();
- mListenAt.setVec(DEFAULT_AT);
- mListenUp.setVec(DEFAULT_UP);
- mVelocity.zeroVec();
-}
-
//-----------------------------------------------------------------------
void LLListener::translate(LLVector3 offset)
{
@@ -99,9 +93,6 @@ void LLListener::orient(LLVector3 up, LLVector3 at)
//-----------------------------------------------------------------------
void LLListener::set(LLVector3 pos, LLVector3 vel, LLVector3 up, LLVector3 at)
{
- mPosition = pos;
- mVelocity = vel;
-
setPosition(pos);
setVelocity(vel);
orient(up,at);
diff --git a/indra/llaudio/lllistener.h b/indra/llaudio/lllistener.h
index 41836bf03..11c1ad2ae 100644
--- a/indra/llaudio/lllistener.h
+++ b/indra/llaudio/lllistener.h
@@ -45,7 +45,6 @@ class LLListener
public:
LLListener();
virtual ~LLListener();
- virtual void init();
virtual void set(LLVector3 pos, LLVector3 vel, LLVector3 up, LLVector3 at);
diff --git a/indra/llaudio/lllistener_fmodstudio.cpp b/indra/llaudio/lllistener_fmodstudio.cpp
index e2074ce2d..42d819ef6 100644
--- a/indra/llaudio/lllistener_fmodstudio.cpp
+++ b/indra/llaudio/lllistener_fmodstudio.cpp
@@ -39,10 +39,12 @@
//-----------------------------------------------------------------------
// constructor
//-----------------------------------------------------------------------
-LLListener_FMODSTUDIO::LLListener_FMODSTUDIO(FMOD::System *system)
+LLListener_FMODSTUDIO::LLListener_FMODSTUDIO(FMOD::System *system)
+ : LLListener(),
+ mDopplerFactor(1.0f),
+ mRolloffFactor(1.0f)
{
mSystem = system;
- init();
}
//-----------------------------------------------------------------------
@@ -50,21 +52,12 @@ LLListener_FMODSTUDIO::~LLListener_FMODSTUDIO()
{
}
-//-----------------------------------------------------------------------
-void LLListener_FMODSTUDIO::init(void)
-{
- // do inherited
- LLListener::init();
- mDopplerFactor = 1.0f;
- mRolloffFactor = 1.0f;
-}
-
//-----------------------------------------------------------------------
void LLListener_FMODSTUDIO::translate(LLVector3 offset)
{
LLListener::translate(offset);
- mSystem->set3DListenerAttributes(0, (FMOD_VECTOR*)mPosition.mV, NULL, (FMOD_VECTOR*)mListenAt.mV, (FMOD_VECTOR*)mListenUp.mV);
+ mSystem->set3DListenerAttributes(0, (FMOD_VECTOR*)mPosition.mV, NULL, NULL, NULL);
}
//-----------------------------------------------------------------------
@@ -72,7 +65,7 @@ void LLListener_FMODSTUDIO::setPosition(LLVector3 pos)
{
LLListener::setPosition(pos);
- mSystem->set3DListenerAttributes(0, (FMOD_VECTOR*)mPosition.mV, NULL, (FMOD_VECTOR*)mListenAt.mV, (FMOD_VECTOR*)mListenUp.mV);
+ mSystem->set3DListenerAttributes(0, (FMOD_VECTOR*)mPosition.mV, NULL, NULL, NULL);
}
//-----------------------------------------------------------------------
@@ -80,7 +73,7 @@ void LLListener_FMODSTUDIO::setVelocity(LLVector3 vel)
{
LLListener::setVelocity(vel);
- mSystem->set3DListenerAttributes(0, NULL, (FMOD_VECTOR*)mVelocity.mV, (FMOD_VECTOR*)mListenAt.mV, (FMOD_VECTOR*)mListenUp.mV);
+ mSystem->set3DListenerAttributes(0, NULL, (FMOD_VECTOR*)mVelocity.mV, NULL, NULL);
}
//-----------------------------------------------------------------------
@@ -94,20 +87,25 @@ void LLListener_FMODSTUDIO::orient(LLVector3 up, LLVector3 at)
//-----------------------------------------------------------------------
void LLListener_FMODSTUDIO::commitDeferredChanges()
{
+ if(!mSystem)
+ {
+ return;
+ }
+
mSystem->update();
}
void LLListener_FMODSTUDIO::setRolloffFactor(F32 factor)
{
- //An internal FMODEx optimization skips 3D updates if there have not been changes to the 3D sound environment.
+ //An internal FMOD Studio optimization skips 3D updates if there have not been changes to the 3D sound environment.
//Sadly, a change in rolloff is not accounted for, thus we must touch the listener properties as well.
- //In short: Changing the position ticks a dirtyflag inside fmodstudio, which makes it not skip 3D processing next update call.
+ //In short: Changing the position ticks a dirtyflag inside fmod studio, which makes it not skip 3D processing next update call.
if(mRolloffFactor != factor)
{
- LLVector3 pos = mVelocity - LLVector3(0.f,0.f,.1f);
- mSystem->set3DListenerAttributes(0, (FMOD_VECTOR*)pos.mV, NULL, NULL, NULL);
- mSystem->set3DListenerAttributes(0, (FMOD_VECTOR*)mVelocity.mV, NULL, NULL, NULL);
+ LLVector3 tmp_pos = mPosition - LLVector3(0.f,0.f,.1f);
+ mSystem->set3DListenerAttributes(0, (FMOD_VECTOR*) tmp_pos.mV, NULL, NULL, NULL);
+ mSystem->set3DListenerAttributes(0, (FMOD_VECTOR*) mPosition.mV, NULL, NULL, NULL);
}
mRolloffFactor = factor;
mSystem->set3DSettings(mDopplerFactor, 1.f, mRolloffFactor);
diff --git a/indra/llaudio/lllistener_fmodstudio.h b/indra/llaudio/lllistener_fmodstudio.h
index 516f4eae8..de9a5e9ca 100644
--- a/indra/llaudio/lllistener_fmodstudio.h
+++ b/indra/llaudio/lllistener_fmodstudio.h
@@ -48,7 +48,6 @@ class LLListener_FMODSTUDIO : public LLListener
public:
LLListener_FMODSTUDIO(FMOD::System *system);
virtual ~LLListener_FMODSTUDIO();
- virtual void init();
virtual void translate(LLVector3 offset);
virtual void setPosition(LLVector3 pos);
diff --git a/indra/llaudio/lllistener_openal.cpp b/indra/llaudio/lllistener_openal.cpp
index 462484e33..d1734a930 100644
--- a/indra/llaudio/lllistener_openal.cpp
+++ b/indra/llaudio/lllistener_openal.cpp
@@ -31,21 +31,15 @@
#include "lllistener_openal.h"
LLListener_OpenAL::LLListener_OpenAL()
+ : LLListener(),
+ mRolloffFactor(1.f)
{
- init();
}
LLListener_OpenAL::~LLListener_OpenAL()
{
}
-void LLListener_OpenAL::init()
-{
- // do inherited
- LLListener::init();
- mRolloffFactor = 1.0f;
-}
-
void LLListener_OpenAL::translate(LLVector3 offset)
{
//LL_INFOS() << "LLListener_OpenAL::translate() : " << offset << LL_ENDL;
@@ -71,18 +65,20 @@ void LLListener_OpenAL::orient(LLVector3 up, LLVector3 at)
void LLListener_OpenAL::commitDeferredChanges()
{
- ALfloat orientation[6];
- orientation[0] = mListenAt.mV[0];
- orientation[1] = mListenAt.mV[1];
- orientation[2] = mListenAt.mV[2];
- orientation[3] = mListenUp.mV[0];
- orientation[4] = mListenUp.mV[1];
- orientation[5] = mListenUp.mV[2];
+ ALfloat orientation[] = {
+ mListenAt.mV[0],
+ mListenAt.mV[1],
+ mListenAt.mV[2],
+ mListenUp.mV[0],
+ mListenUp.mV[1],
+ mListenUp.mV[2],
+ };
- ALfloat velocity[3];
- velocity[0] = mVelocity.mV[0];
- velocity[1] = mVelocity.mV[1];
- velocity[2] = mVelocity.mV[2];
+ ALfloat velocity[3] = {
+ mVelocity.mV[0],
+ mVelocity.mV[1],
+ mVelocity.mV[2],
+ };
alListenerfv(AL_ORIENTATION, orientation);
alListenerfv(AL_POSITION, mPosition.mV);
diff --git a/indra/llaudio/lllistener_openal.h b/indra/llaudio/lllistener_openal.h
index 96af86d99..cb163b11a 100644
--- a/indra/llaudio/lllistener_openal.h
+++ b/indra/llaudio/lllistener_openal.h
@@ -38,7 +38,6 @@ class LLListener_OpenAL : public LLListener
public:
LLListener_OpenAL();
virtual ~LLListener_OpenAL();
- virtual void init();
virtual void translate(LLVector3 offset);
virtual void setPosition(LLVector3 pos);
diff --git a/indra/llaudio/llvorbisencode.cpp b/indra/llaudio/llvorbisencode.cpp
index c0c9d6d6b..2e7fdb1db 100644
--- a/indra/llaudio/llvorbisencode.cpp
+++ b/indra/llaudio/llvorbisencode.cpp
@@ -32,7 +32,6 @@
#include "llerror.h"
#include "llrand.h"
#include "llmath.h"
-#include "llapr.h"
//#if LL_DARWIN
// MBW -- XXX -- Getting rid of SecondLifeVorbis for now -- no fmod means no name collisions.
@@ -81,18 +80,20 @@ S32 check_for_invalid_wav_formats(const std::string& in_fname, std::string& erro
error_msg.clear();
- // ********************************
- LLAPRFile infile ;
- infile.open(in_fname,LL_APR_RB);
- // ********************************
- if (!infile.getFileHandle())
+ //********************************
+ llifstream instream(in_fname, std::ios::in | std::ios::binary);
+ //********************************
+ if (!instream.is_open())
{
error_msg = "CannotUploadSoundFile";
return(LLVORBISENC_SOURCE_OPEN_ERR);
}
- infile.read(wav_header, 44);
- physical_file_size = infile.seek(APR_END,0);
+ instream.read((char*)wav_header, 44);
+
+ instream.seekg(0, instream.end);
+ physical_file_size = (U32) instream.tellg();
+ instream.seekg(0, instream.beg);
if (strncmp((char *)&(wav_header[0]),"RIFF",4))
{
@@ -112,8 +113,8 @@ S32 check_for_invalid_wav_formats(const std::string& in_fname, std::string& erro
while ((file_pos + 8)< physical_file_size)
{
- infile.seek(APR_SET,file_pos);
- infile.read(wav_header, 44);
+ instream.seekg(file_pos);
+ instream.read((char*)wav_header, 44);
chunk_length = ((U32) wav_header[7] << 24)
+ ((U32) wav_header[6] << 16)
@@ -122,7 +123,7 @@ S32 check_for_invalid_wav_formats(const std::string& in_fname, std::string& erro
if (chunk_length > physical_file_size - file_pos - 4)
{
- infile.close();
+ instream.close();
error_msg = "SoundFileInvalidChunkSize";
return(LLVORBISENC_CHUNK_SIZE_ERR);
}
@@ -153,9 +154,9 @@ S32 check_for_invalid_wav_formats(const std::string& in_fname, std::string& erro
file_pos += (chunk_length + 8);
chunk_length = 0;
}
- // ****************
- infile.close();
- // ****************
+ //****************
+ instream.close();
+ //****************
if (!uncompressed_pcm)
{
@@ -233,20 +234,18 @@ S32 encode_vorbis_file(const std::string& in_fname, const std::string& out_fname
S32 data_left = 0;
- LLAPRFile infile ;
- infile.open(in_fname,LL_APR_RB);
- if (!infile.getFileHandle())
+ llifstream instream(in_fname, std::ios::in | std::ios::binary);
+ if (!instream.is_open())
{
- LL_WARNS() << "Couldn't open temporary ogg file for writing: " << in_fname
+ LL_WARNS() << "Couldn't open temporary ogg file for reading: " << in_fname
<< LL_ENDL;
return(LLVORBISENC_SOURCE_OPEN_ERR);
}
- LLAPRFile outfile ;
- outfile.open(out_fname,LL_APR_WPB);
- if (!outfile.getFileHandle())
+ llofstream outstream(out_fname, std::ios::out | std::ios::binary | std::ios::trunc);
+ if (!outstream.is_open())
{
- LL_WARNS() << "Couldn't open upload sound file for reading: " << in_fname
+ LL_WARNS() << "Couldn't open upload sound file for writing: " << in_fname
<< LL_ENDL;
return(LLVORBISENC_DEST_OPEN_ERR);
}
@@ -255,10 +254,10 @@ S32 encode_vorbis_file(const std::string& in_fname, const std::string& out_fname
U32 chunk_length = 0;
U32 file_pos = 12; // start at the first chunk (usually fmt but not always)
- while (infile.eof() != APR_EOF)
+ while (!instream.eof())
{
- infile.seek(APR_SET,file_pos);
- infile.read(wav_header, 44);
+ instream.seekg(file_pos);
+ instream.read((char*)wav_header, 44);
chunk_length = ((U32) wav_header[7] << 24)
+ ((U32) wav_header[6] << 16)
@@ -278,7 +277,7 @@ S32 encode_vorbis_file(const std::string& in_fname, const std::string& out_fname
}
else if (!(strncmp((char *)&(wav_header[0]),"data",4)))
{
- infile.seek(APR_SET,file_pos+8);
+ instream.seekg(file_pos + 8);
// leave the file pointer at the beginning of the data chunk data
data_left = chunk_length;
break;
@@ -351,8 +350,8 @@ S32 encode_vorbis_file(const std::string& in_fname, const std::string& out_fname
while(!eos){
int result=ogg_stream_flush(&os,&og);
if(result==0)break;
- outfile.write(og.header, og.header_len);
- outfile.write(og.body, og.body_len);
+ outstream.write((char*)og.header, og.header_len);
+ outstream.write((char*)og.body, og.body_len);
}
}
@@ -362,7 +361,8 @@ S32 encode_vorbis_file(const std::string& in_fname, const std::string& out_fname
{
long bytes_per_sample = bits_per_sample/8;
- long bytes=(long)infile.read(readbuffer,llclamp((S32)(READ_BUFFER*num_channels*bytes_per_sample),0,data_left)); /* stereo hardwired here */
+ instream.read((char*)readbuffer, llclamp((S32) (READ_BUFFER*num_channels*bytes_per_sample), 0, data_left)); /* stereo hardwired here */
+ long bytes = (long) instream.gcount();
if (bytes==0)
{
@@ -470,8 +470,8 @@ S32 encode_vorbis_file(const std::string& in_fname, const std::string& out_fname
if(result==0)
break;
- outfile.write(og.header, og.header_len);
- outfile.write(og.body, og.body_len);
+ outstream.write((char*)og.header, og.header_len);
+ outstream.write((char*)og.body, og.body_len);
/* this could be set above, but for illustrative purposes, I do
it here (to show that vorbis does know where the stream ends) */
diff --git a/indra/llcharacter/CMakeLists.txt b/indra/llcharacter/CMakeLists.txt
index 1c4ab0b2d..a698a9847 100644
--- a/indra/llcharacter/CMakeLists.txt
+++ b/indra/llcharacter/CMakeLists.txt
@@ -16,6 +16,10 @@ include_directories(
${LLVFS_INCLUDE_DIRS}
${LLXML_INCLUDE_DIRS}
)
+include_directories(SYSTEM
+ ${LLCOMMON_SYSTEM_INCLUDE_DIRS}
+ ${LLXML_SYSTEM_INCLUDE_DIRS}
+ )
set(llcharacter_SOURCE_FILES
llanimationstates.cpp
diff --git a/indra/llcharacter/llbvhloader.cpp b/indra/llcharacter/llbvhloader.cpp
index 5bffb1270..1c811a924 100644
--- a/indra/llcharacter/llbvhloader.cpp
+++ b/indra/llcharacter/llbvhloader.cpp
@@ -35,10 +35,6 @@
#include "llkeyframemotion.h"
#include "llquantize.h"
#include "llstl.h"
-#include "llapr.h"
-
-
-//using namespace std;
#define INCHES_TO_METERS 0.02540005f
@@ -219,9 +215,8 @@ ELoadStatus LLBVHLoader::loadTranslationTable(const char *fileName)
//--------------------------------------------------------------------
std::string path = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,fileName);
- LLAPRFile infile(path, LL_APR_R);
- apr_file_t *fp = infile.getFileHandle();
- if (!fp)
+ llifstream infstream(path);
+ if (!infstream.is_open())
return E_ST_NO_XLT_FILE;
LL_INFOS() << "NOTE: Loading translation table: " << fileName << LL_ENDL;
@@ -233,7 +228,7 @@ ELoadStatus LLBVHLoader::loadTranslationTable(const char *fileName)
//--------------------------------------------------------------------
// load header
//--------------------------------------------------------------------
- if ( ! getLine(fp) )
+ if ( ! getLine(infstream) )
return E_ST_EOF;
if ( strncmp(mLine, "Translations 1.0", 16) )
return E_ST_NO_XLT_HEADER;
@@ -243,7 +238,7 @@ ELoadStatus LLBVHLoader::loadTranslationTable(const char *fileName)
//--------------------------------------------------------------------
BOOL loadingGlobals = FALSE;
Translation *trans = NULL;
- while ( getLine(fp) )
+ while ( getLine(infstream) )
{
//----------------------------------------------------------------
// check the 1st token on the line to determine if it's empty or a comment
@@ -660,7 +655,7 @@ ELoadStatus LLBVHLoader::loadTranslationTable(const char *fileName)
}
- infile.close() ;
+ infstream.close() ;
return E_ST_OK;
}
@@ -1337,13 +1332,9 @@ void LLBVHLoader::reset()
//------------------------------------------------------------------------
// LLBVHLoader::getLine()
//------------------------------------------------------------------------
-BOOL LLBVHLoader::getLine(apr_file_t* fp)
+BOOL LLBVHLoader::getLine(llifstream& stream)
{
- if (apr_file_eof(fp) == APR_EOF)
- {
- return FALSE;
- }
- if ( apr_file_gets(mLine, BVH_PARSER_LINE_SIZE, fp) == APR_SUCCESS)
+ if (stream.getline(mLine, BVH_PARSER_LINE_SIZE))
{
mLineNumber++;
return TRUE;
diff --git a/indra/llcharacter/llbvhloader.h b/indra/llcharacter/llbvhloader.h
index 38617bd6d..d1c48e446 100644
--- a/indra/llcharacter/llbvhloader.h
+++ b/indra/llcharacter/llbvhloader.h
@@ -2,31 +2,25 @@
* @file llbvhloader.h
* @brief Translates a BVH files to LindenLabAnimation format.
*
- * $LicenseInfo:firstyear=2004&license=viewergpl$
- *
- * Copyright (c) 2004-2009, Linden Research, Inc.
- *
+ * $LicenseInfo:firstyear=2004&license=viewerlgpl$
* Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * Copyright (C) 2010, Linden Research, Inc.
*
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
*
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@@ -36,32 +30,11 @@
#include "v3math.h"
#include "m3math.h"
#include "llmath.h"
-#include "llapr.h"
#include "llbvhconsts.h"
const S32 BVH_PARSER_LINE_SIZE = 2048;
class LLDataPacker;
-//------------------------------------------------------------------------
-// FileCloser
-//------------------------------------------------------------------------
-class FileCloser
-{
-public:
- FileCloser( apr_file_t *file )
- {
- mFile = file;
- }
-
- ~FileCloser()
- {
- apr_file_close(mFile);
- }
-protected:
- apr_file_t* mFile;
-};
-
-
//------------------------------------------------------------------------
// Key
//------------------------------------------------------------------------
@@ -304,7 +277,7 @@ public:
protected:
// Consumes one line of input from file.
- BOOL getLine(apr_file_t *fp);
+ BOOL getLine(llifstream& stream);
// parser state
char mLine[BVH_PARSER_LINE_SIZE]; /* Flawfinder: ignore */
diff --git a/indra/llcharacter/lleditingmotion.cpp b/indra/llcharacter/lleditingmotion.cpp
index 8813064dd..41a0ed86d 100644
--- a/indra/llcharacter/lleditingmotion.cpp
+++ b/indra/llcharacter/lleditingmotion.cpp
@@ -225,6 +225,7 @@ BOOL LLEditingMotion::onUpdate(F32 time, U8* joint_mask)
LL_CONT << "NULL";
}
LL_CONT << LL_ENDL;
+ target.setVec(1.f, 1.f, 1.f);
}
mTarget.setPosition( target + mParentJoint.getPosition());
diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp
index 0175a2fe4..d4c73143b 100644
--- a/indra/llcharacter/lljoint.cpp
+++ b/indra/llcharacter/lljoint.cpp
@@ -36,6 +36,63 @@
S32 LLJoint::sNumUpdates = 0;
S32 LLJoint::sNumTouches = 0;
+template
+bool attachment_map_iter_compare_key(const T& a, const T& b)
+{
+ return a.first < b.first;
+}
+
+bool LLPosOverrideMap::findActiveOverride(LLUUID& mesh_id, LLVector3& pos) const
+{
+ pos = LLVector3(0,0,0);
+ mesh_id = LLUUID();
+ bool found = false;
+
+ map_type::const_iterator it = std::max_element(m_map.begin(),
+ m_map.end(),
+ attachment_map_iter_compare_key);
+ if (it != m_map.end())
+ {
+ found = true;
+ pos = it->second;
+ mesh_id = it->first;
+ }
+ return found;
+}
+
+void LLPosOverrideMap::showJointPosOverrides( std::ostringstream& os ) const
+{
+ map_type::const_iterator max_it = std::max_element(m_map.begin(),
+ m_map.end(),
+ attachment_map_iter_compare_key);
+ for (map_type::const_iterator it = m_map.begin();
+ it != m_map.end(); ++it)
+ {
+ const LLVector3& pos = it->second;
+ os << " " << "[" << it->first <<": " << pos << "]" << ((it==max_it) ? "*" : "");
+ }
+}
+
+U32 LLPosOverrideMap::count() const
+{
+ return m_map.size();
+}
+
+void LLPosOverrideMap::add(const LLUUID& mesh_id, const LLVector3& pos)
+{
+ m_map[mesh_id] = pos;
+}
+
+bool LLPosOverrideMap::remove(const LLUUID& mesh_id)
+{
+ U32 remove_count = m_map.erase(mesh_id);
+ return (remove_count > 0);
+}
+
+void LLPosOverrideMap::clear()
+{
+ m_map.clear();
+}
//-----------------------------------------------------------------------------
// LLJoint()
// Class Constructor
@@ -57,7 +114,6 @@ LLJoint::LLJoint() :
{
init();
touch();
- mResetAfterRestoreOldXform = false;
}
LLJoint::LLJoint(S32 joint_num) :
@@ -65,7 +121,6 @@ LLJoint::LLJoint(S32 joint_num) :
{
init();
touch();
- mResetAfterRestoreOldXform = false;
}
@@ -233,54 +288,120 @@ const LLVector3& LLJoint::getPosition()
return mXform.getPosition();
}
+bool do_debug_joint(const std::string& name)
+{
+ return false;
+}
//--------------------------------------------------------------------
// setPosition()
//--------------------------------------------------------------------
void LLJoint::setPosition( const LLVector3& pos )
{
-// if (mXform.getPosition() != pos)
+ if (pos != getPosition())
{
- mXform.setPosition(pos);
- touch(MATRIX_DIRTY | POSITION_DIRTY);
+ if (do_debug_joint(getName()))
+ {
+ LL_DEBUGS("Avatar") << " joint " << getName() << " set pos " << pos << LL_ENDL;
+ }
+ }
+ mXform.setPosition(pos);
+ touch(MATRIX_DIRTY | POSITION_DIRTY);
+}
+
+void showJointPosOverrides( const LLJoint& joint, const std::string& note, const std::string& av_info )
+{
+ std::ostringstream os;
+ os << joint.m_posBeforeOverrides;
+ joint.m_attachmentOverrides.showJointPosOverrides(os);
+ LL_DEBUGS("Avatar") << av_info << " joint " << joint.getName() << " " << note << " " << os.str() << LL_ENDL;
+}
+
+//--------------------------------------------------------------------
+// addAttachmentPosOverride()
+//--------------------------------------------------------------------
+void LLJoint::addAttachmentPosOverride( const LLVector3& pos, const LLUUID& mesh_id, const std::string& av_info )
+{
+ if (mesh_id.isNull())
+ {
+ return;
+ }
+ if (!m_attachmentOverrides.count())
+ {
+ if (do_debug_joint(getName()))
+ {
+ LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " saving m_posBeforeOverrides " << getPosition() << LL_ENDL;
+ }
+ m_posBeforeOverrides = getPosition();
+ }
+ m_attachmentOverrides.add(mesh_id,pos);
+ if (do_debug_joint(getName()))
+ {
+ LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " addAttachmentPosOverride for mesh " << mesh_id << " pos " << pos << LL_ENDL;
+ }
+ updatePos(av_info);
+}
+
+//--------------------------------------------------------------------
+// removeAttachmentPosOverride()
+//--------------------------------------------------------------------
+void LLJoint::removeAttachmentPosOverride( const LLUUID& mesh_id, const std::string& av_info )
+{
+ if (mesh_id.isNull())
+ {
+ return;
+ }
+ if (m_attachmentOverrides.remove(mesh_id))
+ {
+ if (do_debug_joint(getName()))
+ {
+ LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName()
+ << " removeAttachmentPosOverride for " << mesh_id << LL_ENDL;
+ showJointPosOverrides(*this, "remove", av_info);
+ }
+ updatePos(av_info);
}
}
-
//--------------------------------------------------------------------
-// setPosition()
-//--------------------------------------------------------------------
-void LLJoint::setDefaultFromCurrentXform( void )
+ // hasAttachmentPosOverride()
+ //--------------------------------------------------------------------
+bool LLJoint::hasAttachmentPosOverride( LLVector3& pos, LLUUID& mesh_id ) const
{
- mDefaultXform = mXform;
- touch(MATRIX_DIRTY | POSITION_DIRTY);
-
+ return m_attachmentOverrides.findActiveOverride(mesh_id,pos);
}
//--------------------------------------------------------------------
-// storeCurrentXform()
+// clearAttachmentPosOverrides()
//--------------------------------------------------------------------
-void LLJoint::storeCurrentXform( const LLVector3& pos )
+void LLJoint::clearAttachmentPosOverrides()
{
- mOldXform = mXform;
- mResetAfterRestoreOldXform = true;
- setPosition( pos );
+ if (m_attachmentOverrides.count())
+ {
+ m_attachmentOverrides.clear();
+ setPosition(m_posBeforeOverrides);
+ setId( LLUUID::null );
+ }
}
+
//--------------------------------------------------------------------
-// restoreOldXform()
+// updatePos()
//--------------------------------------------------------------------
-void LLJoint::restoreOldXform( void )
+void LLJoint::updatePos(const std::string& av_info)
{
- mResetAfterRestoreOldXform = false;
- mXform = mOldXform;
-}
-//--------------------------------------------------------------------
-// restoreOldXform()
-//--------------------------------------------------------------------
-void LLJoint::restoreToDefaultXform( void )
-{
- mXform = mDefaultXform;
- setPosition( mXform.getPosition() );
+ LLVector3 pos, found_pos;
+ LLUUID mesh_id;
+ if (m_attachmentOverrides.findActiveOverride(mesh_id,found_pos))
+ {
+ LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " updatePos, winner of " << m_attachmentOverrides.count() << " is mesh " << mesh_id << " pos " << found_pos << LL_ENDL;
+ pos = found_pos;
+ }
+ else
+ {
+ LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " updatePos, winner is posBeforeOverrides " << m_posBeforeOverrides << LL_ENDL;
+ pos = m_posBeforeOverrides;
+ }
+ setPosition(pos);
}
//--------------------------------------------------------------------
diff --git a/indra/llcharacter/lljoint.h b/indra/llcharacter/lljoint.h
index 2196f47bb..5ac63e633 100644
--- a/indra/llcharacter/lljoint.h
+++ b/indra/llcharacter/lljoint.h
@@ -46,6 +46,20 @@ const U32 LL_FACE_JOINT_NUM = 30;
const S32 LL_CHARACTER_MAX_PRIORITY = 7;
const F32 LL_MAX_PELVIS_OFFSET = 5.f;
+class LLPosOverrideMap
+{
+public:
+ LLPosOverrideMap() {}
+ bool findActiveOverride(LLUUID& mesh_id, LLVector3& pos) const;
+ void showJointPosOverrides(std::ostringstream& os) const;
+ U32 count() const;
+ void add(const LLUUID& mesh_id, const LLVector3& pos);
+ bool remove(const LLUUID& mesh_id);
+ void clear();
+private:
+ typedef std::map map_type;
+ map_type m_map;
+};
//-----------------------------------------------------------------------------
// class LLJoint
//-----------------------------------------------------------------------------
@@ -79,8 +93,6 @@ protected:
// explicit transformation members
LLXformMatrix mXform;
- LLXformMatrix mOldXform;
- LLXformMatrix mDefaultXform;
LLUUID mId;
@@ -88,8 +100,6 @@ public:
U32 mDirtyFlags;
BOOL mUpdateXform;
- BOOL mResetAfterRestoreOldXform;
-
// describes the skin binding pose
LLVector3 mSkinOffset;
@@ -103,6 +113,11 @@ public:
static S32 sNumTouches;
static S32 sNumUpdates;
+ LLPosOverrideMap m_attachmentOverrides;
+ LLVector3 m_posBeforeOverrides;
+
+ void updatePos(const std::string& av_info);
+
public:
LLJoint();
LLJoint(S32 joint_num);
@@ -183,22 +198,17 @@ public:
virtual BOOL isAnimatable() const { return TRUE; }
S32 getJointNum() const { return mJointNum; }
-
- void restoreOldXform( void );
- void restoreToDefaultXform( void );
- void setDefaultFromCurrentXform( void );
- void storeCurrentXform( const LLVector3& pos );
+
+ void addAttachmentPosOverride( const LLVector3& pos, const LLUUID& mesh_id, const std::string& av_info );
+ void removeAttachmentPosOverride( const LLUUID& mesh_id, const std::string& av_info );
+ bool hasAttachmentPosOverride( LLVector3& pos, LLUUID& mesh_id ) const;
+ void clearAttachmentPosOverrides();
//Accessor for the joint id
LLUUID getId( void ) { return mId; }
//Setter for the joints id
void setId( const LLUUID& id ) { mId = id;}
- //If the old transform flag has been set, then the reset logic in avatar needs to be aware(test) of it
- const BOOL doesJointNeedToBeReset( void ) const { return mResetAfterRestoreOldXform; }
- //Setter for joint reset flag
- void setJointToBeReset( BOOL val ) { mResetAfterRestoreOldXform = val; }
-
//
std::string exportString(U32 tabs = 0);
//
diff --git a/indra/llcharacter/lljointstate.h b/indra/llcharacter/lljointstate.h
index e40cf2673..15e7af5ab 100644
--- a/indra/llcharacter/lljointstate.h
+++ b/indra/llcharacter/lljointstate.h
@@ -70,22 +70,18 @@ protected:
public:
// Constructor
LLJointState()
- {
- mUsage = 0;
- mJoint = NULL;
- mUsage = 0;
- mWeight = 0.f;
- mPriority = LLJoint::USE_MOTION_PRIORITY;
- }
+ : mUsage(0)
+ , mJoint(NULL)
+ , mWeight(0.f)
+ , mPriority(LLJoint::USE_MOTION_PRIORITY)
+ {}
LLJointState(LLJoint* joint)
- {
- mUsage = 0;
- mJoint = joint;
- mUsage = 0;
- mWeight = 0.f;
- mPriority = LLJoint::USE_MOTION_PRIORITY;
- }
+ : mUsage(0)
+ , mJoint(joint)
+ , mWeight(0.f)
+ , mPriority(LLJoint::USE_MOTION_PRIORITY)
+ {}
// joint that this state is applied to
LLJoint* getJoint() { return mJoint; }
diff --git a/indra/llcharacter/llkeyframemotion.cpp b/indra/llcharacter/llkeyframemotion.cpp
index 35b9ab8a1..ac99e0698 100644
--- a/indra/llcharacter/llkeyframemotion.cpp
+++ b/indra/llcharacter/llkeyframemotion.cpp
@@ -42,6 +42,7 @@
#include "llvfile.h"
#include "m3math.h"
#include "message.h"
+#include
//-----------------------------------------------------------------------------
// Static Definitions
@@ -700,7 +701,8 @@ BOOL LLKeyframeMotion::onActivate()
//-----------------------------------------------------------------------------
BOOL LLKeyframeMotion::onUpdate(F32 time, U8* joint_mask)
{
- llassert(time >= 0.f);
+ // llassert(time >= 0.f); // This will fire
+ time = llmax(0.f, time);
if (mJointMotionList->mLoop)
{
@@ -965,7 +967,7 @@ void LLKeyframeMotion::deactivateConstraint(JointConstraint *constraintp)
constraintp->mSourceVolume->mUpdateXform = FALSE;
}
- if (!constraintp->mSharedData->mConstraintTargetType == CONSTRAINT_TARGET_TYPE_GROUND)
+ if (constraintp->mSharedData->mConstraintTargetType != CONSTRAINT_TARGET_TYPE_GROUND)
{
if (constraintp->mTargetVolume)
{
@@ -1284,16 +1286,6 @@ void LLKeyframeMotion::applyConstraint(JointConstraint* constraint, F32 time, U8
}
}
-// Helper class.
-template
-struct AIAutoDestruct
-{
- T* mPtr;
- AIAutoDestruct() : mPtr(NULL) { }
- ~AIAutoDestruct() { delete mPtr; }
- void add(T* ptr) { mPtr = ptr; }
-};
-
//-----------------------------------------------------------------------------
// deserialize()
//-----------------------------------------------------------------------------
@@ -1495,18 +1487,12 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
for(U32 i=0; i watcher;
-
- JointMotion* joint_motion = new JointMotion;
+ JointMotion* joint_motion = new JointMotion;
+ std::unique_ptr watcher(joint_motion);
if (singu_new_joint_motion_list)
{
// Pass ownership to mJointMotionList.
- mJointMotionList->mJointMotionArray.push_back(joint_motion);
- }
- else
- {
- // Just delete this at the end.
- watcher.add(joint_motion);
+ mJointMotionList->mJointMotionArray.push_back(watcher.release());
}
std::string joint_name;
@@ -1785,6 +1771,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
{
// read in constraint data
JointConstraintSharedData* constraintp = new JointConstraintSharedData;
+ std::unique_ptr watcher(constraintp);
U8 byte = 0;
if (!dp.unpackU8(byte, "chain_length"))
@@ -1842,21 +1829,18 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
if (!dp.unpackVector3(constraintp->mSourceConstraintOffset, "source_offset"))
{
LL_WARNS() << "can't read constraint source offset" << LL_ENDL;
- delete constraintp;
return FALSE;
}
if( !(constraintp->mSourceConstraintOffset.isFinite()) )
{
LL_WARNS() << "non-finite constraint source offset" << LL_ENDL;
- delete constraintp;
return FALSE;
}
if (!dp.unpackBinaryDataFixed(bin_data, BIN_DATA_LENGTH, "target_volume"))
{
LL_WARNS() << "can't read target volume name" << LL_ENDL;
- delete constraintp;
return FALSE;
}
@@ -1876,28 +1860,24 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
if (!dp.unpackVector3(constraintp->mTargetConstraintOffset, "target_offset"))
{
LL_WARNS() << "can't read constraint target offset" << LL_ENDL;
- delete constraintp;
return FALSE;
}
if( !(constraintp->mTargetConstraintOffset.isFinite()) )
{
LL_WARNS() << "non-finite constraint target offset" << LL_ENDL;
- delete constraintp;
return FALSE;
}
if (!dp.unpackVector3(constraintp->mTargetConstraintDir, "target_dir"))
{
LL_WARNS() << "can't read constraint target direction" << LL_ENDL;
- delete constraintp;
return FALSE;
}
if( !(constraintp->mTargetConstraintDir.isFinite()) )
{
LL_WARNS() << "non-finite constraint target direction" << LL_ENDL;
- delete constraintp;
return FALSE;
}
@@ -1910,39 +1890,30 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
if (!dp.unpackF32(constraintp->mEaseInStartTime, "ease_in_start") || !std::isfinite(constraintp->mEaseInStartTime))
{
LL_WARNS() << "can't read constraint ease in start time" << LL_ENDL;
- delete constraintp;
return FALSE;
}
if (!dp.unpackF32(constraintp->mEaseInStopTime, "ease_in_stop") || !std::isfinite(constraintp->mEaseInStopTime))
{
LL_WARNS() << "can't read constraint ease in stop time" << LL_ENDL;
- delete constraintp;
return FALSE;
}
if (!dp.unpackF32(constraintp->mEaseOutStartTime, "ease_out_start") || !std::isfinite(constraintp->mEaseOutStartTime))
{
LL_WARNS() << "can't read constraint ease out start time" << LL_ENDL;
- delete constraintp;
return FALSE;
}
if (!dp.unpackF32(constraintp->mEaseOutStopTime, "ease_out_stop") || !std::isfinite(constraintp->mEaseOutStopTime))
{
LL_WARNS() << "can't read constraint ease out stop time" << LL_ENDL;
- delete constraintp;
return FALSE;
}
- AIAutoDestruct watcher;
if (singu_new_joint_motion_list)
{
- mJointMotionList->mConstraints.push_front(constraintp);
- }
- else
- {
- watcher.add(constraintp);
+ mJointMotionList->mConstraints.push_front(watcher.release());
}
constraintp->mJointStateIndices = new S32[constraintp->mChainLength + 1]; // note: mChainLength is size-limited - comes from a byte
diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt
index 00c4b4109..497d09255 100644
--- a/indra/llcommon/CMakeLists.txt
+++ b/indra/llcommon/CMakeLists.txt
@@ -36,6 +36,7 @@ set(llcommon_SOURCE_FILES
llassettype.cpp
llbase32.cpp
llbase64.cpp
+ llcallbacklist.cpp
llcommon.cpp
llcommonutils.cpp
llcoros.cpp
@@ -138,6 +139,7 @@ set(llcommon_HEADER_FILES
llbase32.h
llbase64.h
llboost.h
+ llcallbacklist.h
llchat.h
llclickaction.h
llcommon.h
@@ -230,9 +232,13 @@ set(llcommon_HEADER_FILES
llthreadsafequeue.h
lltimer.h
lltreeiterators.h
+ llunits.h
+ llunittype.h
lltypeinfolookup.h
lluri.h
lluuid.h
+ llwin32headers.h
+ llwin32headerslean.h
llworkerthread.h
metaclass.h
metaclasst.h
@@ -284,6 +290,7 @@ target_link_libraries(
${Boost_REGEX_LIBRARY}
${Boost_THREAD_LIBRARY}
${Boost_SYSTEM_LIBRARY}
+ ${Boost_CHRONO_LIBRARY}
${CORESERVICES_LIBRARY}
)
diff --git a/indra/llcommon/llalignedarray.h b/indra/llcommon/llalignedarray.h
index 14e25e78d..d6ab5ed3d 100644
--- a/indra/llcommon/llalignedarray.h
+++ b/indra/llcommon/llalignedarray.h
@@ -64,7 +64,7 @@ LLAlignedArray::LLAlignedArray()
template
LLAlignedArray::~LLAlignedArray()
{
- ll_aligned_free(mArray);
+ ll_aligned_free(mArray);
mArray = NULL;
mElementCount = 0;
mCapacity = 0;
@@ -78,7 +78,7 @@ void LLAlignedArray::push_back(const T& elem)
{
mCapacity++;
mCapacity *= 2;
- T* new_buf = (T*) ll_aligned_malloc(mCapacity*sizeof(T), alignment);
+ T* new_buf = (T*) ll_aligned_malloc(mCapacity*sizeof(T));
if (mArray)
{
ll_memcpy_nonaliased_aligned_16((char*)new_buf, (char*)mArray, sizeof(T)*mElementCount);
@@ -90,7 +90,7 @@ void LLAlignedArray::push_back(const T& elem)
mArray[mElementCount++] = elem;
//delete old array here to prevent error on a.push_back(a[0])
- ll_aligned_free(old_buf);
+ ll_aligned_free(old_buf);
}
template
@@ -99,11 +99,11 @@ void LLAlignedArray::resize(U32 size)
if (mCapacity < size)
{
mCapacity = size+mCapacity*2;
- T* new_buf = mCapacity > 0 ? (T*) ll_aligned_malloc(mCapacity*sizeof(T), alignment) : NULL;
+ T* new_buf = mCapacity > 0 ? (T*) ll_aligned_malloc(mCapacity*sizeof(T)) : NULL;
if (mArray)
{
ll_memcpy_nonaliased_aligned_16((char*) new_buf, (char*) mArray, sizeof(T)*mElementCount);
- ll_aligned_free(mArray);
+ ll_aligned_free(mArray);
}
/*for (U32 i = mElementCount; i < mCapacity; ++i)
diff --git a/indra/llcommon/llbase64.cpp b/indra/llcommon/llbase64.cpp
index 4e75e4591..6705a6542 100644
--- a/indra/llcommon/llbase64.cpp
+++ b/indra/llcommon/llbase64.cpp
@@ -30,32 +30,36 @@
#include "llbase64.h"
#include
+
#include "apr_base64.h"
+
// static
std::string LLBase64::encode(const U8* input, size_t input_size)
{
- if (!(input && input_size > 0)) return LLStringUtil::null;
-
- // Yes, it returns int.
- int b64_buffer_length = apr_base64_encode_len(input_size);
- char* b64_buffer = new char[b64_buffer_length];
-
- // This is faster than apr_base64_encode() if you know
- // you're not on an EBCDIC machine. Also, the output is
- // null terminated, even though the documentation doesn't
- // specify. See apr_base64.c for details. JC
- b64_buffer_length = apr_base64_encode_binary(
- b64_buffer,
- input,
- input_size);
- std::string result;
- result.assign(b64_buffer);
- delete[] b64_buffer;
-
- return result;
+ std::string output;
+ if (input
+ && input_size > 0)
+ {
+ // Yes, it returns int.
+ int b64_buffer_length = apr_base64_encode_len(input_size);
+ char* b64_buffer = new char[b64_buffer_length];
+
+ // This is faster than apr_base64_encode() if you know
+ // you're not on an EBCDIC machine. Also, the output is
+ // null terminated, even though the documentation doesn't
+ // specify. See apr_base64.c for details. JC
+ b64_buffer_length = apr_base64_encode_binary(
+ b64_buffer,
+ input,
+ input_size);
+ output.assign(b64_buffer);
+ delete[] b64_buffer;
+ }
+ return output;
}
+
// static
std::string LLBase64::encode(const std::string& in_str)
{
diff --git a/indra/llcommon/llcallbacklist.cpp b/indra/llcommon/llcallbacklist.cpp
new file mode 100644
index 000000000..541ff75ee
--- /dev/null
+++ b/indra/llcommon/llcallbacklist.cpp
@@ -0,0 +1,230 @@
+/**
+ * @file llcallbacklist.cpp
+ * @brief A simple list of callback functions to call.
+ *
+ * $LicenseInfo:firstyear=2001&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2010, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
+ * $/LicenseInfo$
+ */
+
+#include "llcallbacklist.h"
+#include "lleventtimer.h"
+#include "llerrorlegacy.h"
+
+// Globals
+//
+LLCallbackList gIdleCallbacks;
+
+//
+// Member functions
+//
+
+LLCallbackList::LLCallbackList()
+{
+ // nothing
+}
+
+LLCallbackList::~LLCallbackList()
+{
+}
+
+
+void LLCallbackList::addFunction( callback_t func, void *data)
+{
+ if (!func)
+ {
+ return;
+ }
+
+ // only add one callback per func/data pair
+ //
+ if (containsFunction(func))
+ {
+ return;
+ }
+
+ callback_pair_t t(func, data);
+ mCallbackList.push_back(t);
+}
+
+bool LLCallbackList::containsFunction( callback_t func, void *data)
+{
+ callback_pair_t t(func, data);
+ callback_list_t::iterator iter = find(func,data);
+ if (iter != mCallbackList.end())
+ {
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
+
+bool LLCallbackList::deleteFunction( callback_t func, void *data)
+{
+ callback_list_t::iterator iter = find(func,data);
+ if (iter != mCallbackList.end())
+ {
+ mCallbackList.erase(iter);
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
+inline
+LLCallbackList::callback_list_t::iterator
+LLCallbackList::find(callback_t func, void *data)
+{
+ callback_pair_t t(func, data);
+ return std::find(mCallbackList.begin(), mCallbackList.end(), t);
+}
+
+void LLCallbackList::deleteAllFunctions()
+{
+ mCallbackList.clear();
+}
+
+
+void LLCallbackList::callFunctions()
+{
+ for (callback_list_t::iterator iter = mCallbackList.begin(); iter != mCallbackList.end(); )
+ {
+ callback_list_t::iterator curiter = iter++;
+ curiter->first(curiter->second);
+ }
+}
+
+// Shim class to allow arbitrary boost::bind
+// expressions to be run as one-time idle callbacks.
+class OnIdleCallbackOneTime
+{
+public:
+ OnIdleCallbackOneTime(nullary_func_t callable):
+ mCallable(callable)
+ {
+ }
+ static void onIdle(void *data)
+ {
+ gIdleCallbacks.deleteFunction(onIdle, data);
+ OnIdleCallbackOneTime* self = reinterpret_cast(data);
+ self->call();
+ delete self;
+ }
+ void call()
+ {
+ mCallable();
+ }
+private:
+ nullary_func_t mCallable;
+};
+
+void doOnIdleOneTime(nullary_func_t callable)
+{
+ OnIdleCallbackOneTime* cb_functor = new OnIdleCallbackOneTime(callable);
+ gIdleCallbacks.addFunction(&OnIdleCallbackOneTime::onIdle,cb_functor);
+}
+
+// Shim class to allow generic boost functions to be run as
+// recurring idle callbacks. Callable should return true when done,
+// false to continue getting called.
+class OnIdleCallbackRepeating
+{
+public:
+ OnIdleCallbackRepeating(bool_func_t callable):
+ mCallable(callable)
+ {
+ }
+ // Will keep getting called until the callable returns true.
+ static void onIdle(void *data)
+ {
+ OnIdleCallbackRepeating* self = reinterpret_cast(data);
+ bool done = self->call();
+ if (done)
+ {
+ gIdleCallbacks.deleteFunction(onIdle, data);
+ delete self;
+ }
+ }
+ bool call()
+ {
+ return mCallable();
+ }
+private:
+ bool_func_t mCallable;
+};
+
+void doOnIdleRepeating(bool_func_t callable)
+{
+ OnIdleCallbackRepeating* cb_functor = new OnIdleCallbackRepeating(callable);
+ gIdleCallbacks.addFunction(&OnIdleCallbackRepeating::onIdle,cb_functor);
+}
+
+class NullaryFuncEventTimer: public LLEventTimer
+{
+public:
+ NullaryFuncEventTimer(nullary_func_t callable, F32 seconds):
+ LLEventTimer(seconds),
+ mCallable(callable)
+ {
+ }
+
+private:
+ BOOL tick()
+ {
+ mCallable();
+ return TRUE;
+ }
+
+ nullary_func_t mCallable;
+};
+
+// Call a given callable once after specified interval.
+void doAfterInterval(nullary_func_t callable, F32 seconds)
+{
+ new NullaryFuncEventTimer(callable, seconds);
+}
+
+class BoolFuncEventTimer: public LLEventTimer
+{
+public:
+ BoolFuncEventTimer(bool_func_t callable, F32 seconds):
+ LLEventTimer(seconds),
+ mCallable(callable)
+ {
+ }
+private:
+ BOOL tick()
+ {
+ return mCallable();
+ }
+
+ bool_func_t mCallable;
+};
+
+// Call a given callable every specified number of seconds, until it returns true.
+void doPeriodically(bool_func_t callable, F32 seconds)
+{
+ new BoolFuncEventTimer(callable, seconds);
+}
diff --git a/indra/newview/llcallbacklist.h b/indra/llcommon/llcallbacklist.h
similarity index 76%
rename from indra/newview/llcallbacklist.h
rename to indra/llcommon/llcallbacklist.h
index 0516c9cdb..1fdb8ca09 100644
--- a/indra/newview/llcallbacklist.h
+++ b/indra/llcommon/llcallbacklist.h
@@ -28,27 +28,35 @@
#define LL_LLCALLBACKLIST_H
#include "llstl.h"
+#include
+#include
+#include "stdtypes.h"
class LLCallbackList
{
public:
typedef void (*callback_t)(void*);
+
+ typedef std::pair< callback_t,void* > callback_pair_t;
+ // NOTE: It is confirmed that we DEPEND on the order provided by using a list :(
+ //
+ typedef std::list< callback_pair_t > callback_list_t;
LLCallbackList();
~LLCallbackList();
- void addFunction( callback_t func, void *data = NULL ); // register a callback, which will be called as func(data)
- BOOL containsFunction( callback_t func, void *data = NULL ); // true if list already contains the function/data pair
- BOOL deleteFunction( callback_t func, void *data = NULL ); // removes the first instance of this function/data pair from the list, false if not found
- void callFunctions(); // calls all functions
+ void addFunction( callback_t func, void *data = NULL ); // register a callback, which will be called as func(data)
+ bool containsFunction( callback_t func, void *data = NULL ); // true if list already contains the function/data pair
+ bool deleteFunction( callback_t func, void *data = NULL ); // removes the first instance of this function/data pair from the list, false if not found
+ void callFunctions(); // calls all functions
void deleteAllFunctions();
static void test();
protected:
- // Use a list so that the callbacks are ordered in case that matters
- typedef std::pair callback_pair_t;
- typedef std::list callback_list_t;
+
+ inline callback_list_t::iterator find(callback_t func, void *data);
+
callback_list_t mCallbackList;
};
diff --git a/indra/llcommon/lldate.cpp b/indra/llcommon/lldate.cpp
index 065a72215..e5af5ced2 100644
--- a/indra/llcommon/lldate.cpp
+++ b/indra/llcommon/lldate.cpp
@@ -55,8 +55,8 @@ LLDate::LLDate(const LLDate& date) :
mSecondsSinceEpoch(date.mSecondsSinceEpoch)
{}
-LLDate::LLDate(F64 seconds_since_epoch) :
- mSecondsSinceEpoch(seconds_since_epoch)
+LLDate::LLDate(F64SecondsImplicit seconds_since_epoch) :
+ mSecondsSinceEpoch(seconds_since_epoch.value())
{}
LLDate::LLDate(const std::string& iso8601_date)
@@ -83,7 +83,7 @@ std::string LLDate::asString() const
// is one of the standards used and the prefered format
std::string LLDate::asRFC1123() const
{
- return toHTTPDateString(LLStringExplicit("%A, %d %b %Y %H:%M:%S GMT"));
+ return toHTTPDateString (std::string ("%A, %d %b %Y %H:%M:%S GMT"));
}
LLFastTimer::DeclareTimer FT_DATE_FORMAT("Date Format");
diff --git a/indra/llcommon/lldate.h b/indra/llcommon/lldate.h
index 7e8ae6368..863c3d02a 100644
--- a/indra/llcommon/lldate.h
+++ b/indra/llcommon/lldate.h
@@ -38,9 +38,8 @@
#include
#include
-#include "llpreprocessor.h"
-
#include "stdtypes.h"
+#include "llunits.h"
/**
* @class LLDate
@@ -64,9 +63,9 @@ public:
/**
* @brief Construct a date from a seconds since epoch value.
*
- * @pararm seconds_since_epoch The number of seconds since UTC epoch.
+ * @param seconds_since_epoch The number of seconds since UTC epoch.
*/
- LLDate(F64 seconds_since_epoch);
+ LLDate(F64SecondsImplicit seconds_since_epoch);
/**
* @brief Construct a date from a string representation
@@ -163,4 +162,6 @@ LL_COMMON_API std::ostream& operator<<(std::ostream& s, const LLDate& date);
// Helper function to stream in a date
LL_COMMON_API std::istream& operator>>(std::istream& s, LLDate& date);
+
+
#endif // LL_LLDATE_H
diff --git a/indra/llcommon/llerrorlegacy.h b/indra/llcommon/llerrorlegacy.h
index 730733109..b4c3739e4 100644
--- a/indra/llcommon/llerrorlegacy.h
+++ b/indra/llcommon/llerrorlegacy.h
@@ -35,7 +35,6 @@
*/
// Specific error codes
-const int LL_ERR_NOERR = 0;
const int LL_ERR_ASSET_REQUEST_FAILED = -1;
//const int LL_ERR_ASSET_REQUEST_INVALID = -2;
const int LL_ERR_ASSET_REQUEST_NONEXISTENT_FILE = -3;
@@ -108,7 +107,7 @@ const int LL_ERR_PRICE_MISMATCH = -23018;
: liru_slashpos2 == std::string::npos ? std::string(__FILE__)/*Apparently, we're in / or perhaps the top of the drive, print as is*/\
: std::string(__FILE__).substr(1+liru_slashpos2))/*print foo/bar.cpp or perhaps foo\bar.cpp*/
-#define llassert_always(func) do { if (LL_UNLIKELY(!(func))) LL_ERRS() << "\nASSERT(" #func ")\nfile:" << liru_assert_strip << " line:" << std::dec << __LINE__ << LL_ENDL; } while(0)
+//#define llassert_always(func) do { if (LL_UNLIKELY(!(func))) LL_ERRS() << "\nASSERT(" #func ")\nfile:" << liru_assert_strip << " line:" << std::dec << __LINE__ << LL_ENDL; } while(0)
#ifdef SHOW_ASSERT
#define llassert(func) llassert_always(func)
diff --git a/indra/llcommon/lleventtimer.cpp b/indra/llcommon/lleventtimer.cpp
index 957b502dc..c491e37cb 100644
--- a/indra/llcommon/lleventtimer.cpp
+++ b/indra/llcommon/lleventtimer.cpp
@@ -65,7 +65,7 @@ LLEventTimer::~LLEventTimer()
void LLEventTimer::updateClass()
{
std::list completed_timers;
- for (instance_iter iter = beginInstances(), iter_end = endInstances(); iter != iter_end;)
+ for (instance_iter iter = beginInstances(), end_iter = endInstances(); iter != end_iter;)
{
LLEventTimer& timer = *iter++;
F32 et = timer.mEventTimer.getElapsedTimeF32();
diff --git a/indra/llcommon/llfile.cpp b/indra/llcommon/llfile.cpp
index 7660baa90..4f8ec6756 100644
--- a/indra/llcommon/llfile.cpp
+++ b/indra/llcommon/llfile.cpp
@@ -28,7 +28,7 @@
*/
#if LL_WINDOWS
-#include
+#include "llwin32headerslean.h"
#include // Windows errno
#else
#include
diff --git a/indra/llcommon/llfindlocale.cpp b/indra/llcommon/llfindlocale.cpp
index 505f5c540..d91620926 100644
--- a/indra/llcommon/llfindlocale.cpp
+++ b/indra/llcommon/llfindlocale.cpp
@@ -39,7 +39,7 @@
#include
#ifdef WIN32
-#include
+#include "llwin32headers.h"
#include
#endif
@@ -183,7 +183,7 @@ canonise_fl(FL_Locale *l) {
#define RML(pn,sn) MAKELANGID(LANG_##pn, SUBLANG_##sn)
struct IDToCode {
LANGID id;
- char* code;
+ const char* code;
};
static const IDToCode both_to_code[] = {
{ML(ENGLISH,US), "en_US.ISO_8859-1"},
diff --git a/indra/llcommon/llfixedbuffer.cpp b/indra/llcommon/llfixedbuffer.cpp
index 4b5cdbe28..bd4db8be8 100644
--- a/indra/llcommon/llfixedbuffer.cpp
+++ b/indra/llcommon/llfixedbuffer.cpp
@@ -30,7 +30,8 @@
LLFixedBuffer::LLFixedBuffer(const U32 max_lines)
: LLLineBuffer(),
- mMaxLines(max_lines)
+ mMaxLines(max_lines),
+ mMutex()
{
mTimer.reset();
}
diff --git a/indra/llcommon/llframetimer.h b/indra/llcommon/llframetimer.h
index 5ebf14247..a2b3ffa39 100644
--- a/indra/llcommon/llframetimer.h
+++ b/indra/llcommon/llframetimer.h
@@ -51,7 +51,7 @@ public:
// Atomic reads of static variables.
// Return the number of seconds since the start of the application.
- static F64 getElapsedSeconds(void)
+ static F64SecondsImplicit getElapsedSeconds(void)
{
// Loses msec precision after ~4.5 hours...
sGlobalMutex.lock();
diff --git a/indra/llcommon/llhandle.h b/indra/llcommon/llhandle.h
index 6af5e198d..401e4d759 100644
--- a/indra/llcommon/llhandle.h
+++ b/indra/llcommon/llhandle.h
@@ -194,13 +194,6 @@ public:
return mHandle;
}
-protected:
- typedef LLHandle handle_type_t;
- LLHandleProvider()
- {
- // provided here to enforce T deriving from LLHandleProvider
- }
-
template
LLHandle getDerivedHandle(typename boost::enable_if< typename boost::is_convertible >::type* dummy = 0) const
{
@@ -209,6 +202,12 @@ protected:
return downcast_handle;
}
+protected:
+ typedef LLHandle handle_type_t;
+ LLHandleProvider()
+ {
+ // provided here to enforce T deriving from LLHandleProvider
+ }
private:
mutable LLRootHandle mHandle;
diff --git a/indra/llcommon/lllivefile.cpp b/indra/llcommon/lllivefile.cpp
index ce6ac4fac..88274a91c 100644
--- a/indra/llcommon/lllivefile.cpp
+++ b/indra/llcommon/lllivefile.cpp
@@ -88,46 +88,51 @@ LLLiveFile::~LLLiveFile()
bool LLLiveFile::Impl::check()
{
- if (!mForceCheck && mRefreshTimer.getElapsedTimeF32() < mRefreshPeriod)
+ bool detected_change = false;
+ // Skip the check if not enough time has elapsed and we're not
+ // forcing a check of the file
+ if (mForceCheck || mRefreshTimer.getElapsedTimeF32() >= mRefreshPeriod)
{
- // Skip the check if not enough time has elapsed and we're not
- // forcing a check of the file
- return false;
- }
- mForceCheck = false;
- mRefreshTimer.reset();
+ mForceCheck = false; // force only forces one check
+ mRefreshTimer.reset(); // don't check again until mRefreshPeriod has passed
- // Stat the file to see if it exists and when it was last modified.
- llstat stat_data;
- int res = LLFile::stat(mFilename, &stat_data);
-
- if (res)
- {
- // Couldn't stat the file, that means it doesn't exist or is
- // broken somehow. Clear flags and return.
- if (mLastExists)
- {
- mLastExists = false;
- return true; // no longer existing is a change!
- }
- return false;
- }
-
- // The file exists, decide if we want to load it.
- if (mLastExists)
- {
- // The file existed last time, don't read it if it hasn't changed since
- // last time.
- if (stat_data.st_mtime <= mLastModTime)
- {
- return false;
- }
- }
-
- // We want to read the file. Update status info for the file.
- mLastExists = true;
- mLastStatTime = stat_data.st_mtime;
- return true;
+ // Stat the file to see if it exists and when it was last modified.
+ llstat stat_data;
+ if (LLFile::stat(mFilename, &stat_data))
+ {
+ // Couldn't stat the file, that means it doesn't exist or is
+ // broken somehow.
+ if (mLastExists)
+ {
+ mLastExists = false;
+ detected_change = true; // no longer existing is a change!
+ LL_DEBUGS() << "detected deleted file '" << mFilename << "'" << LL_ENDL;
+ }
+ }
+ else
+ {
+ // The file exists
+ if ( ! mLastExists )
+ {
+ // last check, it did not exist - that counts as a change
+ LL_DEBUGS() << "detected created file '" << mFilename << "'" << LL_ENDL;
+ detected_change = true;
+ }
+ else if ( stat_data.st_mtime > mLastModTime )
+ {
+ // file modification time is newer than last check
+ LL_DEBUGS() << "detected updated file '" << mFilename << "'" << LL_ENDL;
+ detected_change = true;
+ }
+ mLastExists = true;
+ mLastStatTime = stat_data.st_mtime;
+ }
+ }
+ if (detected_change)
+ {
+ LL_INFOS() << "detected file change '" << mFilename << "'" << LL_ENDL;
+ }
+ return detected_change;
}
void LLLiveFile::Impl::changed()
diff --git a/indra/llcommon/llmd5.cpp b/indra/llcommon/llmd5.cpp
index 46775313d..1881620e6 100644
--- a/indra/llcommon/llmd5.cpp
+++ b/indra/llcommon/llmd5.cpp
@@ -119,6 +119,12 @@ void LLMD5::update (const uint1 *input, const uint4 input_length) {
buffer_space = 64 - buffer_index; // how much space is left in buffer
+ // now, transform each 64-byte piece of the input, bypassing the buffer
+ if (input == NULL || input_length == 0){
+ std::cerr << "LLMD5::update: Invalid input!" << std::endl;
+ return;
+ }
+
// Transform as many times as possible.
if (input_length >= buffer_space) { // ie. we have enough to fill the buffer
// fill the rest of the buffer and transform
@@ -128,12 +134,6 @@ void LLMD5::update (const uint1 *input, const uint4 input_length) {
buffer_space);
transform (buffer);
- // now, transform each 64-byte piece of the input, bypassing the buffer
- if (input == NULL || input_length == 0){
- std::cerr << "LLMD5::update: Invalid input!" << std::endl;
- return;
- }
-
for (input_index = buffer_space; input_index + 63 < input_length;
input_index += 64)
transform (input+input_index);
diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp
index aba33abde..f843f3c96 100644
--- a/indra/llcommon/llmemory.cpp
+++ b/indra/llcommon/llmemory.cpp
@@ -32,7 +32,7 @@
//#endif
#if defined(LL_WINDOWS)
-//# include
+#include "llwin32headerslean.h"
# include
#elif defined(LL_DARWIN)
# include
@@ -50,11 +50,11 @@
//static
char* LLMemory::reserveMem = 0;
-U32 LLMemory::sAvailPhysicalMemInKB = U32_MAX ;
-U32 LLMemory::sMaxPhysicalMemInKB = 0;
-U32 LLMemory::sAllocatedMemInKB = 0;
-U32 LLMemory::sAllocatedPageSizeInKB = 0 ;
-U32 LLMemory::sMaxHeapSizeInKB = U32_MAX ;
+U32Kilobytes LLMemory::sAvailPhysicalMemInKB(U32_MAX);
+U32Kilobytes LLMemory::sMaxPhysicalMemInKB(0);
+U32Kilobytes LLMemory::sAllocatedMemInKB(0);
+U32Kilobytes LLMemory::sAllocatedPageSizeInKB(0);
+U32Kilobytes LLMemory::sMaxHeapSizeInKB(U32_MAX);
BOOL LLMemory::sEnableMemoryFailurePrevention = FALSE;
#if __DEBUG_PRIVATE_MEM__
@@ -93,9 +93,9 @@ void LLMemory::freeReserve()
}
//static
-void LLMemory::initMaxHeapSizeGB(F32 max_heap_size_gb, BOOL prevent_heap_failure)
+void LLMemory::initMaxHeapSizeGB(F32Gigabytes max_heap_size, BOOL prevent_heap_failure)
{
- sMaxHeapSizeInKB = (U32)(max_heap_size_gb * 1024 * 1024) ;
+ sMaxHeapSizeInKB = max_heap_size;
sEnableMemoryFailurePrevention = prevent_heap_failure ;
}
@@ -112,10 +112,10 @@ void LLMemory::updateMemoryInfo()
return ;
}
- sAllocatedMemInKB = (U32)(counters.WorkingSetSize / 1024) ;
- sAllocatedPageSizeInKB = (U32)(counters.PagefileUsage / 1024) ;
+ sAllocatedMemInKB = (U32Bytes)(counters.WorkingSetSize) ;
+ sAllocatedPageSizeInKB = (U32Bytes)(counters.PagefileUsage) ;
- U32 avail_phys, avail_virtual;
+ U32Kilobytes avail_phys, avail_virtual;
LLMemoryInfo::getAvailableMemoryKB(avail_phys, avail_virtual) ;
sMaxPhysicalMemInKB = llmin(avail_phys + sAllocatedMemInKB, sMaxHeapSizeInKB);
@@ -125,14 +125,16 @@ void LLMemory::updateMemoryInfo()
}
else
{
- sAvailPhysicalMemInKB = 0 ;
+ sAvailPhysicalMemInKB = U32Kilobytes(0);
}
#else
//not valid for other systems for now.
- sAllocatedMemInKB = (U32)(LLMemory::getCurrentRSS() / 1024) ;
- sMaxPhysicalMemInKB = U32_MAX ;
- sAvailPhysicalMemInKB = U32_MAX ;
+ sAllocatedMemInKB = (U32Bytes)LLMemory::getCurrentRSS();
+ sMaxPhysicalMemInKB = (U32Bytes)U32_MAX ;
+ sAvailPhysicalMemInKB = (U32Bytes)U32_MAX ;
#endif
+
+ return ;
}
//
@@ -184,8 +186,8 @@ void LLMemory::logMemoryInfo(BOOL update)
//static
bool LLMemory::isMemoryPoolLow()
{
- static const U32 LOW_MEMEOY_POOL_THRESHOLD_KB = 64 * 1024 ; //64 MB for emergency use
- const static U32 MAX_SIZE_CHECKED_MEMORY_BLOCK = 64 * 1024 * 1024 ; //64 MB
+ static const U32Megabytes LOW_MEMORY_POOL_THRESHOLD(64);
+ const static U32Megabytes MAX_SIZE_CHECKED_MEMORY_BLOCK(64);
static void* last_reserved_address = NULL ;
if(!sEnableMemoryFailurePrevention)
@@ -193,32 +195,32 @@ bool LLMemory::isMemoryPoolLow()
return false ; //no memory failure prevention.
}
- if(sAvailPhysicalMemInKB < (LOW_MEMEOY_POOL_THRESHOLD_KB >> 2)) //out of physical memory
+ if(sAvailPhysicalMemInKB < (LOW_MEMORY_POOL_THRESHOLD / 4)) //out of physical memory
{
return true ;
}
- if(sAllocatedPageSizeInKB + (LOW_MEMEOY_POOL_THRESHOLD_KB >> 2) > sMaxHeapSizeInKB) //out of virtual address space.
+ if(sAllocatedPageSizeInKB + (LOW_MEMORY_POOL_THRESHOLD / 4) > sMaxHeapSizeInKB) //out of virtual address space.
{
return true ;
}
- bool is_low = (S32)(sAvailPhysicalMemInKB < LOW_MEMEOY_POOL_THRESHOLD_KB ||
- sAllocatedPageSizeInKB + LOW_MEMEOY_POOL_THRESHOLD_KB > sMaxHeapSizeInKB) ;
+ bool is_low = (S32)(sAvailPhysicalMemInKB < LOW_MEMORY_POOL_THRESHOLD
+ || sAllocatedPageSizeInKB + LOW_MEMORY_POOL_THRESHOLD > sMaxHeapSizeInKB) ;
//check the virtual address space fragmentation
if(!is_low)
{
if(!last_reserved_address)
{
- last_reserved_address = LLMemory::tryToAlloc(last_reserved_address, MAX_SIZE_CHECKED_MEMORY_BLOCK) ;
+ last_reserved_address = LLMemory::tryToAlloc(last_reserved_address, MAX_SIZE_CHECKED_MEMORY_BLOCK.value()) ;
}
else
{
- last_reserved_address = LLMemory::tryToAlloc(last_reserved_address, MAX_SIZE_CHECKED_MEMORY_BLOCK) ;
+ last_reserved_address = LLMemory::tryToAlloc(last_reserved_address, MAX_SIZE_CHECKED_MEMORY_BLOCK.value()) ;
if(!last_reserved_address) //failed, try once more
{
- last_reserved_address = LLMemory::tryToAlloc(last_reserved_address, MAX_SIZE_CHECKED_MEMORY_BLOCK) ;
+ last_reserved_address = LLMemory::tryToAlloc(last_reserved_address, MAX_SIZE_CHECKED_MEMORY_BLOCK.value()) ;
}
}
@@ -229,19 +231,19 @@ bool LLMemory::isMemoryPoolLow()
}
//static
-U32 LLMemory::getAvailableMemKB()
+U32Kilobytes LLMemory::getAvailableMemKB()
{
return sAvailPhysicalMemInKB ;
}
//static
-U32 LLMemory::getMaxMemKB()
+U32Kilobytes LLMemory::getMaxMemKB()
{
return sMaxPhysicalMemInKB ;
}
//static
-U32 LLMemory::getAllocatedMemKB()
+U32Kilobytes LLMemory::getAllocatedMemKB()
{
return sAllocatedMemInKB ;
}
diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h
index 48cd2b7b2..efd61590a 100644
--- a/indra/llcommon/llmemory.h
+++ b/indra/llcommon/llmemory.h
@@ -27,7 +27,8 @@
#define LLMEMORY_H
#include "linden_common.h"
-
+#include "llunits.h"
+#include "stdtypes.h"
#include
#include
#if !LL_WINDOWS
@@ -42,6 +43,21 @@ class LLMutex ;
#define LL_CHECK_MEMORY
#endif
+
+#if LL_WINDOWS
+#define LL_ALIGN_OF __alignof
+#else
+#define LL_ALIGN_OF __align_of__
+#endif
+
+#if LL_WINDOWS
+#define LL_DEFAULT_HEAP_ALIGN 8
+#elif LL_DARWIN
+#define LL_DEFAULT_HEAP_ALIGN 16
+#elif LL_LINUX
+#define LL_DEFAULT_HEAP_ALIGN 8
+#endif
+
//
// ll_assert_aligned seems to only exist to set breakpoints in case an alignment check fails.
// However, the implementation was horrible: the test was done using a integer modulo after
@@ -102,31 +118,43 @@ template T* LL_NEXT_ALIGNED_ADDRESS_64(T* address)
#define LL_ALIGN_16(var) LL_ALIGN_PREFIX(16) var LL_ALIGN_POSTFIX(16)
-inline void* ll_aligned_malloc( size_t size, int align )
-{
-#if defined(LL_WINDOWS)
- return _aligned_malloc(size, align);
-#else
- void* mem = malloc( size + (align - 1) + sizeof(void*) );
- char* aligned = ((char*)mem) + sizeof(void*);
- aligned += align - ((uintptr_t)aligned & (align - 1));
+//------------------------------------------------------------------------------------------------
+//------------------------------------------------------------------------------------------------
+ // for enable buffer overrun detection predefine LL_DEBUG_BUFFER_OVERRUN in current library
+ // change preprocessor code to: #if 1 && defined(LL_WINDOWS)
- ((void**)aligned)[-1] = mem;
- return aligned;
-#endif
-}
-
-inline void ll_aligned_free( void* ptr )
-{
-#if defined(LL_WINDOWS)
- _aligned_free(ptr);
+#if 0 && defined(LL_WINDOWS)
+ void* ll_aligned_malloc_fallback( size_t size, int align );
+ void ll_aligned_free_fallback( void* ptr );
+//------------------------------------------------------------------------------------------------
#else
- if (ptr)
+ inline void* ll_aligned_malloc_fallback( size_t size, int align )
{
- free( ((void**)ptr)[-1] );
+ #if defined(LL_WINDOWS)
+ return _aligned_malloc(size, align);
+ #else
+ void* mem = malloc( size + (align - 1) + sizeof(void*) );
+ char* aligned = ((char*)mem) + sizeof(void*);
+ aligned += align - ((uintptr_t)aligned & (align - 1));
+
+ ((void**)aligned)[-1] = mem;
+ return aligned;
+ #endif
+ }
+
+ inline void ll_aligned_free_fallback( void* ptr )
+ {
+ #if defined(LL_WINDOWS)
+ _aligned_free(ptr);
+ #else
+ if (ptr)
+ {
+ free( ((void**)ptr)[-1] );
+ }
+ #endif
}
#endif
-}
+//------------------------------------------------------------------------------------------------
#if !LL_USE_TCMALLOC
inline void* ll_aligned_malloc_16(size_t size) // returned hunk MUST be freed with ll_aligned_free_16().
@@ -189,7 +217,7 @@ inline void* ll_aligned_malloc_32(size_t size) // returned hunk MUST be freed wi
#if defined(LL_WINDOWS)
return _aligned_malloc(size, 32);
#elif defined(LL_DARWIN)
- return ll_aligned_malloc( size, 32 );
+ return ll_aligned_malloc_fallback( size, 32 );
#else
void *rtn;
if (LL_LIKELY(0 == posix_memalign(&rtn, 32, size)))
@@ -204,12 +232,54 @@ inline void ll_aligned_free_32(void *p)
#if defined(LL_WINDOWS)
_aligned_free(p);
#elif defined(LL_DARWIN)
- ll_aligned_free( p );
+ ll_aligned_free_fallback( p );
#else
free(p); // posix_memalign() is compatible with heap deallocator
#endif
}
+// general purpose dispatch functions that are forced inline so they can compile down to a single call
+template
+LL_FORCE_INLINE void* ll_aligned_malloc(size_t size)
+{
+ if (LL_DEFAULT_HEAP_ALIGN % ALIGNMENT == 0)
+ {
+ return malloc(size);
+ }
+ else if (ALIGNMENT == 16)
+ {
+ return ll_aligned_malloc_16(size);
+ }
+ else if (ALIGNMENT == 32)
+ {
+ return ll_aligned_malloc_32(size);
+ }
+ else
+ {
+ return ll_aligned_malloc_fallback(size, ALIGNMENT);
+ }
+}
+
+template
+LL_FORCE_INLINE void ll_aligned_free(void* ptr)
+{
+ if (ALIGNMENT == LL_DEFAULT_HEAP_ALIGN)
+ {
+ free(ptr);
+ }
+ else if (ALIGNMENT == 16)
+ {
+ ll_aligned_free_16(ptr);
+ }
+ else if (ALIGNMENT == 32)
+ {
+ return ll_aligned_free_32(ptr);
+ }
+ else
+ {
+ return ll_aligned_free_fallback(ptr);
+ }
+}
// Copy words 16-byte blocks from src to dst. Source and destination MUST NOT OVERLAP.
// Source and dest must be 16-byte aligned and size must be multiple of 16.
@@ -297,22 +367,22 @@ public:
static U64 getCurrentRSS();
static U32 getWorkingSetSize();
static void* tryToAlloc(void* address, U32 size);
- static void initMaxHeapSizeGB(F32 max_heap_size_gb, BOOL prevent_heap_failure);
+ static void initMaxHeapSizeGB(F32Gigabytes max_heap_size, BOOL prevent_heap_failure);
static void updateMemoryInfo() ;
static void logMemoryInfo(BOOL update = FALSE);
static bool isMemoryPoolLow();
- static U32 getAvailableMemKB() ;
- static U32 getMaxMemKB() ;
- static U32 getAllocatedMemKB() ;
+ static U32Kilobytes getAvailableMemKB() ;
+ static U32Kilobytes getMaxMemKB() ;
+ static U32Kilobytes getAllocatedMemKB() ;
private:
static char* reserveMem;
- static U32 sAvailPhysicalMemInKB ;
- static U32 sMaxPhysicalMemInKB ;
- static U32 sAllocatedMemInKB;
- static U32 sAllocatedPageSizeInKB ;
+ static U32Kilobytes sAvailPhysicalMemInKB ;
+ static U32Kilobytes sMaxPhysicalMemInKB ;
+ static U32Kilobytes sAllocatedMemInKB;
+ static U32Kilobytes sAllocatedPageSizeInKB ;
- static U32 sMaxHeapSizeInKB;
+ static U32Kilobytes sMaxHeapSizeInKB;
static BOOL sEnableMemoryFailurePrevention;
};
diff --git a/indra/llcommon/llmortician.h b/indra/llcommon/llmortician.h
index 59d284182..074e38fe4 100644
--- a/indra/llcommon/llmortician.h
+++ b/indra/llcommon/llmortician.h
@@ -34,6 +34,7 @@
#define LLMORTICIAN_H
#include "stdtypes.h"
+#include
class LL_COMMON_API LLMortician
{
diff --git a/indra/llcommon/llprocessor.cpp b/indra/llcommon/llprocessor.cpp
index 5c731c691..f86923f9d 100644
--- a/indra/llcommon/llprocessor.cpp
+++ b/indra/llcommon/llprocessor.cpp
@@ -32,9 +32,7 @@
//#include
#if LL_WINDOWS
-# define WIN32_LEAN_AND_MEAN
-# include
-# include
+# include "llwin32headerslean.h"
# define _interlockedbittestandset _renamed_interlockedbittestandset
# define _interlockedbittestandreset _renamed_interlockedbittestandreset
# include
@@ -881,7 +879,7 @@ LLProcessorInfo::LLProcessorInfo() : mImpl(NULL)
LLProcessorInfo::~LLProcessorInfo() {}
-F64 LLProcessorInfo::getCPUFrequency() const { return mImpl->getCPUFrequency(); }
+F64MegahertzImplicit LLProcessorInfo::getCPUFrequency() const { return mImpl->getCPUFrequency(); }
bool LLProcessorInfo::hasSSE() const { return mImpl->hasSSE(); }
bool LLProcessorInfo::hasSSE2() const { return mImpl->hasSSE2(); }
bool LLProcessorInfo::hasAltivec() const { return mImpl->hasAltivec(); }
diff --git a/indra/llcommon/llprocessor.h b/indra/llcommon/llprocessor.h
index fc2c8dacf..681dd6314 100644
--- a/indra/llcommon/llprocessor.h
+++ b/indra/llcommon/llprocessor.h
@@ -33,6 +33,8 @@
#ifndef LLPROCESSOR_H
#define LLPROCESSOR_H
+#include "llunits.h"
+
class LLProcessorInfoImpl;
class LL_COMMON_API LLProcessorInfo
@@ -41,7 +43,7 @@ public:
LLProcessorInfo();
~LLProcessorInfo();
- F64 getCPUFrequency() const;
+ F64MegahertzImplicit getCPUFrequency() const;
bool hasSSE() const;
bool hasSSE2() const;
bool hasAltivec() const;
diff --git a/indra/llcommon/llqueuedthread.cpp b/indra/llcommon/llqueuedthread.cpp
index 5ba7b8bd8..8fe3acf54 100644
--- a/indra/llcommon/llqueuedthread.cpp
+++ b/indra/llcommon/llqueuedthread.cpp
@@ -35,7 +35,7 @@
LLQueuedThread::LLQueuedThread(const std::string& name, bool threaded, bool should_pause) :
LLThread(name),
mThreaded(threaded),
- mIdleThread(TRUE),
+ mIdleThread(true),
mNextHandle(0),
mStarted(FALSE)
{
@@ -552,14 +552,15 @@ void LLQueuedThread::run()
break;
}
- mIdleThread = FALSE;
+ mIdleThread = false;
threadedUpdate();
- int res = processNextRequest();
- if (res == 0)
+ int pending_work = processNextRequest();
+
+ if (pending_work == 0)
{
- mIdleThread = TRUE;
+ mIdleThread = true;
ms_sleep(1);
}
//LLThread::yield(); // thread should yield after each request
diff --git a/indra/llcommon/llqueuedthread.h b/indra/llcommon/llqueuedthread.h
index dda7bf69c..2da59b8ed 100644
--- a/indra/llcommon/llqueuedthread.h
+++ b/indra/llcommon/llqueuedthread.h
@@ -32,8 +32,6 @@
#include