summaryrefslogtreecommitdiff
path: root/indra/newview/lltexturefetch.cpp
diff options
context:
space:
mode:
authorRoxie Linden <roxie@lindenlab.com>2024-05-06 16:40:12 -0700
committerRoxie Linden <roxie@lindenlab.com>2024-05-06 16:40:12 -0700
commit4af9128db1fb65ff99d1e8086352698f46e049b4 (patch)
tree4b98d8afb138a4a1ac9f2d4b01a7d83dce314d17 /indra/newview/lltexturefetch.cpp
parent05b2dd913fcb1c5485ce19885e4e60f26752e6b0 (diff)
parent10aa7f4254fd04c24f15f507188705146f92ee60 (diff)
Merge branch 'main' of https://github.com/secondlife/viewer into roxie/webrtc-voice
Diffstat (limited to 'indra/newview/lltexturefetch.cpp')
-rw-r--r--indra/newview/lltexturefetch.cpp36
1 files changed, 29 insertions, 7 deletions
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index 38c9b3717d..40bbe2b934 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -348,13 +348,13 @@ private:
}
// Threads: Tid
- virtual void completed(bool success, LLImageRaw* raw, LLImageRaw* aux)
+ virtual void completed(bool success, LLImageRaw* raw, LLImageRaw* aux, U32 request_id)
{
LL_PROFILE_ZONE_SCOPED;
LLTextureFetchWorker* worker = mFetcher->getWorker(mID);
if (worker)
{
- worker->callbackDecoded(success, raw, aux);
+ worker->callbackDecoded(success, raw, aux, request_id);
}
}
private:
@@ -398,7 +398,7 @@ public:
void callbackCacheWrite(bool success);
// Threads: Tid
- void callbackDecoded(bool success, LLImageRaw* raw, LLImageRaw* aux);
+ void callbackDecoded(bool success, LLImageRaw* raw, LLImageRaw* aux, S32 decode_id);
// Threads: T*
void setGetStatus(LLCore::HttpStatus status, const std::string& reason)
@@ -1800,8 +1800,22 @@ bool LLTextureFetchWorker::doWork(S32 param)
setState(DECODE_IMAGE_UPDATE);
LL_DEBUGS(LOG_TXT) << mID << ": Decoding. Bytes: " << mFormattedImage->getDataSize() << " Discard: " << discard
<< " All Data: " << mHaveAllData << LL_ENDL;
- mDecodeHandle = LLAppViewer::getImageDecodeThread()->decodeImage(mFormattedImage, discard, mNeedsAux,
- new DecodeResponder(mFetcher, mID, this));
+
+ // In case worked manages to request decode, be shut down,
+ // then init and request decode again with first decode
+ // still in progress, assign a sufficiently unique id
+ mDecodeHandle = LLAppViewer::getImageDecodeThread()->decodeImage(mFormattedImage,
+ discard,
+ mNeedsAux,
+ new DecodeResponder(mFetcher, mID, this));
+ if (mDecodeHandle == 0)
+ {
+ // Abort, failed to put into queue.
+ // Happens if viewer is shutting down
+ setState(DONE);
+ LL_DEBUGS(LOG_TXT) << mID << " DECODE_IMAGE abort: failed to post for decoding" << LL_ENDL;
+ return true;
+ }
// fall though
}
@@ -2305,16 +2319,24 @@ void LLTextureFetchWorker::callbackCacheWrite(bool success)
//////////////////////////////////////////////////////////////////////////////
// Threads: Tid
-void LLTextureFetchWorker::callbackDecoded(bool success, LLImageRaw* raw, LLImageRaw* aux)
+void LLTextureFetchWorker::callbackDecoded(bool success, LLImageRaw* raw, LLImageRaw* aux, S32 decode_id)
{
LLMutexLock lock(&mWorkMutex); // +Mw
if (mDecodeHandle == 0)
{
return; // aborted, ignore
}
+ if (mDecodeHandle != decode_id)
+ {
+ // Queue doesn't support canceling old requests.
+ // This shouldn't normally happen, but in case it's possible that a worked
+ // will request decode, be aborted, reinited then start a new decode
+ LL_DEBUGS(LOG_TXT) << mID << " received obsolete decode's callback" << LL_ENDL;
+ return; // ignore
+ }
if (mState != DECODE_IMAGE_UPDATE)
{
-// LL_WARNS(LOG_TXT) << "Decode callback for " << mID << " with state = " << mState << LL_ENDL;
+ LL_DEBUGS(LOG_TXT) << "Decode callback for " << mID << " with state = " << mState << LL_ENDL;
mDecodeHandle = 0;
return;
}