diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llvoiceclient.cpp | 113 | ||||
-rw-r--r-- | indra/newview/llvoiceclient.h | 11 | ||||
-rw-r--r-- | indra/newview/llvoicevivox.cpp | 24 | ||||
-rw-r--r-- | indra/newview/llvoicewebrtc.cpp | 45 | ||||
-rw-r--r-- | indra/newview/llvoicewebrtc.h | 3 |
5 files changed, 131 insertions, 65 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(); + } } diff --git a/indra/newview/llvoiceclient.h b/indra/newview/llvoiceclient.h index 02f73cde7a..3b1b3bd0c4 100644 --- a/indra/newview/llvoiceclient.h +++ b/indra/newview/llvoiceclient.h @@ -480,7 +480,6 @@ public: const LLUUID &agentID); void onRegionChanged(); - void onSimulatorFeaturesReceived(const LLUUID ®ion_id); void addObserver(LLVoiceClientStatusObserver* observer); void removeObserver(LLVoiceClientStatusObserver* observer); @@ -500,12 +499,20 @@ public: // Returns NULL if voice effects are not supported, or not enabled. LLVoiceEffectInterface* getVoiceEffectInterface() const; //@} -private: + + void handleSimulatorFeaturesReceived(const LLSD &simulatorFeatures); + + private: + void init(LLPumpIO *pump); protected: + LLVoiceModuleInterface* mSpatialVoiceModule; LLVoiceModuleInterface* mNonSpatialVoiceModule; + LLSD mSpatialCredentials; // used to store spatial credentials for vivox + // so they're available when the region voice + // server is retrieved. LLPumpIO *m_servicePump; boost::signals2::connection mSimulatorFeaturesReceivedSlot; diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index 9a1fb925eb..29aba8ecba 100644 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -2101,13 +2101,13 @@ bool LLVivoxVoiceClient::runSession(const sessionStatePtr_t &session) { LL_INFOS("Voice") << "running new voice session " << session->mHandle << LL_ENDL; - bool joined_session = addAndJoinSession(session); - - if (sShuttingDown) + if (sShuttingDown || !mProcessChannels) { return false; } + bool joined_session = addAndJoinSession(session); + if (!joined_session) { notifyStatusObservers(LLVoiceClientStatusObserver::ERROR_UNKNOWN); @@ -2137,7 +2137,8 @@ bool LLVivoxVoiceClient::runSession(const sessionStatePtr_t &session) && mVoiceEnabled && isGatewayRunning() && !mSessionTerminateRequested - && !mTuningMode) + && !mTuningMode + && mProcessChannels) { sendCaptureAndRenderDevices(); // suspends @@ -4923,9 +4924,14 @@ void LLVivoxVoiceClient::setNonSpatialChannel(const LLSD& channelInfo, bool noti bool LLVivoxVoiceClient::setSpatialChannel(const LLSD& channelInfo) { - mProcessChannels = true; - mSpatialSessionURI = channelInfo["channel_uri"].asString(); + mSpatialSessionURI = channelInfo["channel_uri"].asString(); mSpatialSessionCredentials = channelInfo["channel_credentials"].asString(); + if (!mProcessChannels) + { + // we're not even processing channels (another provider is) so + // save the credentials aside and exit + return false; + } LL_DEBUGS("Voice") << "got spatial channel uri: \"" << mSpatialSessionURI << "\"" << LL_ENDL; @@ -6227,6 +6233,12 @@ void LLVivoxVoiceClient::notifyStatusObservers(LLVoiceClientStatusObserver::ESta << ", proximal is " << inSpatialChannel() << LL_ENDL; + if (!mProcessChannels) + { + // we're not processing...another voice module is. + // so nobody wants to hear from us. + return; + } for (status_observer_set_t::iterator it = mStatusObservers.begin(); it != mStatusObservers.end(); ) diff --git a/indra/newview/llvoicewebrtc.cpp b/indra/newview/llvoicewebrtc.cpp index 02917d2135..2bb16cb336 100644 --- a/indra/newview/llvoicewebrtc.cpp +++ b/indra/newview/llvoicewebrtc.cpp @@ -467,10 +467,7 @@ void LLWebRTCVoiceClient::voiceConnectionCoro() if (useEstateVoice && !inEstateChannel()) { // estate voice - if (!inEstateChannel()) - { - startEstateSession(); - } + startEstateSession(); } } if (!voiceEnabled) @@ -487,7 +484,7 @@ void LLWebRTCVoiceClient::voiceConnectionCoro() } sessionState::processSessionStates(); - if (mProcessChannels && voiceEnabled) + if (mProcessChannels && voiceEnabled && !mHidden) { sendPositionUpdate(true); updateOwnVolume(); @@ -741,10 +738,13 @@ void LLWebRTCVoiceClient::setHidden(bool hidden) if (mHidden) { // get out of the channel entirely - leaveAudioSession(); + // mute the microphone. + sessionState::for_each(boost::bind(predSetMuteMic, _1, true)); } else { + // and put it back + sessionState::for_each(boost::bind(predSetMuteMic, _1, mMuteMic)); updatePosition(); sendPositionUpdate(true); } @@ -1338,7 +1338,11 @@ bool LLWebRTCVoiceClient::compareChannels(const LLSD &channelInfo1, const LLSD & void LLWebRTCVoiceClient::setMuteMic(bool muted) { mMuteMic = muted; - sessionState::for_each(boost::bind(predSetMuteMic, _1, muted)); + // when you're hidden, your mic is always muted. + if (!mHidden) + { + sessionState::for_each(boost::bind(predSetMuteMic, _1, muted)); + } } void LLWebRTCVoiceClient::predSetMuteMic(const LLWebRTCVoiceClient::sessionStatePtr_t &session, bool muted) @@ -2791,20 +2795,23 @@ LLVoiceWebRTCSpatialConnection::~LLVoiceWebRTCSpatialConnection() void LLVoiceWebRTCSpatialConnection::setMuteMic(bool muted) { - mMuted = muted; - if (mWebRTCAudioInterface) + if (mMuted != muted) { - LLViewerRegion *regionp = gAgent.getRegion(); - if (regionp && mRegionID == regionp->getRegionID()) + mMuted = muted; + if (mWebRTCAudioInterface) { - mWebRTCAudioInterface->setMute(muted); - } - else - { - // Always mute this agent with respect to neighboring regions. - // Peers don't want to hear this agent from multiple regions - // as that'll echo. - mWebRTCAudioInterface->setMute(true); + LLViewerRegion *regionp = gAgent.getRegion(); + if (regionp && mRegionID == regionp->getRegionID()) + { + mWebRTCAudioInterface->setMute(muted); + } + else + { + // Always mute this agent with respect to neighboring regions. + // Peers don't want to hear this agent from multiple regions + // as that'll echo. + mWebRTCAudioInterface->setMute(true); + } } } } diff --git a/indra/newview/llvoicewebrtc.h b/indra/newview/llvoicewebrtc.h index 0e8ac3a183..03bbe00162 100644 --- a/indra/newview/llvoicewebrtc.h +++ b/indra/newview/llvoicewebrtc.h @@ -146,7 +146,8 @@ public: bool setSpatialChannel(const LLSD &channelInfo) override { - processChannels(true); + // we don't really have credentials for a spatial channel in webrtc, + // it's all handled by the sim. return true; } |