summaryrefslogtreecommitdiff
path: root/indra/llwebrtc
diff options
context:
space:
mode:
authorRoxie Linden <roxie@lindenlab.com>2024-08-17 00:21:27 -0700
committerRoxie Linden <roxie@lindenlab.com>2024-08-17 00:26:07 -0700
commit2efad2182a5f6b8404afd9ea363b3a9088de3207 (patch)
treea2f90bd3f6960a85ec64de46a7c11b68338f13a4 /indra/llwebrtc
parent2a81ebba5395981fcc03a62e0f43a3caa7a42156 (diff)
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.
Diffstat (limited to 'indra/llwebrtc')
-rw-r--r--indra/llwebrtc/llwebrtc.cpp58
-rw-r--r--indra/llwebrtc/llwebrtc_impl.h2
2 files changed, 51 insertions, 9 deletions
diff --git a/indra/llwebrtc/llwebrtc.cpp b/indra/llwebrtc/llwebrtc.cpp
index 2c890acbdb..d154bfb8eb 100644
--- a/indra/llwebrtc/llwebrtc.cpp
+++ b/indra/llwebrtc/llwebrtc.cpp
@@ -251,8 +251,7 @@ void LLWebRTCImpl::init()
apm_config.noise_suppression.level = webrtc::AudioProcessing::Config::NoiseSuppression::kVeryHigh;
apm_config.transient_suppression.enabled = true;
apm_config.pipeline.multi_channel_render = true;
- apm_config.pipeline.multi_channel_capture = true;
- apm_config.pipeline.multi_channel_capture = true;
+ apm_config.pipeline.multi_channel_capture = false;
webrtc::ProcessingConfig processing_config;
processing_config.input_stream().set_num_channels(2);
@@ -279,7 +278,6 @@ void LLWebRTCImpl::init()
nullptr /* audio_mixer */,
mAudioProcessingModule);
- mWorkerThread->BlockingCall([this]() { mPeerDeviceModule->StartPlayout(); });
}
void LLWebRTCImpl::terminate()
@@ -340,6 +338,22 @@ void LLWebRTCImpl::setRecording(bool recording)
});
}
+void LLWebRTCImpl::setPlayout(bool playing)
+{
+ mWorkerThread->PostTask(
+ [this, playing]()
+ {
+ if (playing)
+ {
+ mPeerDeviceModule->StartPlayout();
+ }
+ else
+ {
+ mPeerDeviceModule->StopPlayout();
+ }
+ });
+}
+
void LLWebRTCImpl::setAudioConfig(LLWebRTCDeviceInterface::AudioConfig config)
{
webrtc::AudioProcessing::Config apm_config;
@@ -402,7 +416,6 @@ void LLWebRTCImpl::unsetDevicesObserver(LLWebRTCDevicesObserver *observer)
void ll_set_device_module_capture_device(rtc::scoped_refptr<webrtc::AudioDeviceModule> device_module, int16_t device)
{
- device_module->StopRecording();
#if WEBRTC_WIN
if (device < 0)
{
@@ -420,7 +433,6 @@ void ll_set_device_module_capture_device(rtc::scoped_refptr<webrtc::AudioDeviceM
device_module->InitMicrophone();
device_module->InitRecording();
device_module->SetStereoRecording(false);
- device_module->StartRecording();
}
void LLWebRTCImpl::setCaptureDevice(const std::string &id)
@@ -444,18 +456,32 @@ void LLWebRTCImpl::setCaptureDevice(const std::string &id)
mRecordingDevice = recordingDevice;
if (mTuningMode)
{
- mWorkerThread->PostTask([this, recordingDevice]() { ll_set_device_module_capture_device(mTuningDeviceModule, recordingDevice); });
+ mWorkerThread->PostTask([this, recordingDevice]()
+ {
+ ll_set_device_module_capture_device(mTuningDeviceModule, recordingDevice);
+ });
}
else
{
- mWorkerThread->PostTask([this, recordingDevice]() { ll_set_device_module_capture_device(mPeerDeviceModule, recordingDevice); });
+ mWorkerThread->PostTask([this, recordingDevice]()
+ {
+ bool recording = mPeerDeviceModule->Recording();
+ if (recording)
+ {
+ mPeerDeviceModule->StopRecording();
+ }
+ ll_set_device_module_capture_device(mPeerDeviceModule, recordingDevice);
+ if (recording)
+ {
+ mPeerDeviceModule->StartRecording();
+ }
+ });
}
}
void ll_set_device_module_render_device(rtc::scoped_refptr<webrtc::AudioDeviceModule> device_module, int16_t device)
{
- device_module->StopPlayout();
#if WEBRTC_WIN
if (device < 0)
{
@@ -506,8 +532,16 @@ void LLWebRTCImpl::setRenderDevice(const std::string &id)
mWorkerThread->PostTask(
[this, playoutDevice]()
{
+ bool playing = mPeerDeviceModule->Playing();
+ if (playing)
+ {
+ mPeerDeviceModule->StopPlayout();
+ }
ll_set_device_module_render_device(mPeerDeviceModule, playoutDevice);
- mPeerDeviceModule->StartPlayout();
+ if (playing)
+ {
+ mPeerDeviceModule->StartPlayout();
+ }
});
}
}
@@ -633,6 +667,11 @@ LLWebRTCPeerConnectionInterface *LLWebRTCImpl::newPeerConnection()
rtc::scoped_refptr<LLWebRTCPeerConnectionImpl> peerConnection = rtc::scoped_refptr<LLWebRTCPeerConnectionImpl>(new rtc::RefCountedObject<LLWebRTCPeerConnectionImpl>());
peerConnection->init(this);
+ if (mPeerConnections.empty())
+ {
+ setRecording(true);
+ setPlayout(true);
+ }
mPeerConnections.emplace_back(peerConnection);
peerConnection->enableSenderTracks(!mMute);
return peerConnection.get();
@@ -649,6 +688,7 @@ void LLWebRTCImpl::freePeerConnection(LLWebRTCPeerConnectionInterface* peer_conn
if (mPeerConnections.empty())
{
setRecording(false);
+ setPlayout(false);
}
}
diff --git a/indra/llwebrtc/llwebrtc_impl.h b/indra/llwebrtc/llwebrtc_impl.h
index c5b32123eb..f8a7873af8 100644
--- a/indra/llwebrtc/llwebrtc_impl.h
+++ b/indra/llwebrtc/llwebrtc_impl.h
@@ -278,6 +278,8 @@ class LLWebRTCImpl : public LLWebRTCDeviceInterface, public webrtc::AudioDeviceS
// enables/disables capture via the capture device
void setRecording(bool recording);
+ void setPlayout(bool playing);
+
protected:
LLWebRTCLogSink* mLogSink;