summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2026-09-16 12:50:49 +0300
committerAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2026-09-17 17:44:43 +0300
commitf2586370166a41b0be95c607df2f8df98589458f (patch)
tree2d3cc345d06bbe28c6b782b58e9c536cdc9fdce8 /indra
parent0e1d25f52e6caf4210c86b6e0e4b4ac992a2b8cd (diff)
#6315 Separate voice queue from main queue
Voice should not 'runFor' main app loop on shutdown.
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llvoicewebrtc.cpp51
-rw-r--r--indra/newview/llvoicewebrtc.h7
2 files changed, 40 insertions, 18 deletions
diff --git a/indra/newview/llvoicewebrtc.cpp b/indra/newview/llvoicewebrtc.cpp
index c82a005a77..73277bd7e1 100644
--- a/indra/newview/llvoicewebrtc.cpp
+++ b/indra/newview/llvoicewebrtc.cpp
@@ -288,7 +288,26 @@ void LLWebRTCVoiceClient::initWebRTC()
mWebRTCDeviceInterface = llwebrtc::getDeviceInterface();
mWebRTCDeviceInterface->setDevicesObserver(this);
- mMainQueue = LL::WorkQueue::getInstance("mainloop");
+
+ if (!mVoiceWorkQueue)
+ {
+ mVoiceWorkQueue = std::make_shared<LL::WorkQueue>("VoiceWebRTC");
+ // Service this queue every idle tick, on the main thread.
+ doOnIdleRepeating(
+ [queue = LL::WorkQueue::weak_t(mVoiceWorkQueue)]() -> bool
+ {
+ auto locked = queue.lock();
+ if (!locked || locked->isClosed())
+ {
+ // Done
+ return true;
+ }
+ locked->runPending();
+ // Returning false means "call me again next idle".
+ return false;
+ });
+ }
+
refreshDeviceLists();
}
@@ -351,11 +370,11 @@ void LLWebRTCVoiceClient::drainConnections()
LLTimer timer;
while (!sessionState::allSessionsClosed() && timer.getElapsedTimeF32() < DRAIN_TIMEOUT_SECONDS)
{
- // OnPeerConnectionClosed comes back through the main queue, so it has
+ // OnPeerConnectionClosed comes back through the queue, so it has
// to be pumped or the state machines never see connections finish.
- if (auto main_queue = mMainQueue.lock())
+ if (mVoiceWorkQueue)
{
- main_queue->runFor(std::chrono::milliseconds(DRAIN_POLL_MS));
+ mVoiceWorkQueue->runFor(std::chrono::milliseconds(DRAIN_POLL_MS));
}
sessionState::processSessionStates();
@@ -707,7 +726,7 @@ void LLWebRTCVoiceClient::voiceConnectionCoro()
updatePosition();
}
}
- LL::WorkQueue::postMaybe(mMainQueue,
+ LL::WorkQueue::postMaybe(mVoiceWorkQueue,
[=, this] {
if (sShuttingDown)
{
@@ -829,7 +848,7 @@ void LLWebRTCVoiceClient::OnDevicesChanged(const llwebrtc::LLWebRTCVoiceDeviceLi
const llwebrtc::LLWebRTCVoiceDeviceList& capture_devices)
{
- LL::WorkQueue::postMaybe(mMainQueue,
+ LL::WorkQueue::postMaybe(mVoiceWorkQueue,
[=, this]
{
OnDevicesChangedImpl(render_devices, capture_devices);
@@ -2517,7 +2536,7 @@ LLVoiceWebRTCConnection::LLVoiceWebRTCConnection(const LLUUID &regionID, const s
mWebRTCPeerConnectionInterface = llwebrtc::newPeerConnection();
mWebRTCPeerConnectionInterface->setSignalingObserver(this);
- mMainQueue = LL::WorkQueue::getInstance("mainloop");
+ mVoiceMainQueue = LLWebRTCVoiceClient::getInstance()->getVoiceWorkQueue();
}
LLVoiceWebRTCConnection::~LLVoiceWebRTCConnection()
@@ -2551,7 +2570,7 @@ LLVoiceWebRTCConnection::~LLVoiceWebRTCConnection()
// callback from llwebrtc
void LLVoiceWebRTCConnection::OnIceGatheringState(llwebrtc::LLWebRTCSignalingObserver::EIceGatheringState state)
{
- LL::WorkQueue::postMaybe(mMainQueue,
+ LL::WorkQueue::postMaybe(mVoiceMainQueue,
[=, this] {
LL_DEBUGS("Voice") << "Ice Gathering voice account. " << state << LL_ENDL;
@@ -2575,7 +2594,7 @@ void LLVoiceWebRTCConnection::OnIceGatheringState(llwebrtc::LLWebRTCSignalingObs
// callback from llwebrtc
void LLVoiceWebRTCConnection::OnIceCandidate(const llwebrtc::LLWebRTCIceCandidate& candidate)
{
- LL::WorkQueue::postMaybe(mMainQueue, [=, this] { mIceCandidates.push_back(candidate); });
+ LL::WorkQueue::postMaybe(mVoiceMainQueue, [=, this] { mIceCandidates.push_back(candidate); });
}
void LLVoiceWebRTCConnection::processIceUpdates()
@@ -2691,7 +2710,7 @@ void LLVoiceWebRTCConnection::processIceUpdatesCoro(connectionPtr_t connection)
void LLVoiceWebRTCConnection::OnOfferAvailable(const std::string &sdp)
{
connectionPtr_t connection = shared_from_this();
- LL::WorkQueue::postMaybe(mMainQueue,
+ LL::WorkQueue::postMaybe(mVoiceMainQueue,
[=] {
if (connection->mShutDown)
{
@@ -2719,7 +2738,7 @@ void LLVoiceWebRTCConnection::OnOfferAvailable(const std::string &sdp)
void LLVoiceWebRTCConnection::OnAudioEstablished(llwebrtc::LLWebRTCAudioInterface* audio_interface)
{
connectionPtr_t connection = shared_from_this();
- LL::WorkQueue::postMaybe(mMainQueue,
+ LL::WorkQueue::postMaybe(mVoiceMainQueue,
[=] {
if (connection->mShutDown)
{
@@ -2742,7 +2761,7 @@ void LLVoiceWebRTCConnection::OnAudioEstablished(llwebrtc::LLWebRTCAudioInterfac
// callback from llwebrtc
void LLVoiceWebRTCConnection::OnRenegotiationNeeded()
{
- LL::WorkQueue::postMaybe(mMainQueue,
+ LL::WorkQueue::postMaybe(mVoiceMainQueue,
[=, this] {
LL_DEBUGS("Voice") << "Voice channel requires renegotiation." << LL_ENDL;
setVoiceConnectionState(VOICE_STATE_SESSION_RETRY);
@@ -2753,7 +2772,7 @@ void LLVoiceWebRTCConnection::OnRenegotiationNeeded()
// callback from llwebrtc
void LLVoiceWebRTCConnection::OnPeerConnectionClosed()
{
- LL::WorkQueue::postMaybe(mMainQueue,
+ LL::WorkQueue::postMaybe(mVoiceMainQueue,
[=, this] {
LL_DEBUGS("Voice") << "Peer connection has closed." << LL_ENDL;
if (mVoiceConnectionState == VOICE_STATE_WAIT_FOR_CLOSE)
@@ -3264,7 +3283,7 @@ bool LLVoiceWebRTCConnection::connectionStateMachine()
// llwebrtc callback
void LLVoiceWebRTCConnection::OnDataReceived(const std::string& data, bool binary)
{
- LL::WorkQueue::postMaybe(mMainQueue, [=, this] { LLVoiceWebRTCConnection::OnDataReceivedImpl(data, binary); });
+ LL::WorkQueue::postMaybe(mVoiceMainQueue, [=, this] { LLVoiceWebRTCConnection::OnDataReceivedImpl(data, binary); });
}
//
@@ -3493,7 +3512,7 @@ void LLVoiceWebRTCConnection::OnDataReceivedImpl(const std::string &data, bool b
void LLVoiceWebRTCConnection::OnDataChannelReady(llwebrtc::LLWebRTCDataInterface *data_interface)
{
connectionPtr_t connection = shared_from_this();
- LL::WorkQueue::postMaybe(mMainQueue,
+ LL::WorkQueue::postMaybe(mVoiceMainQueue,
[=] {
if (connection->mShutDown)
{
@@ -3535,7 +3554,7 @@ void LLVoiceWebRTCConnection::sendJoin()
void LLVoiceWebRTCConnection::OnStatsDelivered(const llwebrtc::LLWebRTCStatsMap& stats_data)
{
- LL::WorkQueue::postMaybe(mMainQueue, [=, this]
+ LL::WorkQueue::postMaybe(mVoiceMainQueue, [=, this]
{
if (mShutDown)
{
diff --git a/indra/newview/llvoicewebrtc.h b/indra/newview/llvoicewebrtc.h
index ec01b8c08c..87c31f389b 100644
--- a/indra/newview/llvoicewebrtc.h
+++ b/indra/newview/llvoicewebrtc.h
@@ -40,6 +40,7 @@ class LLWebRTCProtocolParser;
#include "llcoros.h"
#include "llparcel.h"
#include "llmutelist.h"
+#include "workqueue.h"
#include <queue>
#include "boost/json.hpp"
@@ -85,6 +86,8 @@ public:
// drainConnections() and ~LLVoiceWebRTCConnection().
static bool isWebRTCTerminated() { return sWebRTCTerminated; }
+ LL::WorkQueue::weak_t getVoiceWorkQueue() const { return mVoiceWorkQueue; }
+
const LLVoiceVersionInfo& getVersion() override;
void updateVersion();
@@ -468,7 +471,7 @@ private:
/// llwebrtc::terminate(). Bounded and best effort.
void drainConnections();
- LL::WorkQueue::weak_t mMainQueue;
+ LL::WorkQueue::ptr_t mVoiceWorkQueue;
F32 mTuningMicGain;
int mTuningSpeakerVolume;
@@ -688,7 +691,7 @@ class LLVoiceWebRTCConnection :
} EVoiceConnectionState;
EVoiceConnectionState mVoiceConnectionState;
- LL::WorkQueue::weak_t mMainQueue;
+ LL::WorkQueue::weak_t mVoiceMainQueue;
void setVoiceConnectionState(EVoiceConnectionState new_voice_connection_state)
{