Applied MAINT-862. Sounds not playing first time. http://hg.secondlife.com/viewer-beta/changeset/24a7281bef42

This commit is contained in:
Shyotl
2012-06-09 01:50:14 -05:00
parent 5228aa7029
commit 332c8f997c
3 changed files with 31 additions and 16 deletions

View File

@@ -616,7 +616,8 @@ void LLAudioDecodeMgr::Impl::processQueue(const F32 num_secs)
llwarns << mCurrentDecodep->getUUID() << " has invalid vorbis data, aborting decode" << llendl; llwarns << mCurrentDecodep->getUUID() << " has invalid vorbis data, aborting decode" << llendl;
mCurrentDecodep->flushBadFile(); mCurrentDecodep->flushBadFile();
LLAudioData *adp = gAudiop->getAudioData(mCurrentDecodep->getUUID()); LLAudioData *adp = gAudiop->getAudioData(mCurrentDecodep->getUUID());
adp->setHasValidData(FALSE); adp->setHasValidData(false);
adp->setHasCompletedDecode(true);
mCurrentDecodep = NULL; mCurrentDecodep = NULL;
done = TRUE; done = TRUE;
} }
@@ -631,11 +632,16 @@ void LLAudioDecodeMgr::Impl::processQueue(const F32 num_secs)
if (mCurrentDecodep->finishDecode()) if (mCurrentDecodep->finishDecode())
{ {
// We finished! // We finished!
if (mCurrentDecodep->isValid() && mCurrentDecodep->isDone())
{
LLAudioData *adp = gAudiop->getAudioData(mCurrentDecodep->getUUID()); LLAudioData *adp = gAudiop->getAudioData(mCurrentDecodep->getUUID());
adp->setHasDecodedData(TRUE); if (!adp)
adp->setHasValidData(TRUE); {
llwarns << "Missing LLAudioData for decode of " << mCurrentDecodep->getUUID() << llendl;
}
else if (mCurrentDecodep->isValid() && mCurrentDecodep->isDone())
{
adp->setHasCompletedDecode(true);
adp->setHasDecodedData(true);
adp->setHasValidData(true);
// At this point, we could see if anyone needs this sound immediately, but // 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 // I'm not sure that there's a reason to - we need to poll all of the playing
@@ -644,7 +650,8 @@ void LLAudioDecodeMgr::Impl::processQueue(const F32 num_secs)
} }
else else
{ {
llinfos << "Vorbis decode failed!!!" << llendl; adp->setHasCompletedDecode(true);
llinfos << "Vorbis decode failed for " << mCurrentDecodep->getUUID() << llendl;
} }
mCurrentDecodep = NULL; mCurrentDecodep = NULL;
} }

View File

@@ -1279,6 +1279,7 @@ void LLAudioEngine::assetCallback(LLVFS *vfs, const LLUUID &uuid, LLAssetType::E
adp->setHasValidData(false); adp->setHasValidData(false);
adp->setHasLocalData(false); adp->setHasLocalData(false);
adp->setHasDecodedData(false); adp->setHasDecodedData(false);
adp->setHasCompletedDecode(true);
} }
} }
else else
@@ -1380,16 +1381,18 @@ void LLAudioSource::update()
if (!getCurrentBuffer()) if (!getCurrentBuffer())
{ {
if (getCurrentData()) LLAudioData *adp = getCurrentData();
if (adp)
{ {
// Hack - try and load the sound. Will do this as a callback // Hack - try and load the sound. Will do this as a callback
// on decode later. // on decode later.
if (getCurrentData()->load() && getCurrentData()->getBuffer()) if (adp->load() && adp->getBuffer())
{ {
play(getCurrentData()->getID()); play(adp->getID());
} }
else else if (adp->hasCompletedDecode()) // Only mark corrupted after decode is done
{ {
llwarns << "Marking LLAudioSource corrupted for " << adp->getID() << llendl;
mCorrupted = true ; mCorrupted = true ;
} }
} }
@@ -1812,6 +1815,7 @@ LLAudioData::LLAudioData(const LLUUID &uuid) :
mBufferp(NULL), mBufferp(NULL),
mHasLocalData(false), mHasLocalData(false),
mHasDecodedData(false), mHasDecodedData(false),
mHasCompletedDecode(false),
mHasValidData(true) mHasValidData(true)
{ {
if (uuid.isNull()) if (uuid.isNull())
@@ -1823,12 +1827,13 @@ LLAudioData::LLAudioData(const LLUUID &uuid) :
if (gAudiop && gAudiop->hasDecodedFile(uuid)) if (gAudiop && gAudiop->hasDecodedFile(uuid))
{ {
// Already have a decoded version, don't need to decode it. // Already have a decoded version, don't need to decode it.
mHasLocalData = true; setHasLocalData(true);
mHasDecodedData = true; setHasDecodedData(true);
setHasCompletedDecode(true);
} }
else if (gAssetStorage && gAssetStorage->hasLocalAsset(uuid, LLAssetType::AT_SOUND)) else if (gAssetStorage && gAssetStorage->hasLocalAsset(uuid, LLAssetType::AT_SOUND))
{ {
mHasLocalData = true; setHasLocalData(true);
} }
} }

View File

@@ -408,10 +408,12 @@ public:
bool hasLocalData() const { return mHasLocalData; } bool hasLocalData() const { return mHasLocalData; }
bool hasDecodedData() const { return mHasDecodedData; } bool hasDecodedData() const { return mHasDecodedData; }
bool hasCompletedDecode() const { return mHasCompletedDecode; }
bool hasValidData() const { return mHasValidData; } bool hasValidData() const { return mHasValidData; }
void setHasLocalData(const bool hld) { mHasLocalData = hld; } void setHasLocalData(const bool hld) { mHasLocalData = hld; }
void setHasDecodedData(const bool hdd) { mHasDecodedData = hdd; } void setHasDecodedData(const bool hdd) { mHasDecodedData = hdd; }
void setHasCompletedDecode(const bool hcd) { mHasCompletedDecode = hcd; }
void setHasValidData(const bool hvd) { mHasValidData = hvd; } void setHasValidData(const bool hvd) { mHasValidData = hvd; }
friend class LLAudioEngine; // Severe laziness, bad. friend class LLAudioEngine; // Severe laziness, bad.
@@ -419,9 +421,10 @@ public:
protected: protected:
LLUUID mID; LLUUID mID;
LLAudioBuffer *mBufferp; // If this data is being used by the audio system, a pointer to the buffer will be set here. LLAudioBuffer *mBufferp; // If this data is being used by the audio system, a pointer to the buffer will be set here.
bool mHasLocalData; bool mHasLocalData; // Set true if the sound asset file is available locally
bool mHasDecodedData; bool mHasDecodedData; // Set true if the sound file has been decoded
bool mHasValidData; bool mHasCompletedDecode; // Set true when the sound is decoded
bool mHasValidData; // Set false if decoding failed, meaning the sound asset is bad
}; };