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.cpp113
1 files changed, 76 insertions, 37 deletions
diff --git a/indra/newview/llvoiceclient.cpp b/indra/newview/llvoiceclient.cpp
index 1f5dbe3b97..44e00b69e5 100644
--- a/indra/newview/llvoiceclient.cpp
+++ b/indra/newview/llvoiceclient.cpp
@@ -135,6 +135,7 @@ LLVoiceModuleInterface *getVoiceModule(const std::string &voice_server_type)
LLVoiceClient::LLVoiceClient(LLPumpIO *pump)
:
mSpatialVoiceModule(NULL),
+ mNonSpatialVoiceModule(NULL),
m_servicePump(NULL),
mVoiceEffectEnabled(LLCachedControl<bool>(gSavedSettings, "VoiceMorphingEnabled", true)),
mVoiceEffectDefault(LLCachedControl<std::string>(gSavedPerAccountSettings, "VoiceEffectDefault", "00000000-0000-0000-0000-000000000000")),
@@ -174,35 +175,71 @@ void LLVoiceClient::userAuthorized(const std::string& user_id, const LLUUID &age
LLVivoxVoiceClient::getInstance()->userAuthorized(user_id, agentID);
}
-void LLVoiceClient::onRegionChanged()
+void LLVoiceClient::handleSimulatorFeaturesReceived(const LLSD &simulatorFeatures)
{
- LLViewerRegion *region = gAgent.getRegion();
- if (region && region->simulatorFeaturesReceived())
+ std::string voiceServerType = simulatorFeatures["VoiceServerType"].asString();
+ if (voiceServerType.empty())
{
- LLSD simulatorFeatures;
- region->getSimulatorFeatures(simulatorFeatures);
- setSpatialVoiceModule(simulatorFeatures["VoiceServerType"].asString());
+ voiceServerType = VIVOX_VOICE_SERVER_TYPE;
}
- else if (region)
+
+ if (mSpatialVoiceModule && !mNonSpatialVoiceModule)
{
- if (mSimulatorFeaturesReceivedSlot.connected())
+ // stop processing if we're going to change voice modules
+ // and we're not currently in non-spatial.
+ LLVoiceVersionInfo version = mSpatialVoiceModule->getVersion();
+ if (version.internalVoiceServerType != voiceServerType)
{
- mSimulatorFeaturesReceivedSlot.disconnect();
+ mSpatialVoiceModule->processChannels(false);
}
- mSimulatorFeaturesReceivedSlot =
- region->setSimulatorFeaturesReceivedCallback(
- boost::bind(&LLVoiceClient::onSimulatorFeaturesReceived, this, _1));
+ }
+ setSpatialVoiceModule(simulatorFeatures["VoiceServerType"].asString());
+
+ // if we should be in spatial voice, switch to it and set the creds
+ if (mSpatialVoiceModule && !mNonSpatialVoiceModule)
+ {
+ if (!mSpatialCredentials.isUndefined())
+ {
+ mSpatialVoiceModule->setSpatialChannel(mSpatialCredentials);
+ }
+ mSpatialVoiceModule->processChannels(true);
}
}
-void LLVoiceClient::onSimulatorFeaturesReceived(const LLUUID& region_id)
+static void simulator_features_received_callback(const LLUUID& region_id)
{
LLViewerRegion *region = gAgent.getRegion();
if (region && (region->getRegionID() == region_id))
{
LLSD simulatorFeatures;
region->getSimulatorFeatures(simulatorFeatures);
- setSpatialVoiceModule(simulatorFeatures["VoiceServerType"].asString());
+ if (LLVoiceClient::getInstance())
+ {
+ LLVoiceClient::getInstance()->handleSimulatorFeaturesReceived(simulatorFeatures);
+ }
+ }
+}
+
+void LLVoiceClient::onRegionChanged()
+{
+ LLViewerRegion *region = gAgent.getRegion();
+ if (region && region->simulatorFeaturesReceived())
+ {
+ LLSD simulatorFeatures;
+ region->getSimulatorFeatures(simulatorFeatures);
+ if (LLVoiceClient::getInstance())
+ {
+ LLVoiceClient::getInstance()->handleSimulatorFeaturesReceived(simulatorFeatures);
+ }
+ }
+ else if (region)
+ {
+ if (mSimulatorFeaturesReceivedSlot.connected())
+ {
+ mSimulatorFeaturesReceivedSlot.disconnect();
+ }
+ mSimulatorFeaturesReceivedSlot =
+ region->setSimulatorFeaturesReceivedCallback(boost::bind(&simulator_features_received_callback, _1));
}
}
@@ -419,37 +456,36 @@ void LLVoiceClient::setNonSpatialChannel(
bool hangup_on_last_leave)
{
setNonSpatialVoiceModule(channelInfo["voice_server_type"].asString());
- if (mSpatialVoiceModule)
+ if (mSpatialVoiceModule && mSpatialVoiceModule != mNonSpatialVoiceModule)
{
mSpatialVoiceModule->processChannels(false);
}
if (mNonSpatialVoiceModule)
{
- mNonSpatialVoiceModule->setNonSpatialChannel(channelInfo, notify_on_first_join, hangup_on_last_leave);
mNonSpatialVoiceModule->processChannels(true);
+ mNonSpatialVoiceModule->setNonSpatialChannel(channelInfo, notify_on_first_join, hangup_on_last_leave);
}
- }
+}
void LLVoiceClient::setSpatialChannel(const LLSD &channelInfo)
{
- LLViewerRegion *region = gAgent.getRegion();
- if (region && region->simulatorFeaturesReceived())
- {
- LLSD simulatorFeatures;
- region->getSimulatorFeatures(simulatorFeatures);
- setSpatialVoiceModule(simulatorFeatures["VoiceServerType"].asString());
- }
- if (mNonSpatialVoiceModule)
- {
- mNonSpatialVoiceModule->leaveNonSpatialChannel();
- mNonSpatialVoiceModule->processChannels(false);
- mNonSpatialVoiceModule = nullptr;
- }
+ mSpatialCredentials = channelInfo;
+ LLViewerRegion *region = gAgent.getRegion();
+ if (region && region->simulatorFeaturesReceived())
+ {
+ LLSD simulatorFeatures;
+ region->getSimulatorFeatures(simulatorFeatures);
+ setSpatialVoiceModule(simulatorFeatures["VoiceServerType"].asString());
+ }
+ else
+ {
+ return;
+ }
+
if (mSpatialVoiceModule)
- {
- mSpatialVoiceModule->setSpatialChannel(channelInfo);
- mSpatialVoiceModule->processChannels(true);
- }
+ {
+ mSpatialVoiceModule->setSpatialChannel(channelInfo);
+ }
}
void LLVoiceClient::leaveNonSpatialChannel()
@@ -564,9 +600,12 @@ void LLVoiceClient::updateMicMuteLogic()
void LLVoiceClient::setMuteMic(bool muted)
{
- mMuteMic = muted;
- updateMicMuteLogic();
- mMicroChangedSignal();
+ if (mMuteMic != muted)
+ {
+ mMuteMic = muted;
+ updateMicMuteLogic();
+ mMicroChangedSignal();
+ }
}