From bedcf734b15ba480b170ef6538bf9529e80aea26 Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Thu, 5 Oct 2023 00:35:05 -0400
Subject: [PATCH] Import Ansa's fix for multi-session sound

---
 indra/llaudio/llaudiodecodemgr.cpp |  6 +++++-
 indra/llaudio/llaudioengine.cpp    | 10 ++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/indra/llaudio/llaudiodecodemgr.cpp b/indra/llaudio/llaudiodecodemgr.cpp
index 7e255299c7d..906f19203cf 100644
--- a/indra/llaudio/llaudiodecodemgr.cpp
+++ b/indra/llaudio/llaudiodecodemgr.cpp
@@ -800,7 +800,11 @@ BOOL LLAudioDecodeMgr::addDecodeRequest(const LLUUID &uuid)
 	{
 		// 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);
+		// ...only add it if it's note already in the queue
+		if (std::find(mImpl->mDecodeQueue.begin(), mImpl->mDecodeQueue.end(), uuid) == mImpl->mDecodeQueue.end())
+		{
+			mImpl->mDecodeQueue.push_back(uuid);
+		}
 		return TRUE;
 	}
 
diff --git a/indra/llaudio/llaudioengine.cpp b/indra/llaudio/llaudioengine.cpp
index fc670c88fe3..e9647bbbb11 100644
--- a/indra/llaudio/llaudioengine.cpp
+++ b/indra/llaudio/llaudioengine.cpp
@@ -1911,6 +1911,16 @@ bool LLAudioData::load()
 		gAudiop->cleanupBuffer(mBufferp);
 		mBufferp = NULL;
 
+		if (!gDirUtilp->fileExists(wav_path))
+		{
+			mHasLocalData = false;
+			mHasDecodedData = false;
+			mHasCompletedDecode = false;
+			mHasDecodeFailed = false;
+			mHasWAVLoadFailed = false;
+			gAudiop->preloadSound(mID);
+		}
+
 		return false;
 	}
 	mBufferp->mAudioDatap = this;
-- 
GitLab