summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/llwebrtc/llwebrtc.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/indra/llwebrtc/llwebrtc.cpp b/indra/llwebrtc/llwebrtc.cpp
index 8e08239ee6..39cecbda25 100644
--- a/indra/llwebrtc/llwebrtc.cpp
+++ b/indra/llwebrtc/llwebrtc.cpp
@@ -733,12 +733,17 @@ void LLWebRTCImpl::intSetMute(bool mute, int delay_ms)
{
mPeerCustomProcessor->setGain(mMute ? 0.0f : mGain);
}
+
+ // Sequence counter to prevent race conditions from rapid requests to mute/unmute
+ static std::atomic<uint32_t> mute_sequence(0);
+ uint32_t current_sequence = ++mute_sequence;
+
if (mMute)
{
mWorkerThread->PostDelayedTask(
- [this]
+ [this, current_sequence]
{
- if (mDeviceModule)
+ if (mDeviceModule && (current_sequence == mute_sequence.load()))
{
mDeviceModule->ForceStopRecording();
}
@@ -748,9 +753,9 @@ void LLWebRTCImpl::intSetMute(bool mute, int delay_ms)
else
{
mWorkerThread->PostTask(
- [this]
+ [this, current_sequence]
{
- if (mDeviceModule)
+ if (mDeviceModule && (current_sequence == mute_sequence.load()))
{
mDeviceModule->InitRecording();
mDeviceModule->ForceStartRecording();