From d9f0a587a88373dbe839afd6489bc9a1ca4edeea Mon Sep 17 00:00:00 2001 From: Roxie Linden Date: Wed, 4 Sep 2024 15:45:03 -0700 Subject: Fix some race conditions on connection shutdown. In a few locations, there were cases where connection shutdown would stall, leaving the connection in place. This was due to bad handling of the outstanding operations counter. --- indra/newview/llvoicewebrtc.cpp | 48 ++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 20 deletions(-) (limited to 'indra/newview/llvoicewebrtc.cpp') diff --git a/indra/newview/llvoicewebrtc.cpp b/indra/newview/llvoicewebrtc.cpp index 22b53c0b85..4528b57061 100644 --- a/indra/newview/llvoicewebrtc.cpp +++ b/indra/newview/llvoicewebrtc.cpp @@ -2012,7 +2012,10 @@ bool LLWebRTCVoiceClient::estateSessionState::processConnectionStates() // shut down connections to neighbors that are too far away. spatialConnection.get()->shutDown(); } - neighbor_ids.erase(regionID); + if (!spatialConnection.get()->isShuttingDown()) + { + neighbor_ids.erase(regionID); + } } // add new connections for new neighbors @@ -2512,8 +2515,6 @@ void LLVoiceWebRTCConnection::breakVoiceConnectionCoro(connectionPtr_t connectio httpOpts->setWantHeaders(true); - connection->mOutstandingRequests++; - // tell the server to shut down the connection as a courtesy. // shutdownConnection will drop the WebRTC connection which will // also shut things down. @@ -2544,6 +2545,7 @@ void LLVoiceWebRTCSpatialConnection::requestVoiceConnection() // try again. setVoiceConnectionState(VOICE_STATE_REQUEST_CONNECTION); + mOutstandingRequests--; return; } @@ -2551,6 +2553,7 @@ void LLVoiceWebRTCSpatialConnection::requestVoiceConnection() if (url.empty()) { setVoiceConnectionState(VOICE_STATE_SESSION_RETRY); + mOutstandingRequests--; return; } @@ -2575,7 +2578,6 @@ void LLVoiceWebRTCSpatialConnection::requestVoiceConnection() LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); httpOpts->setWantHeaders(true); - mOutstandingRequests++; LLSD result = httpAdapter->postAndSuspend(httpRequest, url, body, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; @@ -2663,7 +2665,10 @@ bool LLVoiceWebRTCConnection::connectionStateMachine() { LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE; - processIceUpdates(); + if (!mShutDown) + { + processIceUpdates(); + } switch (getVoiceConnectionState()) { @@ -2707,6 +2712,7 @@ bool LLVoiceWebRTCConnection::connectionStateMachine() // a given voice channel. On completion, we'll move on to the // VOICE_STATE_SESSION_ESTABLISHED via a callback on a webrtc thread. setVoiceConnectionState(VOICE_STATE_CONNECTION_WAIT); + mOutstandingRequests++; LLCoros::getInstance()->launch("LLVoiceWebRTCConnection::requestVoiceConnectionCoro", boost::bind(&LLVoiceWebRTCConnection::requestVoiceConnectionCoro, this->shared_from_this())); break; @@ -2757,24 +2763,25 @@ bool LLVoiceWebRTCConnection::connectionStateMachine() case VOICE_STATE_SESSION_UP: { mRetryWaitPeriod = 0; - mRetryWaitSecs = (F32)((F32) rand() / (RAND_MAX)) + 0.5f; - LLUUID agentRegionID; - if (isSpatial() && gAgent.getRegion()) - { - - bool primary = (mRegionID == gAgent.getRegion()->getRegionID()); - if (primary != mPrimary) - { - mPrimary = primary; - sendJoin(); - } - } + mRetryWaitSecs = (F32)((F32)rand() / (RAND_MAX)) + 0.5f; // we'll stay here as long as the session remains up. if (mShutDown) { setVoiceConnectionState(VOICE_STATE_DISCONNECT); } + else + { + if (isSpatial() && gAgent.getRegion()) + { + bool primary = (mRegionID == gAgent.getRegion()->getRegionID()); + if (primary != mPrimary) + { + mPrimary = primary; + sendJoin(); + } + } + } break; } @@ -2799,6 +2806,7 @@ bool LLVoiceWebRTCConnection::connectionStateMachine() case VOICE_STATE_DISCONNECT: if (!LLWebRTCVoiceClient::isShuttingDown()) { + mOutstandingRequests++; setVoiceConnectionState(VOICE_STATE_WAIT_FOR_EXIT); LLCoros::instance().launch("LLVoiceWebRTCConnection::breakVoiceConnectionCoro", boost::bind(&LLVoiceWebRTCConnection::breakVoiceConnectionCoro, this->shared_from_this())); @@ -2807,7 +2815,6 @@ bool LLVoiceWebRTCConnection::connectionStateMachine() { // llwebrtc::terminate() is already shuting down the connection. setVoiceConnectionState(VOICE_STATE_WAIT_FOR_CLOSE); - mOutstandingRequests++; } break; @@ -3051,7 +3058,6 @@ void LLVoiceWebRTCConnection::sendJoin() boost::json::object root; boost::json::object join_obj; - LLUUID regionID = gAgent.getRegion()->getRegionID(); if (mPrimary) { join_obj["p"] = true; @@ -3134,6 +3140,7 @@ void LLVoiceWebRTCAdHocConnection::requestVoiceConnection() LL_DEBUGS("Voice") << "no capabilities for voice provisioning; retrying " << LL_ENDL; // try again. setVoiceConnectionState(VOICE_STATE_REQUEST_CONNECTION); + mOutstandingRequests--; return; } @@ -3141,6 +3148,7 @@ void LLVoiceWebRTCAdHocConnection::requestVoiceConnection() if (url.empty()) { setVoiceConnectionState(VOICE_STATE_SESSION_RETRY); + mOutstandingRequests--; return; } @@ -3164,7 +3172,7 @@ void LLVoiceWebRTCAdHocConnection::requestVoiceConnection() LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); httpOpts->setWantHeaders(true); - mOutstandingRequests++; + LLSD result = httpAdapter->postAndSuspend(httpRequest, url, body, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; -- cgit v1.2.3 From 5f99c475dc89bd6293d157e85ad67cf6c832f578 Mon Sep 17 00:00:00 2001 From: Roxie Linden Date: Mon, 9 Sep 2024 15:12:40 -0700 Subject: Voice bars of self and as seen by others do not appear the same. The voice server sends up the float power level of peers as an integer multiplied by 128, in order to save character count as the voice power level will likely be only 3 digits, instead of many for a full float. The client was not taking this into account. --- indra/newview/llvoicewebrtc.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/newview/llvoicewebrtc.cpp') diff --git a/indra/newview/llvoicewebrtc.cpp b/indra/newview/llvoicewebrtc.cpp index 4528b57061..7de8cf9cb1 100644 --- a/indra/newview/llvoicewebrtc.cpp +++ b/indra/newview/llvoicewebrtc.cpp @@ -2983,7 +2983,9 @@ void LLVoiceWebRTCConnection::OnDataReceivedImpl(const std::string &data, bool b // we got a 'power' update. if (participant_obj.contains("p") && participant_obj["p"].is_number()) { - participant->mLevel = (F32)participant_obj["p"].as_int64(); + // server sends up power as an integer which is level * 128 to save + // character count. + participant->mLevel = (F32)participant_obj["p"].as_int64()/128.0f; } if (participant_obj.contains("v") && participant_obj["v"].is_bool()) -- cgit v1.2.3 From 44e1be64e0a212fb77cc6ef4664d444242d62e67 Mon Sep 17 00:00:00 2001 From: Roxie Linden Date: Tue, 10 Sep 2024 11:53:54 -0700 Subject: mute icons were not showing during group call when user was muted This fixes: https://github.com/secondlife/viewer-private/issues/285 When processing messages from the voice server, the volume and not the mute status was being checked with respect to retrieving the mute status. --- indra/newview/llvoicewebrtc.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/newview/llvoicewebrtc.cpp') diff --git a/indra/newview/llvoicewebrtc.cpp b/indra/newview/llvoicewebrtc.cpp index 7de8cf9cb1..31d9574f38 100644 --- a/indra/newview/llvoicewebrtc.cpp +++ b/indra/newview/llvoicewebrtc.cpp @@ -2993,10 +2993,9 @@ void LLVoiceWebRTCConnection::OnDataReceivedImpl(const std::string &data, bool b participant->mIsSpeaking = participant_obj["v"].as_bool(); } - if (participant_obj.contains("v") && participant_obj["m"].is_bool()) + if (participant_obj.contains("m") && participant_obj["m"].is_bool()) { participant->mIsModeratorMuted = participant_obj["m"].as_bool(); - ; } } } -- cgit v1.2.3 From f78b43bd1d4a96db32a64e18d88c3768531ceee8 Mon Sep 17 00:00:00 2001 From: Roxie Linden Date: Wed, 11 Sep 2024 15:58:56 -0700 Subject: Fix issue with improper reporting as to whether voice is working. This fixes #1436, an issue where the 'call button' sometimes got greyed out when it shouldn't have been. Vivox is now 'working' (and the call button can be enabled) when it's logged in. WebRTC is 'working' (and the call button can be enabled) when the coroutine is active. --- indra/newview/llvoicewebrtc.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'indra/newview/llvoicewebrtc.cpp') diff --git a/indra/newview/llvoicewebrtc.cpp b/indra/newview/llvoicewebrtc.cpp index 7de8cf9cb1..4084e5ab76 100644 --- a/indra/newview/llvoicewebrtc.cpp +++ b/indra/newview/llvoicewebrtc.cpp @@ -420,7 +420,7 @@ void LLWebRTCVoiceClient::notifyStatusObservers(LLVoiceClientStatusObserver::ESt status != LLVoiceClientStatusObserver::STATUS_LEFT_CHANNEL && status != LLVoiceClientStatusObserver::STATUS_VOICE_DISABLED) { - bool voice_status = LLVoiceClient::getInstance()->voiceEnabled() && LLVoiceClient::getInstance()->isVoiceWorking(); + bool voice_status = LLVoiceClient::getInstance()->voiceEnabled() && mIsProcessingChannels; gAgent.setVoiceConnected(voice_status); @@ -1335,7 +1335,10 @@ bool LLWebRTCVoiceClient::startAdHocSession(const LLSD& channelInfo, bool notify bool LLWebRTCVoiceClient::isVoiceWorking() const { - return mIsProcessingChannels; + // webrtc is working if the coroutine is active in the case of + // webrtc. WebRTC doesn't need to connect to a secondary process + // or a login server to become active. + return mIsCoroutineActive; } // Returns true if calling back the session URI after the session has closed is possible. -- cgit v1.2.3 From 52091a6097cd4e68f3fc1b0972080867ceb09122 Mon Sep 17 00:00:00 2001 From: Roxie Linden Date: Wed, 18 Sep 2024 13:01:43 -0700 Subject: Mute other / set volume level for other is not working. As part of the boost::json conversion, the json that mutes and sets peer gain was not being formed correctly. Also, tweaked the peer gain default. --- indra/newview/llvoicewebrtc.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'indra/newview/llvoicewebrtc.cpp') diff --git a/indra/newview/llvoicewebrtc.cpp b/indra/newview/llvoicewebrtc.cpp index 3d684e5a1b..aabf897050 100644 --- a/indra/newview/llvoicewebrtc.cpp +++ b/indra/newview/llvoicewebrtc.cpp @@ -87,6 +87,8 @@ namespace { const F32 SPEAKING_AUDIO_LEVEL = 0.30; + const uint32_t PEER_GAIN_CONVERSION_FACTOR = 220; + static const std::string REPORTED_VOICE_SERVER_TYPE = "Secondlife WebRTC Gateway"; // Don't send positional updates more frequently than this: @@ -2443,7 +2445,7 @@ void LLVoiceWebRTCConnection::setSpeakerVolume(F32 volume) void LLVoiceWebRTCConnection::setUserVolume(const LLUUID& id, F32 volume) { - boost::json::object root = {{"ug", {id.asString(), (uint32_t) (volume * 200)}}}; + boost::json::object root = { { "ug", { { id.asString(), (uint32_t)(volume * PEER_GAIN_CONVERSION_FACTOR) } } } }; std::string json_data = boost::json::serialize(root); if (mWebRTCDataInterface) { @@ -2453,7 +2455,7 @@ void LLVoiceWebRTCConnection::setUserVolume(const LLUUID& id, F32 volume) void LLVoiceWebRTCConnection::setUserMute(const LLUUID& id, bool mute) { - boost::json::object root = {{"m", {id.asString(), mute}}}; + boost::json::object root = { { "m", { { id.asString(), mute } } } }; std::string json_data = boost::json::serialize(root); if (mWebRTCDataInterface) { -- cgit v1.2.3 From 743a1a6d8eabf069d95777c96e5b657cb8702593 Mon Sep 17 00:00:00 2001 From: Roxie Linden Date: Wed, 18 Sep 2024 14:14:26 -0700 Subject: fix trailing whitespace --- indra/newview/llvoicewebrtc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llvoicewebrtc.cpp') diff --git a/indra/newview/llvoicewebrtc.cpp b/indra/newview/llvoicewebrtc.cpp index aabf897050..ad8f6927ed 100644 --- a/indra/newview/llvoicewebrtc.cpp +++ b/indra/newview/llvoicewebrtc.cpp @@ -2445,7 +2445,7 @@ void LLVoiceWebRTCConnection::setSpeakerVolume(F32 volume) void LLVoiceWebRTCConnection::setUserVolume(const LLUUID& id, F32 volume) { - boost::json::object root = { { "ug", { { id.asString(), (uint32_t)(volume * PEER_GAIN_CONVERSION_FACTOR) } } } }; + boost::json::object root = { { "ug", { { id.asString(), (uint32_t)(volume * PEER_GAIN_CONVERSION_FACTOR) } } } }; std::string json_data = boost::json::serialize(root); if (mWebRTCDataInterface) { -- cgit v1.2.3