diff options
author | Roxie Linden <roxie@lindenlab.com> | 2024-02-03 22:02:48 -0800 |
---|---|---|
committer | Roxie Linden <roxie@lindenlab.com> | 2024-02-08 18:35:55 -0800 |
commit | 73b00bfe94a6a2a4ea0abc2cf716d835820dfdba (patch) | |
tree | 196df21e1794bf7ac2afaa9295bf232a32a98a90 | |
parent | fd077d8a9b5e2a5d3971b4bcae06f5ee39e6c53b (diff) |
Handle 'device changed' callback
-rw-r--r-- | indra/llwebrtc/llwebrtc.cpp | 22 | ||||
-rw-r--r-- | indra/llwebrtc/llwebrtc.h | 9 | ||||
-rw-r--r-- | indra/llwebrtc/llwebrtc_impl.h | 7 | ||||
-rw-r--r-- | indra/newview/llvoicewebrtc.cpp | 27 | ||||
-rw-r--r-- | indra/newview/llvoicewebrtc.h | 1 |
5 files changed, 55 insertions, 11 deletions
diff --git a/indra/llwebrtc/llwebrtc.cpp b/indra/llwebrtc/llwebrtc.cpp index 900698aa56..d6eff5e1f2 100644 --- a/indra/llwebrtc/llwebrtc.cpp +++ b/indra/llwebrtc/llwebrtc.cpp @@ -113,6 +113,7 @@ void LLWebRTCImpl::init() mTuningDeviceModule->SetStereoRecording(true); mTuningDeviceModule->SetStereoPlayout(true); mTuningDeviceModule->EnableBuiltInAEC(false); + mTuningDeviceModule->SetAudioDeviceSink(this); updateDevices(); }); @@ -379,31 +380,42 @@ void LLWebRTCImpl::setRenderDevice(const std::string &id) void LLWebRTCImpl::updateDevices() { - int16_t renderDeviceCount = mTuningDeviceModule->PlayoutDevices(); + int16_t renderDeviceCount = mTuningDeviceModule->PlayoutDevices(); + int16_t currentRenderDeviceIndex = mTuningDeviceModule->GetPlayoutDevice(); + LLWebRTCVoiceDeviceList renderDeviceList; for (int16_t index = 0; index < renderDeviceCount; index++) { char name[webrtc::kAdmMaxDeviceNameSize]; char guid[webrtc::kAdmMaxGuidSize]; mTuningDeviceModule->PlayoutDeviceName(index, name, guid); - renderDeviceList.emplace_back(name, guid); + renderDeviceList.emplace_back(name, guid, index == currentRenderDeviceIndex); } - int16_t captureDeviceCount = mTuningDeviceModule->RecordingDevices(); + int16_t captureDeviceCount = mTuningDeviceModule->RecordingDevices(); + int16_t currentCaptureDeviceIndex = mTuningDeviceModule->GetRecordingDevice(); + LLWebRTCVoiceDeviceList captureDeviceList; for (int16_t index = 0; index < captureDeviceCount; index++) { char name[webrtc::kAdmMaxDeviceNameSize]; char guid[webrtc::kAdmMaxGuidSize]; mTuningDeviceModule->RecordingDeviceName(index, name, guid); - captureDeviceList.emplace_back(name, guid); + captureDeviceList.emplace_back(name, guid, index == currentCaptureDeviceIndex); } for (auto &observer : mVoiceDevicesObserverList) { - observer->OnDevicesChanged(renderDeviceList, captureDeviceList); + observer->OnDevicesChanged(renderDeviceList, + captureDeviceList); } } +void LLWebRTCImpl::OnDevicesUpdated() +{ + updateDevices(); +} + + void LLWebRTCImpl::setTuningMode(bool enable) { mWorkerThread->BlockingCall( diff --git a/indra/llwebrtc/llwebrtc.h b/indra/llwebrtc/llwebrtc.h index f84e998245..e7effdfbb8 100644 --- a/indra/llwebrtc/llwebrtc.h +++ b/indra/llwebrtc/llwebrtc.h @@ -56,11 +56,14 @@ class LLWebRTCVoiceDevice { public: std::string display_name; // friendly value for the user - std::string id; // internal value for selection + std::string id; // internal value for selection + bool current; // current device - LLWebRTCVoiceDevice(const std::string &display_name, const std::string &id) : + LLWebRTCVoiceDevice(const std::string &display_name, const std::string &id, bool current) : display_name(display_name), - id(id) {}; + id(id), + current(current) + {}; }; typedef std::vector<LLWebRTCVoiceDevice> LLWebRTCVoiceDeviceList; diff --git a/indra/llwebrtc/llwebrtc_impl.h b/indra/llwebrtc/llwebrtc_impl.h index 884e107527..3ccb6058ad 100644 --- a/indra/llwebrtc/llwebrtc_impl.h +++ b/indra/llwebrtc/llwebrtc_impl.h @@ -89,7 +89,7 @@ class LLAudioDeviceObserver : public webrtc::AudioDeviceDataObserver float mMicrophoneEnergy; }; -class LLWebRTCImpl : public LLWebRTCDeviceInterface +class LLWebRTCImpl : public LLWebRTCDeviceInterface, public webrtc::AudioDeviceSink { public: LLWebRTCImpl() : @@ -118,6 +118,11 @@ class LLWebRTCImpl : public LLWebRTCDeviceInterface float getPeerAudioLevel() override; // + // AudioDeviceSink + // + void OnDevicesUpdated() override; + + // // Helpers // diff --git a/indra/newview/llvoicewebrtc.cpp b/indra/newview/llvoicewebrtc.cpp index a3f874aacf..9304ce4740 100644 --- a/indra/newview/llvoicewebrtc.cpp +++ b/indra/newview/llvoicewebrtc.cpp @@ -8,7 +8,7 @@ * ne * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; + * License as published by the Free Software Foundation * version 2.1 of the License only. * * This library is distributed in the hope that it will be useful, @@ -689,16 +689,41 @@ void LLWebRTCVoiceClient::setDevicesListUpdated(bool state) void LLWebRTCVoiceClient::OnDevicesChanged(const llwebrtc::LLWebRTCVoiceDeviceList &render_devices, const llwebrtc::LLWebRTCVoiceDeviceList &capture_devices) { + std::string inputDevice = gSavedSettings.getString("VoiceInputAudioDevice"); + std::string outputDevice = gSavedSettings.getString("VoiceOutputAudioDevice"); + clearRenderDevices(); + bool renderDeviceSet = false; for (auto &device : render_devices) { addRenderDevice(LLVoiceDevice(device.display_name, device.id)); + if (device.current && outputDevice == device.id) + { + setRenderDevice(outputDevice); + renderDeviceSet = true; + } + } + if (!renderDeviceSet) + { + setRenderDevice("Default"); } + clearCaptureDevices(); + bool captureDeviceSet = false; for (auto &device : capture_devices) { addCaptureDevice(LLVoiceDevice(device.display_name, device.id)); + if (device.current && inputDevice == device.id) + { + setCaptureDevice(outputDevice); + captureDeviceSet = true; + } } + if (!captureDeviceSet) + { + setCaptureDevice("Default"); + } + setDevicesListUpdated(true); } diff --git a/indra/newview/llvoicewebrtc.h b/indra/newview/llvoicewebrtc.h index d7d6ca6229..83cb3c7eef 100644 --- a/indra/newview/llvoicewebrtc.h +++ b/indra/newview/llvoicewebrtc.h @@ -102,7 +102,6 @@ public: /// @name Devices //@{ // This returns true when it's safe to bring up the "device settings" dialog in the prefs. - // i.e. when the daemon is running and connected, and the device lists are populated. bool deviceSettingsAvailable() override; bool deviceSettingsUpdated() override; //return if the list has been updated and never fetched, only to be called from the voicepanel. |