summaryrefslogtreecommitdiff
path: root/indra/newview/llvoicevivox.cpp
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2024-04-10 06:57:52 +0300
committerAndrey Lihatskiy <alihatskiy@productengine.com>2024-04-10 07:08:25 +0300
commit84dfe55810815e8c274044cea5c81aaed89a787f (patch)
tree4e499acfe5617682c5eca52998b5c10cdac8609a /indra/newview/llvoicevivox.cpp
parent16e638db975278f6018fe1e21ba1954b7f159149 (diff)
parentda9a1dcb55548a249ff7a1255f3e518696b81245 (diff)
Merge branch 'main' into marchcat/y-merge
# Conflicts: # autobuild.xml # indra/llcommon/llsys.cpp
Diffstat (limited to 'indra/newview/llvoicevivox.cpp')
-rw-r--r--indra/newview/llvoicevivox.cpp57
1 files changed, 38 insertions, 19 deletions
diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp
index c8d77a6e0b..310c9ee297 100644
--- a/indra/newview/llvoicevivox.cpp
+++ b/indra/newview/llvoicevivox.cpp
@@ -951,32 +951,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<U32> portbase(gSavedSettings, "VivoxVoicePort");
+ static LLCachedControl<std::string> host(gSavedSettings, "VivoxVoiceHost");
+ static LLCachedControl<std::string> loglevel(gSavedSettings, "VivoxDebugLevel");
+ static LLCachedControl<std::string> log_folder(gSavedSettings, "VivoxLogDirectory");
+ static LLCachedControl<std::string> 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 + instance_offset;
+ }
+ 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 +1012,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 +1035,7 @@ bool LLVivoxVoiceClient::startAndLaunchDaemon()
sGatewayPtr = LLProcess::create(params);
- mDaemonHost = LLHost(host.c_str(), port);
+ mDaemonHost = LLHost(host().c_str(), port);
}
else
{