Skip to content

Commit a26573f

Browse files
committed
SL-18049 Part 1; Allow voice to be enabled in second instance
1 parent 2a87b64 commit a26573f

File tree

8 files changed

+93
-39
lines changed

8 files changed

+93
-39
lines changed

indra/newview/llappviewer.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2945,13 +2945,14 @@ bool LLAppViewer::initConfiguration()
29452945

29462946
if (mSecondInstance)
29472947
{
2948-
// This is the second instance of SL. Turn off voice support,
2948+
// This is the second instance of SL. Mute voice,
29492949
// but make sure the setting is *not* persisted.
2950-
LLControlVariable* disable_voice = gSavedSettings.getControl("CmdLineDisableVoice");
2951-
if(disable_voice)
2950+
// Also see LLVivoxVoiceClient::voiceEnabled()
2951+
LLControlVariable* enable_voice = gSavedSettings.getControl("EnableVoiceChat");
2952+
if(enable_voice)
29522953
{
29532954
const BOOL DO_NOT_PERSIST = FALSE;
2954-
disable_voice->setValue(LLSD(TRUE), DO_NOT_PERSIST);
2955+
enable_voice->setValue(LLSD(FALSE), DO_NOT_PERSIST);
29552956
}
29562957
}
29572958

indra/newview/llpanelvolumepulldown.cpp

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "llfloaterreg.h"
4141
#include "llfloaterpreference.h"
4242
#include "llsliderctrl.h"
43+
#include "llvoicevivox.h"
4344

4445
///----------------------------------------------------------------------------
4546
/// Class LLPanelVolumePulldown
@@ -50,7 +51,7 @@ LLPanelVolumePulldown::LLPanelVolumePulldown()
5051
{
5152
mCommitCallbackRegistrar.add("Vol.setControlFalse", boost::bind(&LLPanelVolumePulldown::setControlFalse, this, _2));
5253
mCommitCallbackRegistrar.add("Vol.SetSounds", boost::bind(&LLPanelVolumePulldown::onClickSetSounds, this));
53-
mCommitCallbackRegistrar.add("Vol.updateMediaAutoPlayCheckbox", boost::bind(&LLPanelVolumePulldown::updateMediaAutoPlayCheckbox, this, _1));
54+
mCommitCallbackRegistrar.add("Vol.updateCheckbox", boost::bind(&LLPanelVolumePulldown::updateCheckbox, this, _1, _2));
5455
mCommitCallbackRegistrar.add("Vol.GoAudioPrefs", boost::bind(&LLPanelVolumePulldown::onAdvancedButtonClick, this, _2));
5556
buildFromFile( "panel_volume_pulldown.xml");
5657
}
@@ -90,19 +91,27 @@ void LLPanelVolumePulldown::setControlFalse(const LLSD& user_data)
9091
control->set(LLSD(FALSE));
9192
}
9293

93-
void LLPanelVolumePulldown::updateMediaAutoPlayCheckbox(LLUICtrl* ctrl)
94+
void LLPanelVolumePulldown::updateCheckbox(LLUICtrl* ctrl, const LLSD& user_data)
9495
{
95-
std::string name = ctrl->getName();
96+
std::string control_name = user_data.asString();
97+
if (control_name == "MediaAutoPlay")
98+
{
99+
std::string name = ctrl->getName();
96100

97-
// Disable "Allow Media to auto play" only when both
98-
// "Streaming Music" and "Media" are unchecked. STORM-513.
99-
if ((name == "enable_music") || (name == "enable_media"))
100-
{
101-
bool music_enabled = getChild<LLCheckBoxCtrl>("enable_music")->get();
102-
bool media_enabled = getChild<LLCheckBoxCtrl>("enable_media")->get();
101+
// Disable "Allow Media to auto play" only when both
102+
// "Streaming Music" and "Media" are unchecked. STORM-513.
103+
if ((name == "enable_music") || (name == "enable_media"))
104+
{
105+
bool music_enabled = getChild<LLCheckBoxCtrl>("enable_music")->get();
106+
bool media_enabled = getChild<LLCheckBoxCtrl>("enable_media")->get();
103107

104-
getChild<LLCheckBoxCtrl>("media_auto_play_combo")->setEnabled(music_enabled || media_enabled);
105-
}
108+
getChild<LLCheckBoxCtrl>("media_auto_play_combo")->setEnabled(music_enabled || media_enabled);
109+
}
110+
}
111+
else if (control_name == "VoiceChat")
112+
{
113+
LLVivoxVoiceClient::unmuteVoiceInstance();
114+
}
106115
}
107116

108117
void LLPanelVolumePulldown::onClickSetSounds()

indra/newview/llpanelvolumepulldown.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class LLPanelVolumePulldown : public LLPanelPulldown
4343
void onClickSetSounds();
4444
// Disables "Allow Media to auto play" check box only when both
4545
// "Streaming Music" and "Media" are unchecked. Otherwise enables it.
46-
void updateMediaAutoPlayCheckbox(LLUICtrl* ctrl);
46+
void updateCheckbox(LLUICtrl* ctrl, const LLSD& user_data);
4747
void onAdvancedButtonClick(const LLSD& user_data);
4848
};
4949

indra/newview/llvoiceclient.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,16 @@ void LLVoiceClient::setVoiceEnabled(bool enabled)
555555
}
556556
}
557557

558+
void LLVoiceClient::unmuteVoiceInstance()
559+
{
560+
LLVivoxVoiceClient::unmuteVoiceInstance();
561+
}
562+
563+
bool LLVoiceClient::isMutedVoiceInstance()
564+
{
565+
return LLVivoxVoiceClient::isMutedVoiceInstance();
566+
}
567+
558568
void LLVoiceClient::updateMicMuteLogic()
559569
{
560570
// If not configured to use PTT, the mic should be open (otherwise the user will be unable to speak).

indra/newview/llvoiceclient.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,8 @@ class LLVoiceClient: public LLParamSingleton<LLVoiceClient>
403403
void toggleUserPTTState(void);
404404
void inputUserControlState(bool down); // interpret any sort of up-down mic-open control input according to ptt-toggle prefs
405405
void setVoiceEnabled(bool enabled);
406+
static void unmuteVoiceInstance();
407+
static bool isMutedVoiceInstance();
406408

407409
void setUsePTT(bool usePTT);
408410
void setPTTIsToggle(bool PTTIsToggle);

indra/newview/llvoicevivox.cpp

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ static void killGateway()
277277

278278
bool LLVivoxVoiceClient::sShuttingDown = false;
279279
bool LLVivoxVoiceClient::sConnected = false;
280+
bool LLVivoxVoiceClient::sVoiceInstanceMuted = false;
280281
LLPumpIO *LLVivoxVoiceClient::sPump = nullptr;
281282

282283
LLVivoxVoiceClient::LLVivoxVoiceClient() :
@@ -354,6 +355,7 @@ LLVivoxVoiceClient::LLVivoxVoiceClient() :
354355
sShuttingDown = false;
355356
sConnected = false;
356357
sPump = nullptr;
358+
sVoiceInstanceMuted = LLAppViewer::instance()->isSecondInstance();
357359

358360
mSpeakerVolume = scale_speaker_volume(0);
359361

@@ -951,32 +953,52 @@ bool LLVivoxVoiceClient::startAndLaunchDaemon()
951953
// cause SLVoice's bind() call to fail with EADDRINUSE. We expect
952954
// that eventually the OS will time out previous ports, which is
953955
// why we cycle instead of incrementing indefinitely.
954-
U32 portbase = gSavedSettings.getU32("VivoxVoicePort");
955-
static U32 portoffset = 0;
956+
957+
static LLCachedControl<U32> portbase(gSavedSettings, "VivoxVoicePort");
958+
static LLCachedControl<std::string> host(gSavedSettings, "VivoxVoiceHost");
959+
static LLCachedControl<std::string> loglevel(gSavedSettings, "VivoxDebugLevel");
960+
static LLCachedControl<std::string> log_folder(gSavedSettings, "VivoxLogDirectory");
961+
static LLCachedControl<std::string> shutdown_timeout(gSavedSettings, "VivoxShutdownTimeout");
956962
static const U32 portrange = 100;
957-
std::string host(gSavedSettings.getString("VivoxVoiceHost"));
958-
U32 port = portbase + portoffset;
963+
static U32 portoffset = 0;
964+
U32 port = 0;
965+
966+
if (LLAppViewer::instance()->isSecondInstance())
967+
{
968+
// Ideally need to know amount of instances and
969+
// to increment instance_offset on EADDRINUSE.
970+
// But for now just use rand
971+
static U32 instance_offset = portrange * ll_rand(20);
972+
port = portbase + portoffset + portrange;
973+
}
974+
else
975+
{
976+
// leave main thread with exclusive port set
977+
port = portbase + portoffset;
978+
}
959979
portoffset = (portoffset + 1) % portrange;
960980
params.args.add("-i");
961-
params.args.add(STRINGIZE(host << ':' << port));
981+
params.args.add(STRINGIZE(host() << ':' << port));
962982

963-
std::string loglevel = gSavedSettings.getString("VivoxDebugLevel");
964-
if (loglevel.empty())
983+
params.args.add("-ll");
984+
if (loglevel().empty())
965985
{
966-
loglevel = "0";
986+
params.args.add("0");
967987
}
968-
params.args.add("-ll");
969-
params.args.add(loglevel);
970-
971-
std::string log_folder = gSavedSettings.getString("VivoxLogDirectory");
972-
973-
if (log_folder.empty())
988+
else
974989
{
975-
log_folder = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "");
990+
params.args.add(loglevel);
976991
}
977992

978993
params.args.add("-lf");
979-
params.args.add(log_folder);
994+
if (log_folder().empty())
995+
{
996+
params.args.add(gDirUtilp->getExpandedFilename(LL_PATH_LOGS, ""));
997+
}
998+
else
999+
{
1000+
params.args.add(log_folder);
1001+
}
9801002

9811003
// set log file basename and .log
9821004
params.args.add("-lp");
@@ -992,8 +1014,7 @@ bool LLVivoxVoiceClient::startAndLaunchDaemon()
9921014
LLFile::rename(new_log, old_log);
9931015
}
9941016

995-
std::string shutdown_timeout = gSavedSettings.getString("VivoxShutdownTimeout");
996-
if (!shutdown_timeout.empty())
1017+
if (!shutdown_timeout().empty())
9971018
{
9981019
params.args.add("-st");
9991020
params.args.add(shutdown_timeout);
@@ -1016,7 +1037,7 @@ bool LLVivoxVoiceClient::startAndLaunchDaemon()
10161037

10171038
sGatewayPtr = LLProcess::create(params);
10181039

1019-
mDaemonHost = LLHost(host.c_str(), port);
1040+
mDaemonHost = LLHost(host().c_str(), port);
10201041
}
10211042
else
10221043
{
@@ -5624,7 +5645,8 @@ bool LLVivoxVoiceClient::voiceEnabled()
56245645
{
56255646
return gSavedSettings.getBOOL("EnableVoiceChat") &&
56265647
!gSavedSettings.getBOOL("CmdLineDisableVoice") &&
5627-
!gNonInteractive;
5648+
!gNonInteractive &&
5649+
!sVoiceInstanceMuted;
56285650
}
56295651

56305652
void LLVivoxVoiceClient::setLipSyncEnabled(BOOL enabled)

indra/newview/llvoicevivox.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ class LLVivoxVoiceClient : public LLSingleton<LLVivoxVoiceClient>,
172172
//@{
173173
virtual bool voiceEnabled();
174174
virtual void setVoiceEnabled(bool enabled);
175+
static void unmuteVoiceInstance() { sVoiceInstanceMuted = false; }
176+
static bool isMutedVoiceInstance() { return sVoiceInstanceMuted; }
175177
virtual BOOL lipSyncEnabled();
176178
virtual void setLipSyncEnabled(BOOL enabled);
177179
virtual void setMuteMic(bool muted); // Set the mute state of the local mic.
@@ -917,6 +919,7 @@ class LLVivoxVoiceClient : public LLSingleton<LLVivoxVoiceClient>,
917919
// This variables can last longer than vivox in coroutines so we need them as static
918920
static bool sShuttingDown;
919921
static bool sConnected;
922+
static bool sVoiceInstanceMuted; // Second+ instance of viewer starts muted
920923
static LLPumpIO* sPump;
921924

922925
LLEventMailDrop mVivoxPump;

indra/newview/skins/default/xui/en/panel_volume_pulldown.xml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@
199199
top_delta="2"
200200
width="350">
201201
<check_box.commit_callback
202-
function="Vol.updateMediaAutoPlayCheckbox"/>
202+
function="Vol.updateCheckbox"
203+
parameter="MediaAutoPlay"/>
203204
</check_box>
204205
<slider
205206
control_name="AudioLevelMedia"
@@ -246,7 +247,8 @@
246247
name="enable_media"
247248
width="110">
248249
<check_box.commit_callback
249-
function="Vol.updateMediaAutoPlayCheckbox"/>
250+
function="Vol.updateCheckbox"
251+
parameter="MediaAutoPlay"/>
250252
</check_box>
251253
<slider
252254
control_name="AudioLevelVoice"
@@ -292,5 +294,10 @@
292294
top_delta="2"
293295
left_pad="5"
294296
name="enable_voice_check"
295-
width="110"/>
297+
width="110"
298+
>
299+
<check_box.commit_callback
300+
function="Vol.updateCheckbox"
301+
parameter="VoiceChat"/>
302+
</check_box>
296303
</panel>

0 commit comments

Comments
 (0)