Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions indra/llaudio/llaudiodecodemgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ S32 cache_seek(void *datasource, ogg_int64_t offset, S32 whence)
break;
case SEEK_END:
origin = file->getSize();
if (origin <= 0)
{
return -1;
}
break;
case SEEK_CUR:
origin = -1;
Expand Down Expand Up @@ -203,11 +207,11 @@ bool LLVorbisDecodeState::initDecode()
{
LL_WARNS("AudioEngine") << "unable to open vorbis source vfile for reading" << LL_ENDL;
delete mInFilep;
mInFilep = NULL;
mInFilep = nullptr;
return false;
}

S32 r = ov_open_callbacks(mInFilep, &mVF, NULL, 0, cache_callbacks);
S32 r = ov_open_callbacks(mInFilep, &mVF, nullptr, 0, cache_callbacks);
if(r < 0)
{
LL_WARNS("AudioEngine") << r << " Input to vorbis decode does not appear to be an Ogg bitstream: " << mUUID << LL_ENDL;
Expand Down Expand Up @@ -259,7 +263,7 @@ bool LLVorbisDecodeState::initDecode()
LL_WARNS("AudioEngine") << "Bad asset encoded by: " << comment->vendor << LL_ENDL;
}
delete mInFilep;
mInFilep = NULL;
mInFilep = nullptr;
return false;
}

Expand All @@ -272,7 +276,7 @@ bool LLVorbisDecodeState::initDecode()
{
LL_WARNS("AudioEngine") << "Out of memory when trying to alloc buffer: " << size_guess << LL_ENDL;
delete mInFilep;
mInFilep = NULL;
mInFilep = nullptr;
return false;
}

Expand Down
111 changes: 53 additions & 58 deletions indra/llcharacter/llkeyframemotion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,6 @@ void LLKeyframeMotion::JointMotion::update(LLJointState* joint_state, F32 time,
}
}


//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// LLKeyframeMotion class
Expand Down Expand Up @@ -564,59 +563,48 @@ LLMotion::LLMotionInitStatus LLKeyframeMotion::onInitialize(LLCharacter *charact
// Load named file by concatenating the character prefix with the motion name.
// Load data into a buffer to be parsed.
//-------------------------------------------------------------------------
U8 *anim_data;
S32 anim_file_size;

bool success = false;
LLFileSystem* anim_file = new LLFileSystem(mID, LLAssetType::AT_ANIMATION);
if (!anim_file || !anim_file->getSize())
S64 anim_file_size = LLFileSystem::getFileSize(mID, LLAssetType::AT_ANIMATION);
if (anim_file_size <= 0)
{
delete anim_file;
anim_file = NULL;

// request asset over network on next call to load
mAssetStatus = ASSET_NEEDS_FETCH;

return STATUS_HOLD;
}
else

U8 *anim_data = new(std::nothrow) U8[anim_file_size];
if (anim_data)
{
anim_file_size = anim_file->getSize();
anim_data = new(std::nothrow) U8[anim_file_size];
if (anim_data)
LLFileSystem anim_file(mID, LLAssetType::AT_ANIMATION);
bool success = anim_file.read(anim_data, anim_file_size);
if (success)
{
success = anim_file->read(anim_data, anim_file_size); /*Flawfinder: ignore*/
LL_DEBUGS() << "Loading keyframe data for: " << getName() << ":" << getID() << " (" << anim_file_size << " bytes)" << LL_ENDL;

LLDataPackerBinaryBuffer dp(anim_data, (S32)anim_file_size);
success = deserialize(dp, getID());
if (!success)
{
LL_WARNS() << "Failed to decode asset for animation " << getName() << ":" << getID() << LL_ENDL;
}
}
else
{
LL_WARNS() << "Failed to allocate buffer: " << anim_file_size << mID << LL_ENDL;
LL_WARNS() << "Can't read animation file " << getID() << LL_ENDL;
}
delete []anim_data;
if (success)
{
mAssetStatus = ASSET_LOADED;
return STATUS_SUCCESS;
}
delete anim_file;
anim_file = NULL;
}

if (!success)
{
LL_WARNS() << "Can't open animation file " << mID << LL_ENDL;
mAssetStatus = ASSET_FETCH_FAILED;
return STATUS_FAILURE;
}

LL_DEBUGS() << "Loading keyframe data for: " << getName() << ":" << getID() << " (" << anim_file_size << " bytes)" << LL_ENDL;

LLDataPackerBinaryBuffer dp(anim_data, anim_file_size);

if (!deserialize(dp, getID()))
else
{
LL_WARNS() << "Failed to decode asset for animation " << getName() << ":" << getID() << LL_ENDL;
mAssetStatus = ASSET_FETCH_FAILED;
return STATUS_FAILURE;
LL_WARNS() << "Failed to allocate buffer: " << anim_file_size << getID() << LL_ENDL;
}

delete []anim_data;

mAssetStatus = ASSET_LOADED;
return STATUS_SUCCESS;
mAssetStatus = ASSET_FETCH_FAILED;
return STATUS_FAILURE;
}

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -2175,7 +2163,7 @@ bool LLKeyframeMotion::serialize(LLDataPacker& dp) const
//-----------------------------------------------------------------------------
// getFileSize()
//-----------------------------------------------------------------------------
U32 LLKeyframeMotion::getFileSize()
S32 LLKeyframeMotion::getFileSize()
{
// serialize into a dummy buffer to calculate required size
LLDataPackerBinaryBuffer dp;
Expand Down Expand Up @@ -2443,36 +2431,43 @@ void LLKeyframeMotion::onLoadComplete(const LLUUID& asset_uuid,
// asset already loaded
return;
}
LLFileSystem file(asset_uuid, type, LLFileSystem::READ);
S32 size = file.getSize();
// set assetStatus to failed, will be set to loaded if we succeed
motionp->mAssetStatus = ASSET_FETCH_FAILED;

U8* buffer = new(std::nothrow) U8[size];
if (!buffer)
S64 size = LLFileSystem::getFileSize(asset_uuid, type);
if (size > 0)
{
LLError::LLUserWarningMsg::showOutOfMemory();
LL_ERRS() << "Bad memory allocation for buffer of size: " << size << LL_ENDL;
}
file.read((U8*)buffer, size); /*Flawfinder: ignore*/
U8* buffer = new (std::nothrow) U8[size];
if (!buffer)
{
LLError::LLUserWarningMsg::showOutOfMemory();
LL_ERRS() << "Bad memory allocation for buffer of size: " << size << LL_ENDL;
}
LLFileSystem file(asset_uuid, type, LLFileSystem::READ);
file.read(buffer, size);

LL_DEBUGS("Animation") << "Loading keyframe data for: " << motionp->getName() << ":" << motionp->getID() << " (" << size << " bytes)" << LL_ENDL;
LL_DEBUGS("Animation") << "Loading keyframe data for: " << motionp->getName() << ":" << motionp->getID() << " (" << size
<< " bytes)" << LL_ENDL;

LLDataPackerBinaryBuffer dp(buffer, size);
if (motionp->deserialize(dp, asset_uuid))
{
motionp->mAssetStatus = ASSET_LOADED;
LLDataPackerBinaryBuffer dp(buffer, (S32)size);
if (motionp->deserialize(dp, asset_uuid))
{
motionp->mAssetStatus = ASSET_LOADED;
}
else
{
LL_WARNS() << "Failed to decode asset for animation " << motionp->getName() << ":" << motionp->getID() << LL_ENDL;
}
delete[] buffer;
}
else
{
LL_WARNS() << "Failed to decode asset for animation " << motionp->getName() << ":" << motionp->getID() << LL_ENDL;
motionp->mAssetStatus = ASSET_FETCH_FAILED;
LL_WARNS() << "Failed to load asset for animation " << motionp->getName() << ":" << motionp->getID() << LL_ENDL;
}

delete[] buffer;
}
else
{
LL_WARNS() << "Failed to load asset for animation " << motionp->getName() << ":" << motionp->getID() << LL_ENDL;
motionp->mAssetStatus = ASSET_FETCH_FAILED;
}
}
else
Expand Down
2 changes: 1 addition & 1 deletion indra/llcharacter/llkeyframemotion.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class LLKeyframeMotion :
void* user_data, S32 status, LLExtStat ext_status);

public:
U32 getFileSize();
S32 getFileSize();
bool serialize(LLDataPacker& dp) const;
bool deserialize(LLDataPacker& dp, const LLUUID& asset_id, bool allow_invalid_joints = true);
bool isLoaded() { return mJointMotionList != NULL; }
Expand Down
Loading