summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoxanne Skelly <roxie@lindenlab.com>2025-09-16 10:36:26 -0700
committerGitHub <noreply@github.com>2025-09-16 13:36:26 -0400
commitc743ea2b6dc60312b29f2fb5972171ead26ee448 (patch)
tree1cd337bac295ae4ea76ba650dac668106611c419
parent7ec9736200d9f1a719e15462fac0a0f94cdd83af (diff)
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
-rw-r--r--indra/llwebrtc/llwebrtc.cpp48
-rw-r--r--indra/llwebrtc/llwebrtc_impl.h6
2 files changed, 31 insertions, 23 deletions
diff --git a/indra/llwebrtc/llwebrtc.cpp b/indra/llwebrtc/llwebrtc.cpp
index edba2bee9a..23e1076765 100644
--- a/indra/llwebrtc/llwebrtc.cpp
+++ b/indra/llwebrtc/llwebrtc.cpp
@@ -350,6 +350,16 @@ void LLWebRTCImpl::init()
void LLWebRTCImpl::terminate()
{
+ mWorkerThread->BlockingCall(
+ [this]()
+ {
+ if (mDeviceModule)
+ {
+ mDeviceModule->ForceStopRecording();
+ mDeviceModule->StopPlayout();
+ }
+ });
+
for (auto &connection : mPeerConnections)
{
connection->terminate();
@@ -368,8 +378,6 @@ void LLWebRTCImpl::terminate()
{
if (mDeviceModule)
{
- mDeviceModule->StopRecording();
- mDeviceModule->StopPlayout();
mDeviceModule->Terminate();
}
mDeviceModule = nullptr;
@@ -442,11 +450,7 @@ void LLWebRTCImpl::unsetDevicesObserver(LLWebRTCDevicesObserver *observer)
void LLWebRTCImpl::workerDeployDevices()
{
int16_t recordingDevice = RECORD_DEVICE_DEFAULT;
-#if WEBRTC_WIN
int16_t recording_device_start = 0;
-#else
- int16_t recording_device_start = 1;
-#endif
if (mRecordingDevice != "Default")
{
@@ -455,6 +459,12 @@ void LLWebRTCImpl::workerDeployDevices()
if (mRecordingDeviceList[i].mID == mRecordingDevice)
{
recordingDevice = i;
+#if !WEBRTC_WIN
+ // linux and mac devices range from 1 to the end of the list, with the index 0 being the
+ // 'default' device. Windows has a special 'default' device and other devices are indexed
+ // from 0
+ recordingDevice++;
+#endif
break;
}
}
@@ -479,11 +489,7 @@ void LLWebRTCImpl::workerDeployDevices()
mDeviceModule->InitRecording();
int16_t playoutDevice = PLAYOUT_DEVICE_DEFAULT;
-#if WEBRTC_WIN
int16_t playout_device_start = 0;
-#else
- int16_t playout_device_start = 1;
-#endif
if (mPlayoutDevice != "Default")
{
for (int16_t i = playout_device_start; i < mPlayoutDeviceList.size(); i++)
@@ -491,6 +497,12 @@ void LLWebRTCImpl::workerDeployDevices()
if (mPlayoutDeviceList[i].mID == mPlayoutDevice)
{
playoutDevice = i;
+#if !WEBRTC_WIN
+ // linux and mac devices range from 1 to the end of the list, with the index 0 being the
+ // 'default' device. Windows has a special 'default' device and other devices are indexed
+ // from 0
+ playoutDevice++;
+#endif
break;
}
}
@@ -546,20 +558,14 @@ void LLWebRTCImpl::workerDeployDevices()
void LLWebRTCImpl::setCaptureDevice(const std::string &id)
{
- if (mRecordingDevice != id)
- {
- mRecordingDevice = id;
- deployDevices();
- }
+ mRecordingDevice = id;
+ deployDevices();
}
void LLWebRTCImpl::setRenderDevice(const std::string &id)
{
- if (mPlayoutDevice != id)
- {
- mPlayoutDevice = id;
- deployDevices();
- }
+ mPlayoutDevice = id;
+ deployDevices();
}
// updateDevices needs to happen on the worker thread.
@@ -609,7 +615,7 @@ void LLWebRTCImpl::updateDevices()
void LLWebRTCImpl::OnDevicesUpdated()
{
- deployDevices();
+ updateDevices();
}
diff --git a/indra/llwebrtc/llwebrtc_impl.h b/indra/llwebrtc/llwebrtc_impl.h
index 51d42c82b2..dee081119b 100644
--- a/indra/llwebrtc/llwebrtc_impl.h
+++ b/indra/llwebrtc/llwebrtc_impl.h
@@ -239,8 +239,10 @@ public:
return 0;
}
int32_t StopRecording() override {
- if (tuning_) return 0; // if we're tuning, disregard the StopRecording we get from disabling the streams
- return inner_->StopRecording();
+ // ignore stop recording as webrtc.lib will send one when streams shut down,
+ // even if there are other streams in place. Start/Stop recording are entirely
+ // controlled by the app
+ return 0;
}
int32_t ForceStartRecording() { return inner_->StartRecording(); }
int32_t ForceStopRecording() { return inner_->StopRecording(); }