summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2021-08-18 22:27:19 +0300
committerAndrey Kleshchev <andreykproductengine@lindenlab.com>2021-08-18 22:36:11 +0300
commitf6b831a8a73469ce031334219c69bc538dfb92ea (patch)
tree74923c7fa27c50bb08ce5105b627aeaa27528738 /indra/newview
parentc5ee0de58a7d363e514f3a1a76f7c6957200917c (diff)
SL-15462 Refactor voiceControlCoro() into a state machine #2
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llvoicevivox.cpp38
-rw-r--r--indra/newview/llvoicevivox.h1
2 files changed, 35 insertions, 4 deletions
diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp
index aebdde8150..04e649e958 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();