summaryrefslogtreecommitdiff
path: root/indra/newview/llvoicewebrtc.cpp
diff options
context:
space:
mode:
authorRoxie Linden <roxie@lindenlab.com>2024-04-30 11:45:21 -0700
committerRoxie Linden <roxie@lindenlab.com>2024-04-30 11:45:21 -0700
commit2c503997204043fcd24d70854799509c0675d76d (patch)
tree0aff42953b5ec5a873fa5a30f4dc0f62240d3639 /indra/newview/llvoicewebrtc.cpp
parent57182b2ac01007d3d5d11c98e811e05d2c50405c (diff)
Remove voice participants for a connection when shutting it down.
When teleporting or moving around, connections to regions are shut down. We need to track which participants are associated with the given connections and remove those participants when the connection is shut down.
Diffstat (limited to 'indra/newview/llvoicewebrtc.cpp')
-rw-r--r--indra/newview/llvoicewebrtc.cpp68
1 files changed, 41 insertions, 27 deletions
diff --git a/indra/newview/llvoicewebrtc.cpp b/indra/newview/llvoicewebrtc.cpp
index 87106ba6d5..2bd6eee84d 100644
--- a/indra/newview/llvoicewebrtc.cpp
+++ b/indra/newview/llvoicewebrtc.cpp
@@ -810,9 +810,12 @@ void LLWebRTCVoiceClient::OnConnectionEstablished(const std::string &channelID,
}
mSession = mNextSession;
mNextSession.reset();
+ }
+ if (mSession)
+ {
// Add ourselves as a participant.
- mSession->addParticipant(gAgentID);
+ mSession->addParticipant(gAgentID, gAgent.getRegion()->getRegionID());
}
// The current session was established.
@@ -833,14 +836,19 @@ void LLWebRTCVoiceClient::OnConnectionEstablished(const std::string &channelID,
void LLWebRTCVoiceClient::OnConnectionShutDown(const std::string &channelID, const LLUUID &regionID)
{
- if (gAgent.getRegion()->getRegionID() == regionID)
+ if (mSession && (mSession->mChannelID == channelID))
{
- if (mSession && mSession->mChannelID == channelID)
+ if (gAgent.getRegion()->getRegionID() == regionID)
{
- LL_DEBUGS("Voice") << "Main WebRTC Connection Shut Down." << LL_ENDL;
+ if (mSession && mSession->mChannelID == channelID)
+ {
+ LL_DEBUGS("Voice") << "Main WebRTC Connection Shut Down." << LL_ENDL;
+ }
}
+ mSession->removeAllParticipants(regionID);
}
}
+
void LLWebRTCVoiceClient::OnConnectionFailure(const std::string &channelID,
const LLUUID &regionID,
LLVoiceClientStatusObserver::EStatusType status_type)
@@ -1092,13 +1100,13 @@ LLWebRTCVoiceClient::participantStatePtr_t LLWebRTCVoiceClient::findParticipantB
return result;
}
-LLWebRTCVoiceClient::participantStatePtr_t LLWebRTCVoiceClient::addParticipantByID(const std::string &channelID, const LLUUID &id)
+LLWebRTCVoiceClient::participantStatePtr_t LLWebRTCVoiceClient::addParticipantByID(const std::string &channelID, const LLUUID &id, const LLUUID& region)
{
participantStatePtr_t result;
LLWebRTCVoiceClient::sessionState::ptr_t session = sessionState::matchSessionByChannelID(channelID);
if (session)
{
- result = session->addParticipant(id);
+ result = session->addParticipant(id, region);
if (session->mNotifyOnFirstJoin && (id != gAgentID))
{
notifyStatusObservers(LLVoiceClientStatusObserver::STATUS_JOINED);
@@ -1107,7 +1115,7 @@ LLWebRTCVoiceClient::participantStatePtr_t LLWebRTCVoiceClient::addParticipantBy
return result;
}
-void LLWebRTCVoiceClient::removeParticipantByID(const std::string &channelID, const LLUUID &id)
+void LLWebRTCVoiceClient::removeParticipantByID(const std::string &channelID, const LLUUID &id, const LLUUID& region)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE
@@ -1116,7 +1124,7 @@ void LLWebRTCVoiceClient::removeParticipantByID(const std::string &channelID, co
if (session)
{
participantStatePtr_t participant = session->findParticipantByID(id);
- if (participant)
+ if (participant && (participant->mRegion == region))
{
session->removeParticipant(participant);
}
@@ -1125,17 +1133,18 @@ void LLWebRTCVoiceClient::removeParticipantByID(const std::string &channelID, co
// participantState level participant management
-LLWebRTCVoiceClient::participantState::participantState(const LLUUID& agent_id) :
+LLWebRTCVoiceClient::participantState::participantState(const LLUUID& agent_id, const LLUUID& region) :
mURI(agent_id.asString()),
mAvatarID(agent_id),
mIsSpeaking(false),
mIsModeratorMuted(false),
mLevel(0.f),
- mVolume(LLVoiceClient::VOLUME_DEFAULT)
+ mVolume(LLVoiceClient::VOLUME_DEFAULT),
+ mRegion(region)
{
}
-LLWebRTCVoiceClient::participantStatePtr_t LLWebRTCVoiceClient::sessionState::addParticipant(const LLUUID& agent_id)
+LLWebRTCVoiceClient::participantStatePtr_t LLWebRTCVoiceClient::sessionState::addParticipant(const LLUUID& agent_id, const LLUUID& region)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE
@@ -1147,26 +1156,27 @@ LLWebRTCVoiceClient::participantStatePtr_t LLWebRTCVoiceClient::sessionState::ad
if (iter != mParticipantsByUUID.end())
{
result = iter->second;
+ result->mRegion = region;
}
- if(!result)
+ if (!result)
{
// participant isn't already in one list or the other.
- result.reset(new participantState(agent_id));
+ result.reset(new participantState(agent_id, region));
mParticipantsByUUID.insert(participantUUIDMap::value_type(agent_id, result));
- result->mAvatarID = agent_id;
-
- LLWebRTCVoiceClient::getInstance()->lookupName(agent_id);
+ result->mAvatarID = agent_id;
+ }
- LLSpeakerVolumeStorage::getInstance()->getSpeakerVolume(result->mAvatarID, result->mVolume);
- if (!LLWebRTCVoiceClient::sShuttingDown)
- {
- LLWebRTCVoiceClient::getInstance()->notifyParticipantObservers();
- }
+ LLWebRTCVoiceClient::getInstance()->lookupName(agent_id);
- LL_DEBUGS("Voice") << "Participant \"" << result->mURI << "\" added." << LL_ENDL;
+ LLSpeakerVolumeStorage::getInstance()->getSpeakerVolume(result->mAvatarID, result->mVolume);
+ if (!LLWebRTCVoiceClient::sShuttingDown)
+ {
+ LLWebRTCVoiceClient::getInstance()->notifyParticipantObservers();
}
+ LL_DEBUGS("Voice") << "Participant \"" << result->mURI << "\" added." << LL_ENDL;
+
return result;
}
@@ -1218,13 +1228,17 @@ void LLWebRTCVoiceClient::sessionState::removeParticipant(const LLWebRTCVoiceCli
}
}
-void LLWebRTCVoiceClient::sessionState::removeAllParticipants()
+void LLWebRTCVoiceClient::sessionState::removeAllParticipants(const LLUUID &region)
{
LL_DEBUGS("Voice") << "called" << LL_ENDL;
- while (!mParticipantsByUUID.empty())
+
+ for (auto &&participant : mParticipantsByUUID)
{
- removeParticipant(mParticipantsByUUID.begin()->second);
+ if (region.isNull() || (participant.second->mRegion == region))
+ {
+ removeParticipant(participant.second);
+ }
}
}
@@ -2836,7 +2850,7 @@ void LLVoiceWebRTCConnection::OnDataReceivedImpl(const std::string &data, bool b
new_participant |= joined;
if (!participant && joined && (primary || !isSpatial()))
{
- participant = LLWebRTCVoiceClient::getInstance()->addParticipantByID(mChannelID, agent_id);
+ participant = LLWebRTCVoiceClient::getInstance()->addParticipantByID(mChannelID, agent_id, mRegionID);
}
if (participant)
@@ -2846,7 +2860,7 @@ void LLVoiceWebRTCConnection::OnDataReceivedImpl(const std::string &data, bool b
// an existing participant is leaving.
if (agent_id != gAgentID)
{
- LLWebRTCVoiceClient::getInstance()->removeParticipantByID(mChannelID, agent_id);
+ LLWebRTCVoiceClient::getInstance()->removeParticipantByID(mChannelID, agent_id, mRegionID);
}
}
else