From 9ee2595ac196ec08264c9f271e8a7ac757d21cea Mon Sep 17 00:00:00 2001 From: minerjr Date: Wed, 29 Oct 2025 21:39:57 -0300 Subject: [PATCH] Reduced the time_mutx lock to 1 second from 3 seconds Originally setup with 3 second as a was not sure how long it would take to recover, but 1 second should be good to recover and enumerate devices. --- indra/llaudio/llaudioengine_fmodstudio.cpp | 8 ++++---- indra/llwebrtc/llwebrtc.cpp | 16 ++++++++-------- indra/newview/llvoicevivox.cpp | 4 ++-- indra/newview/llvoicewebrtc.cpp | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/indra/llaudio/llaudioengine_fmodstudio.cpp b/indra/llaudio/llaudioengine_fmodstudio.cpp index ddac609b85..7daaea1c76 100644 --- a/indra/llaudio/llaudioengine_fmodstudio.cpp +++ b/indra/llaudio/llaudioengine_fmodstudio.cpp @@ -134,8 +134,8 @@ static FMOD_RESULT F_CALL systemCallback(FMOD_SYSTEM *system, FMOD_SYSTEM_CALLBA if (sys && audio_engine) { // [FIRE-36022] - Removing my USB headset crashes entire viewer - // Attempt to lock the access to the audio device, wait up to 3 seconds for other threads to unlock. - std::unique_lock lock(gAudioDeviceMutex, 3s); + // Attempt to lock the access to the audio device, wait up to 1 second for other threads to unlock. + std::unique_lock lock(gAudioDeviceMutex, 1s); // If the lock could not be accessed, return as we don't have hardware access and will need to try again another pass. // Prevents threads from interacting with the hardware at the same time as other audio/voice threads. if (!lock.owns_lock()) @@ -429,8 +429,8 @@ void LLAudioEngine_FMODSTUDIO::setDevice(const LLUUID& device_uuid) // [FIRE-36022] - Removing my USB headset crashes entire viewer try // Try catch needed for uniquie lock as will throw an exception if a second lock is attempted or the mutex is invalid { - // Attempt to lock the access to the audio device, wait up to 3 seconds for other threads to unlock. - std::unique_lock lock(gAudioDeviceMutex, 3s); + // Attempt to lock the access to the audio device, wait up to 1 second for other threads to unlock. + std::unique_lock lock(gAudioDeviceMutex, 1s); // If the lock could not be accessed, return as we don't have hardware access and will need to try again another pass. // Prevents threads from interacting with the hardware at the same time as other audio/voice threads. if (!lock.owns_lock()) diff --git a/indra/llwebrtc/llwebrtc.cpp b/indra/llwebrtc/llwebrtc.cpp index 26e05118da..860f619885 100644 --- a/indra/llwebrtc/llwebrtc.cpp +++ b/indra/llwebrtc/llwebrtc.cpp @@ -477,8 +477,8 @@ void LLWebRTCImpl::workerDeployDevices() // [FIRE-36022] - Removing my USB headset crashes entire viewer try // Try catch needed for uniquie lock as will throw an exception if a second lock is attempted or the mutex is invalid { - // Attempt to lock the access to the audio device, wait up to 3 seconds for other threads to unlock. - std::unique_lock lock(gAudioDeviceMutex, 3s); + // Attempt to lock the access to the audio device, wait up to 1 second for other threads to unlock. + std::unique_lock lock(gAudioDeviceMutex, 1s); // If the lock could not be accessed, return as we don't have hardware access and will need to try again another pass. // Prevents threads from interacting with the hardware at the same time as other audio/voice threads. if (!lock.owns_lock()) @@ -660,8 +660,8 @@ void LLWebRTCImpl::updateDevices() // [FIRE-36022] - Removing my USB headset crashes entire viewer try // Try catch needed for uniquie lock as will throw an exception if a second lock is attempted or the mutex is invalid { - // Attempt to lock the access to the audio device, wait up to 3 seconds for other threads to unlock. - std::unique_lock lock(gAudioDeviceMutex, 3s); + // Attempt to lock the access to the audio device, wait up to 1 second for other threads to unlock. + std::unique_lock lock(gAudioDeviceMutex, 1s); // If the lock could not be accessed, return as we don't have hardware access and will need to try again another pass. // Prevents threads from interacting with the hardware at the same time as other audio/voice threads. if (!lock.owns_lock()) @@ -855,8 +855,8 @@ void LLWebRTCImpl::intSetMute(bool mute, int delay_ms) try // Try catch needed for uniquie lock as will throw an exception if a second lock is attempted or the mutex is // invalid { - // Attempt to lock the access to the audio device, wait up to 3 seconds for other threads to unlock. - std::unique_lock lock(gAudioDeviceMutex, 3s); + // Attempt to lock the access to the audio device, wait up to 1 second for other threads to unlock. + std::unique_lock lock(gAudioDeviceMutex, 1s); // If the lock could not be accessed, return as we don't have hardware access and will need to try again another pass. // Prevents threads from interacting with the hardware at the same time as other audio/voice threads. if (!lock.owns_lock()) @@ -916,8 +916,8 @@ void LLWebRTCImpl::intSetMute(bool mute, int delay_ms) try // Try catch needed for uniquie lock as will throw an exception if a second lock is attempted or the mutex is // invalid { - // Attempt to lock the access to the audio device, wait up to 3 seconds for other threads to unlock. - std::unique_lock lock(gAudioDeviceMutex, 3s); + // Attempt to lock the access to the audio device, wait up to 1 second for other threads to unlock. + std::unique_lock lock(gAudioDeviceMutex, 1s); // If the lock could not be accessed, return as we don't have hardware access and will need to try again another pass. // Prevents threads from interacting with the hardware at the same time as other audio/voice threads. if (!lock.owns_lock()) diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index 3c8b091a48..e45ab3d3bd 100644 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -2419,8 +2419,8 @@ void LLVivoxVoiceClient::sendCaptureAndRenderDevices() // [FIRE-36022] - Removing my USB headset crashes entire viewer try // Try catch needed for uniquie lock as will throw an exception if a second lock is attempted or the mutex is invalid { - // Attempt to lock the access to the audio device, wait up to 3 seconds for other threads to unlock. - std::unique_lock lock(gAudioDeviceMutex, 3s); + // Attempt to lock the access to the audio device, wait up to 1 second for other threads to unlock. + std::unique_lock lock(gAudioDeviceMutex, 1s); // If the lock could not be accessed, return as we don't have hardware access and will need to try again another pass. // Prevents threads from interacting with the hardware at the same time as other audio/voice threads. if (!lock.owns_lock()) diff --git a/indra/newview/llvoicewebrtc.cpp b/indra/newview/llvoicewebrtc.cpp index 2d13a62904..cfc9456582 100644 --- a/indra/newview/llvoicewebrtc.cpp +++ b/indra/newview/llvoicewebrtc.cpp @@ -763,8 +763,8 @@ void LLWebRTCVoiceClient::OnDevicesChangedImpl(const llwebrtc::LLWebRTCVoiceDevi // [FIRE-36022] - Removing my USB headset crashes entire viewer try // Try catch needed for uniquie lock as will throw an exception if a second lock is attempted or the mutex is invalid { - // Attempt to lock the access to the audio device, wait up to 3 seconds for other threads to unlock. - std::unique_lock lock(gAudioDeviceMutex, 3s); + // Attempt to lock the access to the audio device, wait up to 1 second for other threads to unlock. + std::unique_lock lock(gAudioDeviceMutex, 1s); // If the lock could not be accessed, return as we don't have hardware access and will need to try again another pass. // Prevents threads from interacting with the hardware at the same time as other audio/voice threads. if (!lock.owns_lock())