From 3f89c98dac05c24a8897330f0bd96bfabdd8096f Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 22 Jul 2022 03:11:08 +0300 Subject: SL-17816 Crash trying to schedule audio decoding on shutdown --- indra/llaudio/llaudiodecodemgr.cpp | 64 ++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 27 deletions(-) (limited to 'indra/llaudio') diff --git a/indra/llaudio/llaudiodecodemgr.cpp b/indra/llaudio/llaudiodecodemgr.cpp index bc082bf39a..38a6b41afe 100755 --- a/indra/llaudio/llaudiodecodemgr.cpp +++ b/indra/llaudio/llaudiodecodemgr.cpp @@ -607,36 +607,46 @@ void LLAudioDecodeMgr::Impl::startMoreDecodes() // Kick off a decode mDecodes[decode_id] = LLPointer(NULL); - main_queue->postTo( - general_queue, - [decode_id]() // Work done on general queue - { - LLPointer decode_state = beginDecodingAndWritingAudio(decode_id); - - if (!decode_state) - { - // Audio decode has errored - return decode_state; - } - - // Disk write of decoded audio is now in progress off-thread - return decode_state; - }, - [decode_id, this](LLPointer decode_state) // Callback to main thread - mutable { - if (!gAudiop) + try + { + main_queue->postTo( + general_queue, + [decode_id]() // Work done on general queue { - // There is no LLAudioEngine anymore. This might happen if - // an audio decode is enqueued just before shutdown. - return; - } + LLPointer decode_state = beginDecodingAndWritingAudio(decode_id); - // At this point, we can be certain that the pointer to "this" - // is valid because the lifetime of "this" is dependent upon - // the lifetime of gAudiop. + if (!decode_state) + { + // Audio decode has errored + return decode_state; + } - enqueueFinishAudio(decode_id, decode_state); - }); + // Disk write of decoded audio is now in progress off-thread + return decode_state; + }, + [decode_id, this](LLPointer decode_state) // Callback to main thread + mutable { + if (!gAudiop) + { + // There is no LLAudioEngine anymore. This might happen if + // an audio decode is enqueued just before shutdown. + return; + } + + // At this point, we can be certain that the pointer to "this" + // is valid because the lifetime of "this" is dependent upon + // the lifetime of gAudiop. + + enqueueFinishAudio(decode_id, decode_state); + }); + } + catch (const LLThreadSafeQueueInterrupt&) + { + // Shutdown + // Consider making processQueue() do a cleanup instead + // of starting more decodes + LL_WARNS() << "Tried to start decoding on shutdown" << LL_ENDL; + } } } -- cgit v1.2.3