From a26573fefe2a3599c1c920722dec519c9481dc64 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 3 Aug 2023 20:40:40 +0300 Subject: SL-18049 Part 1; Allow voice to be enabled in second instance --- indra/newview/llvoicevivox.cpp | 62 ++++++++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 20 deletions(-) (limited to 'indra/newview/llvoicevivox.cpp') diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index 3725510b6a..c89fe81a85 100644 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -277,6 +277,7 @@ static void killGateway() bool LLVivoxVoiceClient::sShuttingDown = false; bool LLVivoxVoiceClient::sConnected = false; +bool LLVivoxVoiceClient::sVoiceInstanceMuted = false; LLPumpIO *LLVivoxVoiceClient::sPump = nullptr; LLVivoxVoiceClient::LLVivoxVoiceClient() : @@ -354,6 +355,7 @@ LLVivoxVoiceClient::LLVivoxVoiceClient() : sShuttingDown = false; sConnected = false; sPump = nullptr; + sVoiceInstanceMuted = LLAppViewer::instance()->isSecondInstance(); mSpeakerVolume = scale_speaker_volume(0); @@ -951,32 +953,52 @@ bool LLVivoxVoiceClient::startAndLaunchDaemon() // cause SLVoice's bind() call to fail with EADDRINUSE. We expect // that eventually the OS will time out previous ports, which is // why we cycle instead of incrementing indefinitely. - U32 portbase = gSavedSettings.getU32("VivoxVoicePort"); - static U32 portoffset = 0; + + static LLCachedControl portbase(gSavedSettings, "VivoxVoicePort"); + static LLCachedControl host(gSavedSettings, "VivoxVoiceHost"); + static LLCachedControl loglevel(gSavedSettings, "VivoxDebugLevel"); + static LLCachedControl log_folder(gSavedSettings, "VivoxLogDirectory"); + static LLCachedControl shutdown_timeout(gSavedSettings, "VivoxShutdownTimeout"); static const U32 portrange = 100; - std::string host(gSavedSettings.getString("VivoxVoiceHost")); - U32 port = portbase + portoffset; + static U32 portoffset = 0; + U32 port = 0; + + if (LLAppViewer::instance()->isSecondInstance()) + { + // Ideally need to know amount of instances and + // to increment instance_offset on EADDRINUSE. + // But for now just use rand + static U32 instance_offset = portrange * ll_rand(20); + port = portbase + portoffset + portrange; + } + else + { + // leave main thread with exclusive port set + port = portbase + portoffset; + } portoffset = (portoffset + 1) % portrange; params.args.add("-i"); - params.args.add(STRINGIZE(host << ':' << port)); + params.args.add(STRINGIZE(host() << ':' << port)); - std::string loglevel = gSavedSettings.getString("VivoxDebugLevel"); - if (loglevel.empty()) + params.args.add("-ll"); + if (loglevel().empty()) { - loglevel = "0"; + params.args.add("0"); } - params.args.add("-ll"); - params.args.add(loglevel); - - std::string log_folder = gSavedSettings.getString("VivoxLogDirectory"); - - if (log_folder.empty()) + else { - log_folder = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, ""); + params.args.add(loglevel); } params.args.add("-lf"); - params.args.add(log_folder); + if (log_folder().empty()) + { + params.args.add(gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "")); + } + else + { + params.args.add(log_folder); + } // set log file basename and .log params.args.add("-lp"); @@ -992,8 +1014,7 @@ bool LLVivoxVoiceClient::startAndLaunchDaemon() LLFile::rename(new_log, old_log); } - std::string shutdown_timeout = gSavedSettings.getString("VivoxShutdownTimeout"); - if (!shutdown_timeout.empty()) + if (!shutdown_timeout().empty()) { params.args.add("-st"); params.args.add(shutdown_timeout); @@ -1016,7 +1037,7 @@ bool LLVivoxVoiceClient::startAndLaunchDaemon() sGatewayPtr = LLProcess::create(params); - mDaemonHost = LLHost(host.c_str(), port); + mDaemonHost = LLHost(host().c_str(), port); } else { @@ -5624,7 +5645,8 @@ bool LLVivoxVoiceClient::voiceEnabled() { return gSavedSettings.getBOOL("EnableVoiceChat") && !gSavedSettings.getBOOL("CmdLineDisableVoice") && - !gNonInteractive; + !gNonInteractive && + !sVoiceInstanceMuted; } void LLVivoxVoiceClient::setLipSyncEnabled(BOOL enabled) -- cgit v1.3 From a16babdf7d96fbbe345d9e0c5df178e48539751c Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 4 Aug 2023 18:17:50 +0300 Subject: SL-18049 Part 4; Adjustments and fixes --- indra/newview/llpanelvoicedevicesettings.cpp | 22 ++++++++++++---------- indra/newview/llpanelvoicedevicesettings.h | 4 ++-- indra/newview/llpanelvolumepulldown.cpp | 5 ----- indra/newview/llstatusbar.cpp | 4 ++-- indra/newview/llvoiceclient.cpp | 10 ---------- indra/newview/llvoiceclient.h | 2 -- indra/newview/llvoicevivox.cpp | 5 +---- indra/newview/llvoicevivox.h | 3 --- .../skins/default/xui/en/panel_sound_devices.xml | 16 ++++++++-------- .../skins/default/xui/en/panel_volume_pulldown.xml | 6 +----- 10 files changed, 26 insertions(+), 51 deletions(-) (limited to 'indra/newview/llvoicevivox.cpp') diff --git a/indra/newview/llpanelvoicedevicesettings.cpp b/indra/newview/llpanelvoicedevicesettings.cpp index 5e1cf801b9..af57169f3b 100644 --- a/indra/newview/llpanelvoicedevicesettings.cpp +++ b/indra/newview/llpanelvoicedevicesettings.cpp @@ -32,6 +32,7 @@ // Viewer includes #include "llcombobox.h" #include "llsliderctrl.h" +#include "llstartup.h" #include "llviewercontrol.h" #include "llvoiceclient.h" #include "llvoicechannel.h" @@ -70,14 +71,14 @@ BOOL LLPanelVoiceDeviceSettings::postBuild() mCtrlInputDevices = getChild("voice_input_device"); mCtrlOutputDevices = getChild("voice_output_device"); - mRetryBtn = getChild("retry_btn"); + mUnmuteBtn = getChild("unmute_btn"); mCtrlInputDevices->setCommitCallback( boost::bind(&LLPanelVoiceDeviceSettings::onCommitInputDevice, this)); mCtrlOutputDevices->setCommitCallback( boost::bind(&LLPanelVoiceDeviceSettings::onCommitOutputDevice, this)); - mRetryBtn->setCommitCallback( - boost::bind(&LLPanelVoiceDeviceSettings::onCommitRetry, this)); + mUnmuteBtn->setCommitCallback( + boost::bind(&LLPanelVoiceDeviceSettings::onCommitUnmute, this)); mLocalizedDeviceNames[DEFAULT_DEVICE] = getString("default_text"); mLocalizedDeviceNames["No Device"] = getString("name_no_device"); @@ -115,16 +116,18 @@ void LLPanelVoiceDeviceSettings::draw() if (voice_enabled) { getChildView("wait_text")->setVisible( !is_in_tuning_mode && mUseTuningMode); - getChildView("muted_text")->setVisible(FALSE); - mRetryBtn->setVisible(FALSE); + getChildView("disabled_text")->setVisible(FALSE); + mUnmuteBtn->setVisible(FALSE); } else { getChildView("wait_text")->setVisible(FALSE); - getChildView("muted_text")->setVisible(TRUE); - static LLCachedControl voice_enabled(gSavedSettings, "EnableVoiceChat"); - mRetryBtn->setVisible(!voice_enabled || LLVoiceClient::isMutedVoiceInstance()); + static LLCachedControl chat_enabled(gSavedSettings, "EnableVoiceChat"); + // If voice isn't enabled, it is either disabled or muted + bool voice_disabled = chat_enabled() || LLStartUp::getStartupState() <= STATE_LOGIN_WAIT; + getChildView("disabled_text")->setVisible(voice_disabled); + mUnmuteBtn->setVisible(!voice_disabled); } LLPanel::draw(); @@ -357,8 +360,7 @@ void LLPanelVoiceDeviceSettings::onInputDevicesClicked() LLVoiceClient::getInstance()->refreshDeviceLists(false); // fill in the pop up menus again if needed. } -void LLPanelVoiceDeviceSettings::onCommitRetry() +void LLPanelVoiceDeviceSettings::onCommitUnmute() { gSavedSettings.setBOOL("EnableVoiceChat", TRUE); - LLVoiceClient::unmuteVoiceInstance(); } diff --git a/indra/newview/llpanelvoicedevicesettings.h b/indra/newview/llpanelvoicedevicesettings.h index 6b85d4e540..e704394d4a 100644 --- a/indra/newview/llpanelvoicedevicesettings.h +++ b/indra/newview/llpanelvoicedevicesettings.h @@ -55,14 +55,14 @@ protected: void onCommitOutputDevice(); void onOutputDevicesClicked(); void onInputDevicesClicked(); - void onCommitRetry(); + void onCommitUnmute(); F32 mMicVolume; std::string mInputDevice; std::string mOutputDevice; class LLComboBox *mCtrlInputDevices; class LLComboBox *mCtrlOutputDevices; - class LLButton *mRetryBtn; + class LLButton *mUnmuteBtn; BOOL mDevicesUpdated; bool mUseTuningMode; std::map mLocalizedDeviceNames; diff --git a/indra/newview/llpanelvolumepulldown.cpp b/indra/newview/llpanelvolumepulldown.cpp index 17975a6e6d..09038ac95a 100644 --- a/indra/newview/llpanelvolumepulldown.cpp +++ b/indra/newview/llpanelvolumepulldown.cpp @@ -40,7 +40,6 @@ #include "llfloaterreg.h" #include "llfloaterpreference.h" #include "llsliderctrl.h" -#include "llvoicevivox.h" ///---------------------------------------------------------------------------- /// Class LLPanelVolumePulldown @@ -108,10 +107,6 @@ void LLPanelVolumePulldown::updateCheckbox(LLUICtrl* ctrl, const LLSD& user_data getChild("media_auto_play_combo")->setEnabled(music_enabled || media_enabled); } } - else if (control_name == "VoiceChat") - { - LLVivoxVoiceClient::unmuteVoiceInstance(); - } } void LLPanelVolumePulldown::onClickSetSounds() diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp index a9ec4ffbb4..0145380712 100644 --- a/indra/newview/llstatusbar.cpp +++ b/indra/newview/llstatusbar.cpp @@ -193,7 +193,7 @@ BOOL LLStatusBar::postBuild() gSavedSettings.getControl("MuteAudio")->getSignal()->connect(boost::bind(&LLStatusBar::onVolumeChanged, this, _2)); gSavedSettings.getControl("EnableVoiceChat")->getSignal()->connect(boost::bind(&LLStatusBar::onVoiceChanged, this, _2)); - if (gSavedSettings.getBOOL("EnableVoiceChat") && !LLVoiceClient::isMutedVoiceInstance()) + if (gSavedSettings.getBOOL("EnableVoiceChat")) { mBtnVolume->setImageUnselected(LLUI::getUIImage("Audio_Off")); } @@ -653,7 +653,7 @@ void LLStatusBar::onVolumeChanged(const LLSD& newvalue) void LLStatusBar::onVoiceChanged(const LLSD& newvalue) { - if (newvalue.asBoolean() && !LLVoiceClient::isMutedVoiceInstance()) + if (newvalue.asBoolean()) { mBtnVolume->setImageUnselected(LLUI::getUIImage("Audio_Off")); } diff --git a/indra/newview/llvoiceclient.cpp b/indra/newview/llvoiceclient.cpp index fab6ec3755..150b556284 100644 --- a/indra/newview/llvoiceclient.cpp +++ b/indra/newview/llvoiceclient.cpp @@ -555,16 +555,6 @@ void LLVoiceClient::setVoiceEnabled(bool enabled) } } -void LLVoiceClient::unmuteVoiceInstance() -{ - LLVivoxVoiceClient::unmuteVoiceInstance(); -} - -bool LLVoiceClient::isMutedVoiceInstance() -{ - return LLVivoxVoiceClient::isMutedVoiceInstance(); -} - void LLVoiceClient::updateMicMuteLogic() { // If not configured to use PTT, the mic should be open (otherwise the user will be unable to speak). diff --git a/indra/newview/llvoiceclient.h b/indra/newview/llvoiceclient.h index 7788efb8e1..aa67502908 100644 --- a/indra/newview/llvoiceclient.h +++ b/indra/newview/llvoiceclient.h @@ -403,8 +403,6 @@ public: void toggleUserPTTState(void); void inputUserControlState(bool down); // interpret any sort of up-down mic-open control input according to ptt-toggle prefs void setVoiceEnabled(bool enabled); - static void unmuteVoiceInstance(); - static bool isMutedVoiceInstance(); void setUsePTT(bool usePTT); void setPTTIsToggle(bool PTTIsToggle); diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index c89fe81a85..72e0412194 100644 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -277,7 +277,6 @@ static void killGateway() bool LLVivoxVoiceClient::sShuttingDown = false; bool LLVivoxVoiceClient::sConnected = false; -bool LLVivoxVoiceClient::sVoiceInstanceMuted = false; LLPumpIO *LLVivoxVoiceClient::sPump = nullptr; LLVivoxVoiceClient::LLVivoxVoiceClient() : @@ -355,7 +354,6 @@ LLVivoxVoiceClient::LLVivoxVoiceClient() : sShuttingDown = false; sConnected = false; sPump = nullptr; - sVoiceInstanceMuted = LLAppViewer::instance()->isSecondInstance(); mSpeakerVolume = scale_speaker_volume(0); @@ -5645,8 +5643,7 @@ bool LLVivoxVoiceClient::voiceEnabled() { return gSavedSettings.getBOOL("EnableVoiceChat") && !gSavedSettings.getBOOL("CmdLineDisableVoice") && - !gNonInteractive && - !sVoiceInstanceMuted; + !gNonInteractive; } void LLVivoxVoiceClient::setLipSyncEnabled(BOOL enabled) diff --git a/indra/newview/llvoicevivox.h b/indra/newview/llvoicevivox.h index 9a4023422b..e3ab99c675 100644 --- a/indra/newview/llvoicevivox.h +++ b/indra/newview/llvoicevivox.h @@ -172,8 +172,6 @@ public: //@{ virtual bool voiceEnabled(); virtual void setVoiceEnabled(bool enabled); - static void unmuteVoiceInstance() { sVoiceInstanceMuted = false; } - static bool isMutedVoiceInstance() { return sVoiceInstanceMuted; } virtual BOOL lipSyncEnabled(); virtual void setLipSyncEnabled(BOOL enabled); virtual void setMuteMic(bool muted); // Set the mute state of the local mic. @@ -919,7 +917,6 @@ private: // This variables can last longer than vivox in coroutines so we need them as static static bool sShuttingDown; static bool sConnected; - static bool sVoiceInstanceMuted; // Second+ instance of viewer starts muted static LLPumpIO* sPump; LLEventMailDrop mVivoxPump; diff --git a/indra/newview/skins/default/xui/en/panel_sound_devices.xml b/indra/newview/skins/default/xui/en/panel_sound_devices.xml index bcb38a46cc..a1ce99c8be 100644 --- a/indra/newview/skins/default/xui/en/panel_sound_devices.xml +++ b/indra/newview/skins/default/xui/en/panel_sound_devices.xml @@ -168,7 +168,7 @@ width="20" /> - Muted + width="110"> + Disabled