summaryrefslogtreecommitdiff
path: root/indra
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
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')
-rw-r--r--indra/newview/llvoicewebrtc.cpp68
-rw-r--r--indra/newview/llvoicewebrtc.h11
2 files changed, 47 insertions, 32 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
diff --git a/indra/newview/llvoicewebrtc.h b/indra/newview/llvoicewebrtc.h
index 67e4a4ea6f..af1efa5fe5 100644
--- a/indra/newview/llvoicewebrtc.h
+++ b/indra/newview/llvoicewebrtc.h
@@ -228,7 +228,7 @@ public:
struct participantState
{
public:
- participantState(const LLUUID& agent_id);
+ participantState(const LLUUID& agent_id, const LLUUID& region);
bool isAvatar();
@@ -240,12 +240,13 @@ public:
F32 mVolume; // the gain applied to the participant
bool mIsSpeaking;
bool mIsModeratorMuted;
+ LLUUID mRegion;
};
typedef boost::shared_ptr<participantState> participantStatePtr_t;
participantStatePtr_t findParticipantByID(const std::string &channelID, const LLUUID &id);
- participantStatePtr_t addParticipantByID(const std::string& channelID, const LLUUID &id);
- void removeParticipantByID(const std::string& channelID, const LLUUID &id);
+ participantStatePtr_t addParticipantByID(const std::string& channelID, const LLUUID &id, const LLUUID& region);
+ void removeParticipantByID(const std::string& channelID, const LLUUID &id, const LLUUID& region);
protected:
@@ -262,9 +263,9 @@ public:
static void addSession(const std::string &channelID, ptr_t& session);
virtual ~sessionState();
- participantStatePtr_t addParticipant(const LLUUID& agent_id);
+ participantStatePtr_t addParticipant(const LLUUID& agent_id, const LLUUID& region);
void removeParticipant(const participantStatePtr_t &participant);
- void removeAllParticipants();
+ void removeAllParticipants(const LLUUID& region = LLUUID());
participantStatePtr_t findParticipantByID(const LLUUID& id);