Fixup some logic relating to teleporting and new regions

meow-7.2.2
Roxie Linden 2024-03-11 22:12:21 -07:00
parent 1f177d837c
commit 37837edd69
5 changed files with 133 additions and 67 deletions

View File

@ -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,14 +175,62 @@ void LLVoiceClient::userAuthorized(const std::string& user_id, const LLUUID &age
LLVivoxVoiceClient::getInstance()->userAuthorized(user_id, agentID);
}
void LLVoiceClient::handleSimulatorFeaturesReceived(const LLSD &simulatorFeatures)
{
std::string voiceServerType = simulatorFeatures["VoiceServerType"].asString();
if (voiceServerType.empty())
{
voiceServerType = VIVOX_VOICE_SERVER_TYPE;
}
if (mSpatialVoiceModule && !mNonSpatialVoiceModule)
{
// 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)
{
mSpatialVoiceModule->processChannels(false);
}
}
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);
}
}
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);
if (LLVoiceClient::getInstance())
{
LLVoiceClient::getInstance()->handleSimulatorFeaturesReceived(simulatorFeatures);
}
}
}
void LLVoiceClient::onRegionChanged()
{
LLViewerRegion *region = gAgent.getRegion();
if (region && region->simulatorFeaturesReceived())
{
LLSD simulatorFeatures;
region->getSimulatorFeatures(simulatorFeatures);
setSpatialVoiceModule(simulatorFeatures["VoiceServerType"].asString());
LLSD simulatorFeatures;
region->getSimulatorFeatures(simulatorFeatures);
if (LLVoiceClient::getInstance())
{
LLVoiceClient::getInstance()->handleSimulatorFeaturesReceived(simulatorFeatures);
}
}
else if (region)
{
@ -190,19 +239,7 @@ void LLVoiceClient::onRegionChanged()
mSimulatorFeaturesReceivedSlot.disconnect();
}
mSimulatorFeaturesReceivedSlot =
region->setSimulatorFeaturesReceivedCallback(
boost::bind(&LLVoiceClient::onSimulatorFeaturesReceived, this, _1));
}
}
void LLVoiceClient::onSimulatorFeaturesReceived(const LLUUID& region_id)
{
LLViewerRegion *region = gAgent.getRegion();
if (region && (region->getRegionID() == region_id))
{
LLSD simulatorFeatures;
region->getSimulatorFeatures(simulatorFeatures);
setSpatialVoiceModule(simulatorFeatures["VoiceServerType"].asString());
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();
}
}

View File

@ -480,7 +480,6 @@ public:
const LLUUID &agentID);
void onRegionChanged();
void onSimulatorFeaturesReceived(const LLUUID &region_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;

View File

@ -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();
)

View File

@ -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);
}
}
}
}

View File

@ -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;
}