@@ -277,6 +277,7 @@ static void killGateway()
277277
278278bool LLVivoxVoiceClient::sShuttingDown = false ;
279279bool LLVivoxVoiceClient::sConnected = false ;
280+ bool LLVivoxVoiceClient::sVoiceInstanceMuted = false ;
280281LLPumpIO *LLVivoxVoiceClient::sPump = nullptr ;
281282
282283LLVivoxVoiceClient::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
56305652void LLVivoxVoiceClient::setLipSyncEnabled (BOOL enabled)
0 commit comments