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.
This commit is contained in:
minerjr
2025-10-29 21:39:57 -03:00
parent b37a210e38
commit 9ee2595ac1
4 changed files with 16 additions and 16 deletions
+4 -4
View File
@@ -134,8 +134,8 @@ static FMOD_RESULT F_CALL systemCallback(FMOD_SYSTEM *system, FMOD_SYSTEM_CALLBA
if (sys && audio_engine)
{
// <FS:minerjr> [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)
// <FS:minerjr> [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())
+8 -8
View File
@@ -477,8 +477,8 @@ void LLWebRTCImpl::workerDeployDevices()
// <FS:minerjr> [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()
// <FS:minerjr> [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())
+2 -2
View File
@@ -2419,8 +2419,8 @@ void LLVivoxVoiceClient::sendCaptureAndRenderDevices()
// <FS:minerjr> [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())
+2 -2
View File
@@ -763,8 +763,8 @@ void LLWebRTCVoiceClient::OnDevicesChangedImpl(const llwebrtc::LLWebRTCVoiceDevi
// <FS:minerjr> [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())