diff options
author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2021-08-18 22:27:19 +0300 |
---|---|---|
committer | Andrey Lihatskiy <alihatskiy@productengine.com> | 2021-10-13 22:05:36 +0300 |
commit | 1e7fd6302aa39f1a011e2e4d711bca7a88a62076 (patch) | |
tree | 16da3c7404b28b182b3b578ef60e03c21b18ee18 /indra | |
parent | 241881309a568c2521ef773bf43544298ff1fd61 (diff) |
SL-15462 Refactor voiceControlCoro() into a state machine #2
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llvoicevivox.cpp | 38 | ||||
-rw-r--r-- | indra/newview/llvoicevivox.h | 1 |
2 files changed, 35 insertions, 4 deletions
diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index a8d5ef627f..4aa6f2c6b2 100644 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -676,20 +676,45 @@ typedef enum e_voice_control_coro_state void LLVivoxVoiceClient::voiceControlCoro() { + int state = 0; + try + { + // state is passed as a reference instead of being + // a member due to unresolved issues with coroutine + // surviving longer than LLVivoxVoiceClient + voiceControlStateMachine(state); + } + catch (const LLContinueError&) + { + LOG_UNHANDLED_EXCEPTION("LLVivoxVoiceClient"); + } + catch (...) + { + // Ideally for Windows need to log SEH exception instead or to set SEH + // handlers but bugsplat shows local variables for windows, which should + // be enough + LL_WARNS("Voice") << "voiceControlStateMachine crashed in state " << state << LL_ENDL; + throw; + } +} + +void LLVivoxVoiceClient::voiceControlStateMachine(S32 &coro_state) +{ LL_DEBUGS("Voice") << "starting" << LL_ENDL; mIsCoroutineActive = true; LLCoros::set_consuming(true); U32 retry = 0; - EVoiceControlCoroState coro_state = VOICE_STATE_TP_WAIT; + coro_state = VOICE_STATE_TP_WAIT; do { if (sShuttingDown) { - // Vivox singleton performed the exit, and no longer - // cares about state of coroutine, so just stop + // Vivox singleton performed the exit, logged out, + // cleaned sockets, gateway and no longer cares + // about state of coroutine, so just stop return; } @@ -797,7 +822,7 @@ void LLVivoxVoiceClient::voiceControlCoro() break; case VOICE_STATE_WAIT_FOR_CHANNEL: - waitForChannel(); + waitForChannel(); // todo: split into more states like login/fonts coro_state = VOICE_STATE_DISCONNECT; break; @@ -1865,6 +1890,11 @@ bool LLVivoxVoiceClient::waitForChannel() { retrieveVoiceFonts(); + if (sShuttingDown) + { + return false; + } + // Request the set of available voice fonts. refreshVoiceEffectLists(false); } diff --git a/indra/newview/llvoicevivox.h b/indra/newview/llvoicevivox.h index 4ee0545a72..cf30a4e86a 100644 --- a/indra/newview/llvoicevivox.h +++ b/indra/newview/llvoicevivox.h @@ -626,6 +626,7 @@ private: // Coroutine support methods //--- void voiceControlCoro(); + void voiceControlStateMachine(S32 &coro_state); bool endAndDisconnectSession(); |