summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/llwebrtc/llwebrtc.cpp107
-rw-r--r--indra/llwebrtc/llwebrtc_impl.h3
-rw-r--r--indra/newview/llvoicewebrtc.cpp2
3 files changed, 58 insertions, 54 deletions
diff --git a/indra/llwebrtc/llwebrtc.cpp b/indra/llwebrtc/llwebrtc.cpp
index 95f87ed65b..eda25a3641 100644
--- a/indra/llwebrtc/llwebrtc.cpp
+++ b/indra/llwebrtc/llwebrtc.cpp
@@ -131,10 +131,12 @@ void LLWebRTCImpl::terminate()
{
if (mTuningDeviceModule)
{
+ mTuningDeviceModule->StopRecording();
mTuningDeviceModule->Terminate();
}
if (mPeerDeviceModule)
{
+ mPeerDeviceModule->StopRecording();
mPeerDeviceModule->Terminate();
}
mTuningDeviceModule = nullptr;
@@ -174,43 +176,32 @@ void LLWebRTCImpl::setCaptureDevice(const std::string &id)
mWorkerThread->PostTask(
[this, id]()
{
- bool was_tuning_recording = mTuningDeviceModule->Recording();
-
- if (was_tuning_recording)
- {
- mTuningDeviceModule->StopRecording();
- }
- bool was_peer_recording = false;
- if (mPeerDeviceModule)
- {
- was_peer_recording = mPeerDeviceModule->Recording();
- if (was_peer_recording)
- {
- mPeerDeviceModule->StopRecording();
- }
- }
int16_t captureDeviceCount = mTuningDeviceModule->RecordingDevices();
for (int16_t i = 0; i < captureDeviceCount; i++)
{
char name[webrtc::kAdmMaxDeviceNameSize];
char guid[webrtc::kAdmMaxGuidSize];
mTuningDeviceModule->RecordingDeviceName(i, name, guid);
- if (id == guid || id == "Default") // first one in list is default
+ if (id == guid || id == "Default") // first one in list is default
{
RTC_LOG(LS_INFO) << __FUNCTION__ << "Set recording device to " << name << " " << guid << " " << i;
mRecordingDevice = i;
break;
}
}
+ mTuningDeviceModule->StopRecording();
mTuningDeviceModule->SetRecordingDevice(mRecordingDevice);
mTuningDeviceModule->InitMicrophone();
mTuningDeviceModule->InitRecording();
- if (was_tuning_recording)
- {
- mTuningDeviceModule->StartRecording();
- }
+ mTuningDeviceModule->StartRecording();
+ bool was_peer_recording = false;
if (mPeerDeviceModule)
{
+ was_peer_recording = mPeerDeviceModule->Recording();
+ if (was_peer_recording)
+ {
+ mPeerDeviceModule->StopRecording();
+ }
mPeerDeviceModule->SetRecordingDevice(mRecordingDevice);
mPeerDeviceModule->InitMicrophone();
mPeerDeviceModule->InitRecording();
@@ -227,20 +218,6 @@ void LLWebRTCImpl::setRenderDevice(const std::string &id)
mWorkerThread->PostTask(
[this, id]()
{
- bool was_tuning_playing = mTuningDeviceModule->Playing();
- if (was_tuning_playing)
- {
- mTuningDeviceModule->StopPlayout();
- }
- bool was_peer_playing = false;
- if (mPeerDeviceModule)
- {
- was_peer_playing = mPeerDeviceModule->Playing();
- if (was_tuning_playing)
- {
- mPeerDeviceModule->StopPlayout();
- }
- }
int16_t renderDeviceCount = mTuningDeviceModule->PlayoutDevices();
for (int16_t i = 0; i < renderDeviceCount; i++)
{
@@ -254,6 +231,22 @@ void LLWebRTCImpl::setRenderDevice(const std::string &id)
break;
}
}
+ mTuningDeviceModule->SetSpeakerMute(true);
+ bool was_tuning_playing = mTuningDeviceModule->Playing();
+ if (was_tuning_playing)
+ {
+ mTuningDeviceModule->StopPlayout();
+ }
+ bool was_peer_mute = false;
+ if (mPeerDeviceModule)
+ {
+ mPeerDeviceModule->SpeakerMute(&was_peer_mute);
+ if (!was_peer_mute)
+ {
+ mPeerDeviceModule->SetSpeakerMute(true);
+ }
+ }
+
mTuningDeviceModule->SetPlayoutDevice(mPlayoutDevice);
mTuningDeviceModule->InitSpeaker();
mTuningDeviceModule->InitPlayout();
@@ -266,11 +259,11 @@ void LLWebRTCImpl::setRenderDevice(const std::string &id)
mPeerDeviceModule->SetPlayoutDevice(mPlayoutDevice);
mPeerDeviceModule->InitSpeaker();
mPeerDeviceModule->InitPlayout();
- if (was_peer_playing)
- {
- mPeerDeviceModule->StartPlayout();
- }
+ mPeerDeviceModule->StartPlayout();
+ mPeerDeviceModule->SetSpeakerMute(was_peer_mute);
+
}
+ mTuningDeviceModule->SetSpeakerMute(false);
});
}
@@ -303,29 +296,42 @@ void LLWebRTCImpl::updateDevices()
void LLWebRTCImpl::setTuningMode(bool enable)
{
- mWorkerThread->PostTask(
+ mWorkerThread->BlockingCall(
[this, enable]()
{
if (enable)
{
+
mTuningDeviceModule->StartRecording();
mTuningDeviceModule->SetMicrophoneMute(false);
+
+
+ mTuningDeviceModule->SetSpeakerMute(false);
+
if (mPeerDeviceModule)
{
mPeerDeviceModule->StopRecording();
- mPeerDeviceModule->StopPlayout();
+ mPeerDeviceModule->SetSpeakerMute(true);
}
}
else
{
- mTuningDeviceModule->StopRecording();
if (mPeerDeviceModule)
{
- mPeerDeviceModule->StartPlayout();
mPeerDeviceModule->StartRecording();
+ mPeerDeviceModule->SetSpeakerMute(false);
}
}
});
+ // set_enabled shouldn't be done on the worker thread
+ if (mPeerConnection)
+ {
+ auto senders = mPeerConnection->GetSenders();
+ for (auto &sender : senders)
+ {
+ sender->track()->set_enabled(enable ? false : !mMute);
+ }
+ }
}
//
@@ -538,18 +544,15 @@ void LLWebRTCImpl::AnswerAvailable(const std::string &sdp)
void LLWebRTCImpl::setMute(bool mute)
{
- mSignalingThread->PostTask(
- [this, mute]()
- {
- auto senders = mPeerConnection->GetSenders();
+ mMute = mute;
+ auto senders = mPeerConnection->GetSenders();
- RTC_LOG(LS_INFO) << __FUNCTION__ << (mute ? "disabling" : "enabling") << " streams count " << senders.size();
+ RTC_LOG(LS_INFO) << __FUNCTION__ << (mute ? "disabling" : "enabling") << " streams count " << senders.size();
- for (auto &sender : senders)
- {
- sender->track()->set_enabled(!mute);
- }
- });
+ for (auto &sender : senders)
+ {
+ sender->track()->set_enabled(!mMute);
+ }
}
void LLWebRTCImpl::setSpeakerVolume(float volume)
diff --git a/indra/llwebrtc/llwebrtc_impl.h b/indra/llwebrtc/llwebrtc_impl.h
index 947b417923..24edd6eaa2 100644
--- a/indra/llwebrtc/llwebrtc_impl.h
+++ b/indra/llwebrtc/llwebrtc_impl.h
@@ -100,7 +100,7 @@ class LLWebRTCImpl : public LLWebRTCDeviceInterface,
{
public:
LLWebRTCImpl() :
- mTuningAudioDeviceObserver(nullptr), mPeerAudioDeviceObserver(nullptr)
+ mTuningAudioDeviceObserver(nullptr), mPeerAudioDeviceObserver(nullptr), mMute(true)
{
}
~LLWebRTCImpl() {}
@@ -209,6 +209,7 @@ class LLWebRTCImpl : public LLWebRTCDeviceInterface,
// accessors in webrtc aren't apparently implemented yet.
int32_t mPlayoutDevice;
int32_t mRecordingDevice;
+ bool mMute;
LLAudioDeviceObserver * mTuningAudioDeviceObserver;
LLAudioDeviceObserver * mPeerAudioDeviceObserver;
diff --git a/indra/newview/llvoicewebrtc.cpp b/indra/newview/llvoicewebrtc.cpp
index b9e5c7a8b2..8d929fd36a 100644
--- a/indra/newview/llvoicewebrtc.cpp
+++ b/indra/newview/llvoicewebrtc.cpp
@@ -2479,7 +2479,6 @@ void LLWebRTCVoiceClient::OnAudioEstablished(llwebrtc::LLWebRTCAudioInterface *
mWebRTCAudioInterface = audio_interface;
mWebRTCAudioInterface->setAudioObserver(this);
float speaker_volume = 0;
- audio_interface->setMute(true);
{
LLMutexLock lock(&mVoiceStateMutex);
speaker_volume = mSpeakerVolume;
@@ -4872,6 +4871,7 @@ void LLWebRTCVoiceClient::sessionState::for_eachPredicate(const LLWebRTCVoiceCli
void LLWebRTCVoiceClient::sessionEstablished()
{
+ mWebRTCAudioInterface->setMute(mMuteMic);
addSession(gAgent.getRegion()->getRegionID().asString());
}