From fa61272bd4741f786b86c22db273c7b0a5f16924 Mon Sep 17 00:00:00 2001
From: Oz Linden <oz@lindenlab.com>
Date: Mon, 13 Mar 2017 10:08:18 -0400
Subject: [PATCH] clean up use of mVoiceEnabled (rename the session member
 mVoiceActive)

---
 indra/newview/llvoiceclient.cpp |  5 ++++-
 indra/newview/llvoicevivox.cpp  | 25 ++++++++++---------------
 indra/newview/llvoicevivox.h    |  2 +-
 3 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/indra/newview/llvoiceclient.cpp b/indra/newview/llvoiceclient.cpp
index 5c125a236a..26f172171a 100644
--- a/indra/newview/llvoiceclient.cpp
+++ b/indra/newview/llvoiceclient.cpp
@@ -519,7 +519,10 @@ bool LLVoiceClient::voiceEnabled()
 
 void LLVoiceClient::setVoiceEnabled(bool enabled)
 {
-	if (mVoiceModule) mVoiceModule->setVoiceEnabled(enabled);
+	if (mVoiceModule)
+    {
+        mVoiceModule->setVoiceEnabled(enabled);
+    }
 }
 
 void LLVoiceClient::updateMicMuteLogic()
diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp
index dd01727bfe..6cc462290b 100644
--- a/indra/newview/llvoicevivox.cpp
+++ b/indra/newview/llvoicevivox.cpp
@@ -311,7 +311,7 @@ LLVivoxVoiceClient::LLVivoxVoiceClient() :
 	mMicVolume(0),
 	mMicVolumeDirty(true),
 
-	mVoiceEnabled(false),
+	mVoiceEnabled(voiceEnabled()),
 	mWriteInProgress(false),
 
 	mLipSyncEnabled(false),
@@ -425,7 +425,7 @@ const LLVoiceVersionInfo& LLVivoxVoiceClient::getVersion()
 
 void LLVivoxVoiceClient::updateSettings()
 {
-	setVoiceEnabled(gSavedSettings.getBOOL("EnableVoiceChat"));
+    setVoiceEnabled(voiceEnabled());
 	setEarLocation(gSavedSettings.getS32("VoiceEarLocation"));
 
 	std::string inputDevice = gSavedSettings.getString("VoiceInputAudioDevice");
@@ -677,6 +677,8 @@ void LLVivoxVoiceClient::voiceControlCoro()
 bool LLVivoxVoiceClient::startAndConnectSession()
 {
     bool ok = false;
+    LL_DEBUGS("Voice") << LL_ENDL;
+
     LLVoiceVivoxStats::getInstance()->reset();
 
     if (startAndLaunchDaemon())
@@ -1004,11 +1006,6 @@ bool LLVivoxVoiceClient::establishVoiceConnection()
         LLNotificationsUtil::add("NoVoiceConnect", args);
     }
 
-//    if (!mVoiceEnabled && mIsInitialized)
-//    {
-//        connected = false;
-//    }
-
     return connected;
 }
 
@@ -1067,10 +1064,9 @@ bool LLVivoxVoiceClient::loginToVivox()
         if (send_login)
         {
             loginSendMessage();
+            send_login = false;
         }
         
-        send_login = false;
-
         LLSD result = llcoro::suspendUntilEventOnWithTimeout(voicePump, LOGIN_ATTEMPT_TIMEOUT, timeoutResult);
         LL_DEBUGS("Voice") << "event=" << ll_stream_notation_sd(result) << LL_ENDL;
 
@@ -1593,7 +1589,7 @@ bool LLVivoxVoiceClient::waitForChannel()
             }
             else if (sessionNeedsRelog(mNextAudioSession))
             {
-                LL_DEBUGS("Voice") << "Session requesting reprovision and login." << LL_ENDL;
+                LL_INFOS("Voice") << "Session requesting reprovision and login." << LL_ENDL;
                 requestRelog();
                 break;
             }
@@ -3160,7 +3156,7 @@ void LLVivoxVoiceClient::sessionConnectResponse(std::string &requestId, int stat
 	// set the session info to reflect that the user is already connected.
 	if (statusCode == 1026)
 	{
-		session->mVoiceEnabled = true;
+		session->mVoiceActive = true;
 		session->mMediaConnectInProgress = false;
 		session->mMediaStreamState = streamStateConnected;
 		//session->mTextStreamState = streamStateConnected;
@@ -3585,13 +3581,13 @@ void LLVivoxVoiceClient::mediaStreamUpdatedEvent(
 		case streamStateDisconnecting:
 		case streamStateIdle:
 				// Standard "left audio session", Vivox state 'disconnected'
-				session->mVoiceEnabled = false;
+				session->mVoiceActive = false;
 				session->mMediaConnectInProgress = false;
 				leftAudioSession(session);
 			break;
 
 			case streamStateConnected:
-				session->mVoiceEnabled = true;
+				session->mVoiceActive = true;
 				session->mMediaConnectInProgress = false;
 				joinedAudioSession(session);
 			case streamStateConnecting: // do nothing, but prevents a warning getting into the logs.  
@@ -4942,7 +4938,6 @@ void LLVivoxVoiceClient::setVoiceEnabled(bool enabled)
 		mVoiceEnabled = enabled;
 		LLVoiceClientStatusObserver::EStatusType status;
 		
-		
 		if (enabled)
 		{
 			LLVoiceChannel::getCurrentVoiceChannel()->activate();
@@ -5309,7 +5304,7 @@ LLVivoxVoiceClient::sessionState::sessionState() :
     mIsSpatial(false),
     mIsP2P(false),
     mIncoming(false),
-    mVoiceEnabled(false),
+    mVoiceActive(false),
     mReconnect(false),
     mVolumeDirty(false),
     mMuteDirty(false),
diff --git a/indra/newview/llvoicevivox.h b/indra/newview/llvoicevivox.h
index f8de363352..dd146033f8 100644
--- a/indra/newview/llvoicevivox.h
+++ b/indra/newview/llvoicevivox.h
@@ -351,7 +351,7 @@ protected:
 		bool		mIsSpatial;	// True for spatial channels
 		bool		mIsP2P;
 		bool		mIncoming;
-		bool		mVoiceEnabled;
+		bool		mVoiceActive;
 		bool		mReconnect;	// Whether we should try to reconnect to this session if it's dropped
 
 		// Set to true when the volume/mute state of someone in the participant list changes.
-- 
GitLab