FIRE-5503; Fix for sounds not playing right away.

Nicky 2012-03-29 00:46:33 +02:00
parent d9d47fd1ba
commit c0bbc101d7
3 changed files with 35 additions and 2 deletions

View File

@ -591,6 +591,7 @@ void LLAudioDecodeMgr::Impl::processQueue(const F32 num_secs)
LLAudioData *adp = gAudiop->getAudioData(mCurrentDecodep->getUUID());
adp->setHasDecodedData(TRUE);
adp->setHasValidData(TRUE);
adp->setHasDecodeRequestPending( false ); // <FS:ND/> All done, buffer can be used.
// At this point, we could see if anyone needs this sound immediately, but
// I'm not sure that there's a reason to - we need to poll all of the playing
@ -600,6 +601,14 @@ void LLAudioDecodeMgr::Impl::processQueue(const F32 num_secs)
else
{
llinfos << "Vorbis decode failed!!!" << llendl;
// <FS:ND> Decode failed, mark audiodata as not waiting for decoded data, then it can be reused.
LLAudioData *adp = gAudiop->getAudioData(mCurrentDecodep->getUUID());
if( adp )
adp->setHasDecodeRequestPending( false );
// </FS:ND>
}
mCurrentDecodep = NULL;
}

View File

@ -1230,6 +1230,7 @@ void LLAudioEngine::assetCallback(LLVFS *vfs, const LLUUID &uuid, LLAssetType::E
adp->setHasValidData(false);
adp->setHasLocalData(false);
adp->setHasDecodedData(false);
adp->setHasDecodeRequestPending( false ); // <FS:ND> Buffer has no data, can be reused.
}
}
else
@ -1243,7 +1244,8 @@ void LLAudioEngine::assetCallback(LLVFS *vfs, const LLUUID &uuid, LLAssetType::E
else
{
adp->setHasValidData(true);
adp->setHasLocalData(true);
adp->setHasLocalData(true);
adp->setHasDecodeRequestPending( true ); // <FS:ND> Data must be decoded, wait for it.
gAudioDecodeMgrp->addDecodeRequest(uuid);
}
}
@ -1311,6 +1313,13 @@ void LLAudioSource::update()
{
if (getCurrentData())
{
// <FS:ND> Don't try to load if still waiting for decoded data. Otherwise load fails, mCorrupted gets set and we never get a sound played.
if( getCurrentData()->hasDecodeRequestPending() )
return;
// </FS:ND>
// Hack - try and load the sound. Will do this as a callback
// on decode later.
if (getCurrentData()->load() && getCurrentData()->getBuffer())
@ -1736,10 +1745,12 @@ LLAudioData::LLAudioData(const LLUUID &uuid) :
mBufferp(NULL),
mHasLocalData(false),
mHasDecodedData(false),
mHasValidData(true)
mHasValidData(true),
mHasDecodeRequest(true)
{
if (uuid.isNull())
{
mHasDecodeRequest = false;
// This is a null sound.
return;
}
@ -1749,10 +1760,14 @@ LLAudioData::LLAudioData(const LLUUID &uuid) :
// Already have a decoded version, don't need to decode it.
mHasLocalData = true;
mHasDecodedData = true;
mHasDecodeRequest = false;
}
else if (gAssetStorage && gAssetStorage->hasLocalAsset(uuid, LLAssetType::AT_SOUND))
{
mHasLocalData = true;
mHasDecodeRequest = false;
}
}

View File

@ -385,6 +385,15 @@ protected:
bool mHasLocalData;
bool mHasDecodedData;
bool mHasValidData;
// <FS:ND> Mark data as still waiting for being decoded.
public:
void setHasDecodeRequestPending( bool aRequestPending ) { mHasDecodeRequest = aRequestPending; }
bool hasDecodeRequestPending() const { return mHasDecodeRequest; }
private:
bool mHasDecodeRequest;
// </FS:ND>
};