diff options
author | Andrey Lihatskiy <alihatskiy@productengine.com> | 2020-09-22 22:55:00 +0300 |
---|---|---|
committer | Andrey Lihatskiy <alihatskiy@productengine.com> | 2020-09-22 23:30:12 +0300 |
commit | 825cfc2b6a2711bdf8b4a3360f379d5fa628a421 (patch) | |
tree | d58fd5b2afcf160491016d6d4db180b4aa3aff93 /indra/newview/llvoicevivox.cpp | |
parent | 53421626c5da4f976429e0b19f760a1ad1cb26cb (diff) | |
parent | 60ed688026269568a9eef67437dc780f88c92871 (diff) |
Merge branch 'master' into DRTVWR-507-maint
# Conflicts:
# doc/contributions.txt
# indra/newview/llfloaterconversationpreview.cpp
# indra/newview/llinventorypanel.h
# indra/newview/llmeshrepository.h
# indra/newview/llvoicevivox.cpp
Diffstat (limited to 'indra/newview/llvoicevivox.cpp')
-rw-r--r-- | indra/newview/llvoicevivox.cpp | 82 |
1 files changed, 50 insertions, 32 deletions
diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index a2c2a8629e..1ff955644c 100644 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -274,6 +274,8 @@ static void killGateway() /////////////////////////////////////////////////////////////////////////////////////////////// +bool LLVivoxVoiceClient::sShuttingDown = false; + LLVivoxVoiceClient::LLVivoxVoiceClient() : mSessionTerminateRequested(false), mRelogRequested(false), @@ -381,6 +383,7 @@ LLVivoxVoiceClient::~LLVivoxVoiceClient() { mAvatarNameCacheConnection.disconnect(); } + sShuttingDown = true; } //--------------------------------------------------- @@ -411,8 +414,11 @@ void LLVivoxVoiceClient::terminate() } else { + mRelogRequested = false; killGateway(); } + + sShuttingDown = true; } //--------------------------------------------------- @@ -660,12 +666,18 @@ void LLVivoxVoiceClient::voiceControlCoro() U32 retry = 0; - while (gAgent.getTeleportState() != LLAgent::TELEPORT_NONE) + while (gAgent.getTeleportState() != LLAgent::TELEPORT_NONE && !sShuttingDown) { LL_DEBUGS("Voice") << "Suspending voiceControlCoro() momentarily for teleport. Tuning: " << mTuningMode << ". Relog: " << mRelogRequested << LL_ENDL; llcoro::suspendUntilTimeout(1.0); } + if (sShuttingDown) + { + mIsCoroutineActive = false; + return; + } + do { bool success = startAndConnectSession(); @@ -691,7 +703,7 @@ void LLVivoxVoiceClient::voiceControlCoro() << "disconnected" << " RelogRequested=" << mRelogRequested << LL_ENDL; - if (mRelogRequested) + if (mRelogRequested && !sShuttingDown) { if (!success) { @@ -706,14 +718,14 @@ void LLVivoxVoiceClient::voiceControlCoro() LL_INFOS("Voice") << "will attempt to reconnect to voice" << LL_ENDL; } - while (isGatewayRunning() || gAgent.getTeleportState() != LLAgent::TELEPORT_NONE) + while (isGatewayRunning() || (gAgent.getTeleportState() != LLAgent::TELEPORT_NONE && !sShuttingDown)) { LL_INFOS("Voice") << "waiting for SLVoice to exit" << LL_ENDL; llcoro::suspendUntilTimeout(1.0); } } } - while (mVoiceEnabled && mRelogRequested); + while (mVoiceEnabled && mRelogRequested && !sShuttingDown); mIsCoroutineActive = false; LL_INFOS("Voice") << "exiting" << LL_ENDL; } @@ -758,7 +770,7 @@ bool LLVivoxVoiceClient::endAndDisconnectSession() bool LLVivoxVoiceClient::callbackEndDaemon(const LLSD& data) { - if (!LLAppViewer::isExiting() && mVoiceEnabled) + if (!sShuttingDown && mVoiceEnabled) { LL_WARNS("Voice") << "SLVoice terminated " << ll_stream_notation_sd(data) << LL_ENDL; terminateAudioSession(false); @@ -912,12 +924,10 @@ bool LLVivoxVoiceClient::startAndLaunchDaemon() //--------------------------------------------------------------------- llcoro::suspendUntilTimeout(UPDATE_THROTTLE_SECONDS); - bool quiting = LLAppViewer::isExiting(); - LL_DEBUGS("Voice") << "Connecting to vivox daemon:" << mDaemonHost << LL_ENDL; LLVoiceVivoxStats::getInstance()->reset(); - while (!mConnected && !quiting) + while (!mConnected && !sShuttingDown) { LLVoiceVivoxStats::getInstance()->connectionAttemptStart(); LL_DEBUGS("Voice") << "Attempting to connect to vivox daemon: " << mDaemonHost << LL_ENDL; @@ -932,12 +942,11 @@ bool LLVivoxVoiceClient::startAndLaunchDaemon() if (!mConnected) { llcoro::suspendUntilTimeout(DAEMON_CONNECT_THROTTLE_SECONDS); - quiting = LLAppViewer::isExiting(); } } //--------------------------------------------------------------------- - if (quiting && !mConnected) + if (sShuttingDown && !mConnected) { return false; } @@ -978,13 +987,11 @@ bool LLVivoxVoiceClient::provisionVoiceAccount() { LL_INFOS("Voice") << "Provisioning voice account." << LL_ENDL; - bool quiting = LLApp::isExiting(); - while ((!gAgent.getRegion() || !gAgent.getRegion()->capabilitiesReceived()) && !quiting) + while ((!gAgent.getRegion() || !gAgent.getRegion()->capabilitiesReceived()) && !sShuttingDown) { LL_DEBUGS("Voice") << "no capabilities for voice provisioning; waiting " << LL_ENDL; // *TODO* Pump a message for wake up. llcoro::suspend(); - quiting = LLApp::isExiting(); } std::string url = gAgent.getRegionCapability("ProvisionVoiceAccountRequest"); @@ -1004,7 +1011,6 @@ bool LLVivoxVoiceClient::provisionVoiceAccount() { LLVoiceVivoxStats::getInstance()->provisionAttemptStart(); result = httpAdapter->postAndSuspend(httpRequest, url, LLSD(), httpOpts); - quiting = LLApp::isExiting(); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -1014,7 +1020,6 @@ bool LLVivoxVoiceClient::provisionVoiceAccount() F32 timeout = pow(PROVISION_RETRY_TIMEOUT, static_cast<float>(retryCount)); LL_WARNS("Voice") << "Provision CAP 404. Retrying in " << timeout << " seconds." << LL_ENDL; llcoro::suspendUntilTimeout(timeout); - quiting = LLApp::isExiting(); } else if (!status) { @@ -1026,9 +1031,9 @@ bool LLVivoxVoiceClient::provisionVoiceAccount() { provisioned = true; } - } while (!provisioned && retryCount <= PROVISION_RETRY_MAX && !quiting); + } while (!provisioned && retryCount <= PROVISION_RETRY_MAX && !sShuttingDown); - if (quiting && !provisioned) + if (sShuttingDown && !provisioned) { return false; } @@ -1075,11 +1080,15 @@ bool LLVivoxVoiceClient::establishVoiceConnection() LL_WARNS("Voice") << "cannot establish connection; enabled "<<mVoiceEnabled<<" initialized "<<mIsInitialized<<LL_ENDL; return false; } + + if (sShuttingDown) + { + return false; + } LLSD result; bool connected(false); bool giving_up(false); - bool quiting = LLApp::isExiting(); int retries = 0; LL_INFOS("Voice") << "Requesting connection to voice service" << LL_ENDL; @@ -1088,7 +1097,6 @@ bool LLVivoxVoiceClient::establishVoiceConnection() do { result = llcoro::suspendUntilEventOn(mVivoxPump); - quiting = LLApp::isExiting(); LL_DEBUGS("Voice") << "event=" << ll_stream_notation_sd(result) << LL_ENDL; if (result.has("connector")) @@ -1097,7 +1105,7 @@ bool LLVivoxVoiceClient::establishVoiceConnection() connected = LLSD::Boolean(result["connector"]); if (!connected) { - if (result.has("retry") && ++retries <= CONNECT_RETRY_MAX && !quiting) + if (result.has("retry") && ++retries <= CONNECT_RETRY_MAX && !sShuttingDown) { F32 timeout = LLSD::Real(result["retry"]); timeout *= retries; @@ -1126,7 +1134,7 @@ bool LLVivoxVoiceClient::establishVoiceConnection() LL_DEBUGS("Voice") << (connected ? "" : "not ") << "connected, " << (giving_up ? "" : "not ") << "giving up" << LL_ENDL; - } while (!connected && !giving_up && !quiting); + } while (!connected && !giving_up && !sShuttingDown); if (giving_up) { @@ -1196,7 +1204,6 @@ bool LLVivoxVoiceClient::loginToVivox() bool response_ok(false); bool account_login(false); bool send_login(true); - bool quiting = LLApp::isExiting(); do { @@ -1208,14 +1215,13 @@ bool LLVivoxVoiceClient::loginToVivox() } LLSD result = llcoro::suspendUntilEventOnWithTimeout(mVivoxPump, LOGIN_ATTEMPT_TIMEOUT, timeoutResult); - quiting = LLApp::isExiting(); LL_DEBUGS("Voice") << "event=" << ll_stream_notation_sd(result) << LL_ENDL; if (result.has("login")) { std::string loginresp = result["login"]; - if (((loginresp == "retry") || (loginresp == "timeout")) && !quiting) + if (((loginresp == "retry") || (loginresp == "timeout")) && !sShuttingDown) { LL_WARNS("Voice") << "login failed with status '" << loginresp << "' " << " count " << loginRetryCount << "/" << LOGIN_RETRY_MAX @@ -1243,7 +1249,6 @@ bool LLVivoxVoiceClient::loginToVivox() LL_WARNS("Voice") << "login " << loginresp << " will retry login in " << timeout << " seconds." << LL_ENDL; llcoro::suspendUntilTimeout(timeout); - quiting = LLApp::isExiting(); } else if (loginresp == "failed") { @@ -1258,14 +1263,14 @@ bool LLVivoxVoiceClient::loginToVivox() { account_login = true; } - else if (quiting) + else if (sShuttingDown) { mIsLoggingIn = false; return false; } } - } while ((!response_ok || !account_login) && !quiting); + } while ((!response_ok || !account_login) && !sShuttingDown); mRelogRequested = false; mIsLoggedIn = true; @@ -1718,12 +1723,12 @@ bool LLVivoxVoiceClient::terminateAudioSession(bool wait) // the region chat. mSessionTerminateRequested = false; - bool status=((mVoiceEnabled || !mIsInitialized) && !mRelogRequested && !LLApp::isExiting()); + bool status=((mVoiceEnabled || !mIsInitialized) && !mRelogRequested && !sShuttingDown); LL_DEBUGS("Voice") << "exiting" << " VoiceEnabled " << mVoiceEnabled << " IsInitialized " << mIsInitialized << " RelogRequested " << mRelogRequested - << " AppExiting " << LLApp::isExiting() + << " ShuttingDown " << (sShuttingDown ? "TRUE" : "FALSE") << " returning " << status << LL_ENDL; return status; @@ -1761,6 +1766,12 @@ bool LLVivoxVoiceClient::waitForChannel() mIsProcessingChannels = true; llcoro::suspend(); + if (sShuttingDown) + { + mRelogRequested = false; + break; + } + if (mTuningMode) { performMicTuning(); @@ -1805,7 +1816,14 @@ bool LLVivoxVoiceClient::waitForChannel() { llcoro::suspendUntilTimeout(1.0); } - } while (mVoiceEnabled && !mRelogRequested); + + if (sShuttingDown) + { + mRelogRequested = false; + break; + } + + } while (mVoiceEnabled && !mRelogRequested && !sShuttingDown); LL_DEBUGS("Voice") << "leaving inner waitForChannel loop" @@ -1827,14 +1845,14 @@ bool LLVivoxVoiceClient::waitForChannel() return false; } } - } while (mVoiceEnabled && mRelogRequested && isGatewayRunning()); + } while (mVoiceEnabled && mRelogRequested && isGatewayRunning() && !sShuttingDown); LL_DEBUGS("Voice") << "exiting" << " RelogRequested=" << mRelogRequested << " VoiceEnabled=" << mVoiceEnabled << LL_ENDL; - return true; + return !sShuttingDown; } bool LLVivoxVoiceClient::runSession(const sessionStatePtr_t &session) |