Commit Graph

208 Commits (master)

Author SHA1 Message Date
Ansariel 8a55580fc9 Merge branch 'master' of https://github.com/FirestormViewer/phoenix-firestorm
# Conflicts:
#	indra/cmake/LLPhysicsExtensions.cmake
#	indra/newview/llvoicewebrtc.cpp
2025-11-17 23:26:11 +01:00
Hecklezz 834b198a87 Fix issue where mac was crashing during an attempt to unplug or replug microphone (FS:TJ- Cherry-pick to help fix FIRE-36022 on macOS)
The mac audio device manager was being "helpful" by restarting
playout and recording if the Default device was changed, assuming
the application wouldn't care.
However, we received an update of device change, and attempted to
stop and start playout anyway, causing a conflict.
The fix was simply to not deploy new devices when the device id didn't
change.
2025-11-02 01:10:19 +10:00
minerjr 9ee2595ac1 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.
2025-10-29 21:39:57 -03:00
minerjr b37a210e38 Fixed up the i prefix to g to follow coding standards
Changed iWebRTCUpdateDevices and iAudioDeviceMutex to gWebRTCUpdateDevicesand gAudioDeviceMutex to follow Firestorm coding standards.

They are global static variables.
2025-10-29 15:37:55 -03:00
minerjr f6ce46c726 Fixed up not python operator to proper C++ operator
Fixed up the follow Firestorm coding standards.
2025-10-29 15:21:51 -03:00
Ansariel ced6a24696 Merge branch 'release/2025.08' of https://github.com/secondlife/viewer
# Conflicts:
#	indra/newview/llviewermedia.cpp
#	indra/newview/llviewerwindow.cpp
2025-10-29 19:11:13 +01:00
Ansariel 3620dfdd35 Merge branch 'master' of https://github.com/FirestormViewer/phoenix-firestorm 2025-10-29 18:40:12 +01:00
minerjr 6ad9a57c39 FIRE-36022 - Removing my USB headset crashes entire viewer - audio device mutex
As with the previous change, this is to address the issue FIRE-36022 where users who remove their USB headsets with microphones are having the viewer lock up.

This introduces a new inline mutex called iAudioDeviceMutex. This is stored in a shared header file located on llcommon. iAudioDeviceMutex is a timed_mutex which allows for a time limit to be placed on a wait for a lock. Once the time runs out or the lock is achiveved the code moves on. With a check after the lock, if the owner is the current thread, then the lock was successful, otherwise it's still being used by another thread and the function should exit to try again later on.

This logic is wrapping WebRTC, FMOD and Vinvox calls to the audio hardware by the Viewer. OpenAL does not currently support changing of audio hardware and always defaults to the default audio hardware.

Added exceptions handling for the new unique_lock with the timed_mutex as they can throw 2 exceptions if the thread is already locked by the current thread and if the mutex is invalid.

Further testing may reveal other areas which would need the timed_mutex added to protect from threads locking up.
2025-10-28 23:22:13 -03:00
minerjr 0cdae450d8 FIRE-36022- Removing my USB headset crashes entire viewer - WebRTC fix
This is created to address the issue of USB headsets being removed or Bluetooth headsets with bad connections causing the viewer to lock up.

First Part: WebRTC

WebRTC now has an added inline atomic bool used to track when the worker thread is accessing the audio hardware. If the coroutine that is always running detects 10 consecutive true flag values, it will set WebRTC to exit and exit itself.

This coroutine was what was locking up the viewer as it spammed the mMainQueue with messages every update, but the worker thread was locked up and unable to receive the messages. Once the queue reached 1024 messages, it would lock up.

Underlying issue is the Windows Core Audio driver system crashes if too many threads have requests to get audio updates upon hardware changes. And with a USB headset having 2 devices in 1, it multiples the updates by 2x. The WebRTC audio system itself locks a mutex as it calls the core audio system to get set the input, but if it is already being processed by another thread, it then gets an exception to try again. The audio driver is not handling the message and crashes and does not return leaving the WebRTC worker thread locked.
2025-10-28 23:05:53 -03:00
Roxanne Skelly 164912418c
Fix issue where mac was crashing during an attempt to unplug or replug microphone. (#4897)
The mac audio device manager was being "helpful" by restarting
playout and recording if the Default device was changed, assuming
the application wouldn't care.
However, we received an update of device change, and attempted to
stop and start playout anyway, causing a conflict.
The fix was simply to not deploy new devices when the device id didn't
change.
2025-10-28 13:03:25 -04:00
Ansariel 3410a182c5 initWebRTC() can get multiple times - make sure to unset previous observers before re-adding 2025-10-18 13:32:44 +02:00
Ansariel eadf33f100 Merge branch 'master' of https://github.com/FirestormViewer/phoenix-firestorm-ll-master 2025-10-18 13:02:10 +02:00
Ansariel d733bef269 Restore original indentation 2025-10-18 12:42:20 +02:00
Ansariel 36217e7cb3 Merge branch 'master' of https://github.com/FirestormViewer/phoenix-firestorm
# Conflicts:
#	autobuild.xml
#	indra/llwebrtc/llwebrtc.cpp
#	indra/llwebrtc/llwebrtc_impl.h
#	indra/newview/llvoicewebrtc.cpp
#	indra/newview/llvoicewebrtc.h
2025-10-18 12:33:24 +02:00
Ansariel 9fe6e65aed Continue keeping built-in audio effects disabled - only disable duplicate call to updateDevices() which is already called via
LLWebRTCVoiceClient::initWebRTC() -> LLWebRTCVoiceClient::refreshDeviceLists() -> LLWebRTCImpl::refreshDevices()

and duplicate to

LLWebRTCVoiceClient::initWebRTC() -> llwebrtc::init() -> LLWebRTCImpl::init()
2025-10-18 12:26:47 +02:00
minerjr 4a6975a944 FIRE-36022 - Removing my USB headset crashes entire viewer
Commented out a block of new code recently added which was also being called by one of the callback functions.
This had the side effect of having 2 LLWebRTCDevicesObserver listening to the hardware removal events and cause both to trigger events at the same time, which may be the source of the queue being locked up in a race condition.

Was able to reproduce issue 2x without code change by moving mouse around a lot while on  rezing and then pulling USB headset out of the USB port. Direct motherboard USB port seemed to work the best as could not trigger while headset was in USB hub.
2025-10-17 22:01:17 -03:00
Jonathan "Geenz" Goodman bbc2ad8fc5 Merge remote-tracking branch 'origin/main' into geenz/main-to-develop 2025-10-17 17:06:39 -04:00
Andrey Kleshchev dc54661b3a #4819 WebRTC crashes after a failed login 2025-10-14 10:04:56 +02:00
Andrey Kleshchev 57a9e51360 #4819 WebRTC crashes after a failed login 2025-10-13 21:19:24 +03:00
Hecklezz 4855714b46 Updated CMakeLists.txt for LLWebRTC to fix compilation issues with the updated WebRTC 2025-10-13 14:37:32 +10:00
Andrey Kleshchev 0dcade5e1d #4695 Fix missing voice cleanup
Cleanup is in LLVoiceClient::terminate()
gWebRTCImpl was never deleted
Added mDeviceModule security
2025-10-12 16:34:56 +10:00
Roxanne Skelly 81c01ab5bc Fix indexing problem with mac devices (#4676)
* Fix indexing problem with mac devices

This resulted in the wrong device being selected.

Also, fix a shutdown crash where recording was not being stopped, hence the recording
thread was still running on shutdown and crashed because it lost access to resources.

Fix an issue with p2p calls where they're coming up muted even though the button indicates
they are unmuted.

* Always refresh device list on notification of device changes

Even when the selected device doesn't change, we need to
re-deploy it as it might have had characteristics (sampling rate, etc.) changed.

Also, we need to redeploy when the Default device has changed
2025-10-12 16:34:22 +10:00
Roxanne Skelly d070b996bd [WebRTC] Rework device handling sequence so that we can handle unplugging/re-plugging devices (#4593)
* [WebRTC] Rework device handling sequence so that we can handle unplugging/re-plugging devices

The device handling was not processing device updates in the proper sequence as
things like AEC use both input and output devices.  Devices like headsets are both
so unplugging them resulted in various mute conditions and sometimes even a crash.

Now, we update both capture and render devices at once in the proper sequence.

Test Guidance:
* Bring two users in the same place in webrtc regions.
* The 'listening' one should have a headset or something set oas 'Default'
* Press 'talk' on one, and verify the other can hear.
* Unplug the headset from the listening one.
* Validate that audio changes from the headset to the speakers.
* Plug the headset back in.
* Validate that audio changes from speakers to headset.
* Do the same type of test with the headset viewer talking.
* The microphone used should switch from the headset to the computer (it should have one)

Do other various device tests, such as setting devices explicitly, messing with the device selector, etc.

* Fix race condition when multiple change device requests might come in at once

* Update to m137

The primary feature of this commit is to update libwebrtc from m114
to m137.  This is needed to make webrtc buildable, as m114 is not buildable
by the current toolset.

m137 had some changes to the API, which required renaming or changing namespace
of some of the calls.

Additionally, this PR moves from a callback mechanism for gathering the energy
levels for tuning to a wrapper AudioDeviceModule, which gives us more control
over the audio stream.

Finally, the new m137-based webrtc has been updated to allow for 192khz audio
streams.

* Properly pass the observer setting into the inner audio device module

* Update to m137 and get rid of some noise

    This change updates to m137 from m114, which required a few API changes.

    Additionally, this fixes the hiss that happens shortly after someone unmutes: https://github.com/secondlife/server/issues/2094

    There was also an issue with a slight amount of repeated after unmuting if there was audio right before unmuting.  This is because
    the audio processing and buffering still had audio from the previous speaking session.  Now, we inject nearly a half second of
    silence into the audio buffers/processor after unmuting to flush things.

* Install nsis on windows

* Use the newer digital AGC pipeline

m137 improved the AGC pipeline and the existing analog style is going away
so move to the new digital pipeline.

Also, some tweaking for audio levels so that we don't see inworld bars when tuning,
so one's own bars seem a reasonable size, etc.

* Install NSIS during windows sisgning and package build step

* Try pinning the packaging to windows 2022 to deal with missing nsis

* Adjust gain calculation and audio level calculations for tuning and peer connections

* Update with mac universal webrtc build

* Tuning of voice indicators for both tuning mode and inworld for self.

* Redo device deployment to handle cases where multiple deploy requests pile up

Also, mute when leaving webrtc-enabled regions or parcels,
and unmute when voice comes back.

* pre commit issue
2025-10-12 16:32:18 +10:00
Ansariel e7b3d68cab Merge branch 'develop' of https://github.com/secondlife/viewer
# Conflicts:
#	autobuild.xml
#	indra/cmake/LLPhysicsExtensions.cmake
#	indra/llprimitive/CMakeLists.txt
#	indra/newview/CMakeLists.txt
#	indra/newview/lltexturectrl.cpp
#	indra/newview/llviewerobject.cpp
#	indra/newview/llviewertexture.cpp
#	indra/newview/llviewerwindow.cpp
#	indra/newview/llvovolume.cpp
#	indra/newview/skins/default/xui/en/floater_marketplace.xml
#	indra/newview/skins/default/xui/en/floater_model_preview.xml
#	indra/newview/skins/default/xui/en/floater_search.xml
2025-10-11 18:51:03 +02:00
Andrey Kleshchev 400351f3b8 #4777 Fix crash on missing factory 2025-10-09 23:59:51 +03:00
Andrey Kleshchev d76d0c239c #4796 Preferences' mic volume slider had no effect. 2025-10-08 17:33:48 +03:00
Andrey Kleshchev f846861f04 #4777 Fix webrtc crashing in worker threads on shutdown 2025-10-03 19:07:00 +03:00
Ansariel 3717122cb9 Merge branch 'release/2025.07' of https://github.com/secondlife/viewer
# Conflicts:
#	indra/newview/llappviewer.cpp
2025-09-23 10:01:04 +02:00
Andrey Kleshchev 3ff163887d #4695 Fix missing voice cleanup
Cleanup is in LLVoiceClient::terminate()
gWebRTCImpl was never deleted
Added mDeviceModule security
2025-09-20 00:32:04 +03:00
Roxanne Skelly c743ea2b6d
Fix indexing problem with mac devices (#4676)
* Fix indexing problem with mac devices

This resulted in the wrong device being selected.

Also, fix a shutdown crash where recording was not being stopped, hence the recording
thread was still running on shutdown and crashed because it lost access to resources.

Fix an issue with p2p calls where they're coming up muted even though the button indicates
they are unmuted.

* Always refresh device list on notification of device changes

Even when the selected device doesn't change, we need to
re-deploy it as it might have had characteristics (sampling rate, etc.) changed.

Also, we need to redeploy when the Default device has changed
2025-09-16 13:36:26 -04:00
Ansariel 5fdef7863e Merge branch 'release/2025.07' of https://github.com/secondlife/viewer
# Conflicts:
#	indra/newview/skins/default/xui/en/menu_inventory.xml
2025-09-16 18:33:02 +02:00
Roxanne Skelly a6d4c1d394
[WebRTC] Rework device handling sequence so that we can handle unplugging/re-plugging devices (#4593)
* [WebRTC] Rework device handling sequence so that we can handle unplugging/re-plugging devices

The device handling was not processing device updates in the proper sequence as
things like AEC use both input and output devices.  Devices like headsets are both
so unplugging them resulted in various mute conditions and sometimes even a crash.

Now, we update both capture and render devices at once in the proper sequence.

Test Guidance:
* Bring two users in the same place in webrtc regions.
* The 'listening' one should have a headset or something set oas 'Default'
* Press 'talk' on one, and verify the other can hear.
* Unplug the headset from the listening one.
* Validate that audio changes from the headset to the speakers.
* Plug the headset back in.
* Validate that audio changes from speakers to headset.
* Do the same type of test with the headset viewer talking.
* The microphone used should switch from the headset to the computer (it should have one)

Do other various device tests, such as setting devices explicitly, messing with the device selector, etc.

* Fix race condition when multiple change device requests might come in at once

* Update to m137

The primary feature of this commit is to update libwebrtc from m114
to m137.  This is needed to make webrtc buildable, as m114 is not buildable
by the current toolset.

m137 had some changes to the API, which required renaming or changing namespace
of some of the calls.

Additionally, this PR moves from a callback mechanism for gathering the energy
levels for tuning to a wrapper AudioDeviceModule, which gives us more control
over the audio stream.

Finally, the new m137-based webrtc has been updated to allow for 192khz audio
streams.

* Properly pass the observer setting into the inner audio device module

* Update to m137 and get rid of some noise

    This change updates to m137 from m114, which required a few API changes.

    Additionally, this fixes the hiss that happens shortly after someone unmutes: https://github.com/secondlife/server/issues/2094

    There was also an issue with a slight amount of repeated after unmuting if there was audio right before unmuting.  This is because
    the audio processing and buffering still had audio from the previous speaking session.  Now, we inject nearly a half second of
    silence into the audio buffers/processor after unmuting to flush things.

* Install nsis on windows

* Use the newer digital AGC pipeline

m137 improved the AGC pipeline and the existing analog style is going away
so move to the new digital pipeline.

Also, some tweaking for audio levels so that we don't see inworld bars when tuning,
so one's own bars seem a reasonable size, etc.

* Install NSIS during windows sisgning and package build step

* Try pinning the packaging to windows 2022 to deal with missing nsis

* Adjust gain calculation and audio level calculations for tuning and peer connections

* Update with mac universal webrtc build

* Tuning of voice indicators for both tuning mode and inworld for self.

* Redo device deployment to handle cases where multiple deploy requests pile up

Also, mute when leaving webrtc-enabled regions or parcels,
and unmute when voice comes back.

* pre commit issue
2025-09-12 20:07:51 -04:00
Ansariel b99cf9fb86 Merge branch 'project/mac_universal' of https://github.com/secondlife/viewer
# Conflicts:
#	autobuild.xml
#	indra/cmake/00-Common.cmake
#	indra/cmake/APR.cmake
#	indra/cmake/Audio.cmake
#	indra/cmake/Boost.cmake
#	indra/cmake/Copy3rdPartyLibs.cmake
#	indra/cmake/LLKDU.cmake
#	indra/cmake/LLPrimitive.cmake
#	indra/cmake/Meshoptimizer.cmake
#	indra/cmake/NGHTTP2.cmake
#	indra/cmake/OPENAL.cmake
#	indra/llaudio/llvorbisencode.cpp
#	indra/llcommon/linden_common.h
#	indra/llcommon/llcommon.cpp
#	indra/llcommon/llfasttimer.cpp
#	indra/llcommon/llfasttimer.h
#	indra/llcommon/llfile.cpp
#	indra/llcommon/llmemory.h
#	indra/llcommon/llprofiler.h
#	indra/llcommon/llthreadsafequeue.h
#	indra/llfilesystem/lldir_win32.cpp
#	indra/llkdu/llimagej2ckdu.cpp
#	indra/llkdu/llimagej2ckdu.h
#	indra/llkdu/llkdumem.h
#	indra/llplugin/slplugin/CMakeLists.txt
#	indra/llrender/llfontfreetype.cpp
#	indra/llrender/llfontfreetype.h
#	indra/llwindow/CMakeLists.txt
#	indra/llwindow/llopenglview-objc.mm
#	indra/llwindow/llwindowmacosx-objc.h
#	indra/llwindow/llwindowwin32.cpp
#	indra/media_plugins/cef/CMakeLists.txt
#	indra/newview/CMakeLists.txt
#	indra/newview/llappviewer.cpp
#	indra/newview/llface.cpp
#	indra/newview/pipeline.cpp
#	indra/newview/viewer_manifest.py
2025-09-05 14:55:37 +02:00
Rye ba30737d8f Merge branch 'develop' of github.com:secondlife/viewer into rye/infinitemac 2025-08-20 18:04:55 -04:00
Ansariel 478a51f8e3 Merge branch 'release/2025.06' of https://github.com/secondlife/viewer
# Conflicts:
#	indra/llxml/llcontrol.cpp
#	indra/newview/llfloaterpreference.cpp
#	indra/newview/lllogchat.cpp
#	indra/newview/llreflectionmap.h
2025-08-13 20:52:47 +02:00
Roxie Linden bab2c12d04 Straighten out muting to prevent echo when crossing from vivox to webrtc regions.
Muting was a bit random in the code, so it's now been straightened out and should
prevent echo.

Also, code was added to not attempt connection to non-webrtc regions in the webrtc code.
2025-08-08 14:37:46 -07:00
Ansariel a4e8af0dce Merge branch 'develop' of https://github.com/secondlife/viewer
# Conflicts:
#	.github/pull_request_template.md
#	CONTRIBUTING.md
#	indra/newview/CMakeLists.txt
#	indra/newview/app_settings/settings.xml
#	indra/newview/llappviewer.cpp
#	indra/newview/llfloaterimagepreview.cpp
#	indra/newview/llfloatersettingsdebug.cpp
#	indra/newview/llfloatersettingsdebug.h
#	indra/newview/llstatusbar.cpp
#	indra/newview/llstatusbar.h
#	indra/newview/res/viewerRes.rc
#	indra/newview/skins/default/xui/de/panel_login_first.xml
#	indra/newview/skins/default/xui/en/notifications.xml
#	indra/newview/skins/default/xui/en/panel_login_first.xml
#	indra/newview/skins/default/xui/en/panel_preferences_advanced.xml
#	indra/newview/skins/default/xui/en/panel_preferences_privacy.xml
#	indra/newview/skins/default/xui/en/panel_status_bar.xml
#	indra/newview/skins/default/xui/es/panel_login_first.xml
#	indra/newview/skins/default/xui/fr/panel_login_first.xml
#	indra/newview/skins/default/xui/it/panel_login_first.xml
#	indra/newview/skins/default/xui/ja/panel_login_first.xml
#	indra/newview/skins/default/xui/pl/panel_login_first.xml
#	indra/newview/skins/default/xui/pt/panel_login_first.xml
#	indra/newview/skins/default/xui/ru/panel_login_first.xml
#	indra/newview/skins/default/xui/tr/panel_login_first.xml
#	indra/newview/skins/default/xui/zh/panel_login_first.xml
#	indra/newview/viewer_manifest.py
2025-07-30 10:52:39 +02:00
Andrey Kleshchev be04175579 #4358 Fix 'Microphone in use' task bar icon
1. set_enabled(false) failed to apply, force set it to trigger observers
and remove the icon
2. Don't set audio devices if voice was disabled
2025-07-16 20:05:23 +03:00
Ansariel 469795979f Merge branch 'release/2025.04' of https://github.com/secondlife/viewer
# Conflicts:
#	indra/newview/llinventorybridge.cpp
#	indra/newview/llmodelpreview.cpp
#	indra/newview/llpanelface.cpp
#	indra/newview/llviewercamera.cpp
#	indra/newview/llviewerregion.cpp
#	indra/newview/skins/default/colors.xml
2025-05-14 21:56:38 +02:00
Andrey Kleshchev edb0032c95 #3542 Microphone doesn't switch after plugging in an audio device 2025-05-10 10:11:53 +03:00
Rye 7bba6b835f Update dependencies with support for apple silicon 2025-02-11 05:04:06 -05:00
Beq 549dc802a8 Tentative fix for Linux WebRTC hang from Roxie. 2024-10-28 15:48:59 +00:00
Ansariel 830eeaa6ff Merge branch 'develop' of https://github.com/secondlife/viewer
# Conflicts:
#	indra/newview/llagentwearables.cpp
#	indra/newview/llface.cpp
#	indra/newview/llpanelpeople.cpp
#	indra/newview/llpanelprofile.cpp
#	indra/newview/llviewertexturelist.cpp
2024-08-21 00:46:46 +02:00
Brad Linden 68f712615f Merge remote-tracking branch 'origin/release/2024.06-atlasaurus' into develop
# Conflicts:
 #	autobuild.xml
 #	indra/newview/llvoicewebrtc.cpp
2024-08-20 09:44:14 -07:00
Roxie Linden de0b5afa25 Merge branch 'roxie/webrtc-airpod-fixes' of github.com:secondlife/viewer into roxie/webrtc-airpod-fixes 2024-08-18 23:10:00 -07:00
Roxie Linden 226f7bc5b7 Use the release build of webrtc to avoid pedantic asserts which are handled properly anyway. 2024-08-18 23:07:29 -07:00
Roxie Linden 28fdd6e786 Update webrtc to fix loss of stereo in bluetooth issue.
When transitioning from mic-on hands-free mode to mic off,
it's expected that the audio stream would return to stereo.
Inproper logic in the mac device code in webrtc was preventing
that.
2024-08-18 00:30:16 -07:00
Roxie Linden 63d17b395b Microphone was being prematurely enabled on login for a short period.
The microphone issue was causing a short moment of sound, and was
causing bluetooth headsets to switch to hands-free/one channel mode
which is disruptive.

Also, update webrtc to deal with issue where airpods were garbled
after coming out of hands-free mode.
2024-08-17 20:11:46 -07:00
Roxie Linden 2efad2182a Fixes to managing device start/stop playout/recording.
Fixes prevent attempting to start playout/recording before the devices
are set up, to prevent restarting playout/recording, to prevent
attempts to stop when not playing/recording, and so on...

This should address the case where audio device changes can cause
an assert.  It should also address the case where audio was unnecessarily played
or transmitted when connecting.

And, when voice is disabled, the audio devices are not set up to play/record
so there should be no disruption of bluetooth music from other apps.
2024-08-17 00:26:07 -07:00
Ansariel 028933621e Merge branch 'master' of https://bitbucket.org/Ansariel/phoenix-firestorm-atlasaurus
# Conflicts:
#	indra/llui/llscrolllistctrl.cpp
2024-08-10 13:57:24 +02:00