summaryrefslogtreecommitdiff
path: root/indra/newview/llvoiceclient.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llvoiceclient.cpp')
-rw-r--r--indra/newview/llvoiceclient.cpp71
1 files changed, 53 insertions, 18 deletions
diff --git a/indra/newview/llvoiceclient.cpp b/indra/newview/llvoiceclient.cpp
index f3bfc2e86c..5ba13efca2 100644
--- a/indra/newview/llvoiceclient.cpp
+++ b/indra/newview/llvoiceclient.cpp
@@ -102,6 +102,13 @@ const F32 UPDATE_THROTTLE_SECONDS = 0.1f;
const F32 LOGIN_RETRY_SECONDS = 10.0f;
const int MAX_LOGIN_RETRIES = 12;
+// Defines the maximum number of times(in a row) "stateJoiningSession" case for spatial channel is reached in stateMachine()
+// which is treated as normal. If this number is exceeded we suspect there is a problem with connection
+// to voice server (EXT-4313). When voice works correctly, there is from 1 to 15 times. 50 was chosen
+// to make sure we don't make mistake when slight connection problems happen- situation when connection to server is
+// blocked is VERY rare and it's better to sacrifice response time in this situation for the sake of stability.
+const int MAX_NORMAL_JOINING_SPATIAL_NUM = 50;
+
static void setUUIDFromStringHash(LLUUID &uuid, const std::string &str)
{
LLMD5 md5_uuid;
@@ -1115,10 +1122,9 @@ public:
* Gets stored external (vivox) volume level for specified speaker and
* transforms it into internal (viewer) level.
*
- * If specified user is not found default level will be returned. It is equivalent of
- * external level 0.5 from the 0.0..1.0 range.
+ * If specified user is not found -1 will be returned.
* Internal level is calculated as: internal = 400 * external^2
- * Maps 0.0 to 1.0 to internal values 0-400 with default 0.5 == 100
+ * Maps 0.0 to 1.0 to internal values 0-400
*
* @param[in] speaker_id - LLUUID of user to get his volume level
*/
@@ -1157,9 +1163,8 @@ void LLSpeakerVolumeStorage::storeSpeakerVolume(const LLUUID& speaker_id, F32 vo
S32 LLSpeakerVolumeStorage::getSpeakerVolume(const LLUUID& speaker_id)
{
- // default internal level of user voice.
- const static LLUICachedControl<S32> DEFAULT_INTERNAL_VOLUME_LEVEL("VoiceDefaultInternalLevel", 100);
- S32 ret_val = DEFAULT_INTERNAL_VOLUME_LEVEL;
+ // Return value of -1 indicates no level is stored for this speaker
+ S32 ret_val = -1;
speaker_data_map_t::const_iterator it = mSpeakersData.find(speaker_id);
if (it != mSpeakersData.end())
@@ -1223,6 +1228,7 @@ LLVoiceClient::LLVoiceClient() :
mRelogRequested(false),
mConnected(false),
mPump(NULL),
+ mSpatialJoiningNum(0),
mTuningMode(false),
mTuningEnergy(0.0f),
@@ -2225,6 +2231,8 @@ void LLVoiceClient::stateMachine()
//MARK: stateNoChannel
case stateNoChannel:
+
+ mSpatialJoiningNum = 0;
// Do this here as well as inside sendPositionalUpdate().
// Otherwise, if you log in but don't join a proximal channel (such as when your login location has voice disabled), your friends list won't sync.
sendFriendsListUpdates();
@@ -2281,6 +2289,23 @@ void LLVoiceClient::stateMachine()
//MARK: stateJoiningSession
case stateJoiningSession: // waiting for session handle
+
+ // If this is true we have problem with connection to voice server (EXT-4313).
+ // See descriptions of mSpatialJoiningNum and MAX_NORMAL_JOINING_SPATIAL_NUM.
+ if(mSpatialJoiningNum == MAX_NORMAL_JOINING_SPATIAL_NUM)
+ {
+ // Notify observers to let them know there is problem with voice
+ notifyStatusObservers(LLVoiceClientStatusObserver::STATUS_VOICE_DISABLED);
+ llwarns << "There seems to be problem with connection to voice server. Disabling voice chat abilities." << llendl;
+ }
+
+ // Increase mSpatialJoiningNum only for spatial sessions- it's normal to reach this case for
+ // example for p2p many times while waiting for response, so it can't be used to detect errors
+ if(mAudioSession && mAudioSession->mIsSpatial)
+ {
+ mSpatialJoiningNum++;
+ }
+
// joinedAudioSession() will transition from here to stateSessionJoined.
if(!mVoiceEnabled)
{
@@ -2304,6 +2329,8 @@ void LLVoiceClient::stateMachine()
//MARK: stateSessionJoined
case stateSessionJoined: // session handle received
+
+ mSpatialJoiningNum = 0;
// It appears that I need to wait for BOTH the SessionGroup.AddSession response and the SessionStateChangeEvent with state 4
// before continuing from this state. They can happen in either order, and if I don't wait for both, things can get stuck.
// For now, the SessionGroup.AddSession response handler sets mSessionHandle and the SessionStateChangeEvent handler transitions to stateSessionJoined.
@@ -5045,6 +5072,11 @@ LLVoiceClient::participantState *LLVoiceClient::sessionState::addParticipant(con
mParticipantsByUUID.insert(participantUUIDMap::value_type(&(result->mAvatarID), result));
result->mUserVolume = LLSpeakerVolumeStorage::getInstance()->getSpeakerVolume(result->mAvatarID);
+ if (result->mUserVolume != -1)
+ {
+ result->mVolumeDirty = true;
+ mVolumeDirty = true;
+ }
LL_DEBUGS("Voice") << "participant \"" << result->mURI << "\" added." << LL_ENDL;
}
@@ -5377,24 +5409,25 @@ LLVoiceClient::sessionState* LLVoiceClient::startUserIMSession(const LLUUID &uui
// No session with user, need to start one.
std::string uri = sipURIFromID(uuid);
session = addSession(uri);
+
+ llassert(session);
+ if (!session) return NULL;
+
session->mIsSpatial = false;
session->mReconnect = false;
session->mIsP2P = true;
session->mCallerID = uuid;
}
- if(session)
+ if(session->mHandle.empty())
{
- if(session->mHandle.empty())
- {
- // Session isn't active -- start it up.
- sessionCreateSendMessage(session, false, true);
- }
- else
- {
- // Session is already active -- start up text.
- sessionTextConnectSendMessage(session);
- }
+ // Session isn't active -- start it up.
+ sessionCreateSendMessage(session, false, true);
+ }
+ else
+ {
+ // Session is already active -- start up text.
+ sessionTextConnectSendMessage(session);
}
return session;
@@ -5988,7 +6021,9 @@ bool LLVoiceClient::voiceEnabled()
bool LLVoiceClient::voiceWorking()
{
//Added stateSessionTerminated state to avoid problems with call in parcels with disabled voice (EXT-4758)
- return (stateLoggedIn <= mState) && (mState <= stateSessionTerminated);
+ // Condition with joining spatial num was added to take into account possible problems with connection to voice
+ // server(EXT-4313). See bug descriptions and comments for MAX_NORMAL_JOINING_SPATIAL_NUM for more info.
+ return (mSpatialJoiningNum < MAX_NORMAL_JOINING_SPATIAL_NUM) && (stateLoggedIn <= mState) && (mState <= stateSessionTerminated);
}
void LLVoiceClient::setLipSyncEnabled(BOOL enabled)