Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions indra/llwebrtc/llwebrtc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,9 +484,9 @@ void LLWebRTCImpl::workerDeployDevices()
}
}

mDeviceModule->StopPlayout();
mDeviceModule->ForceStopRecording();
#if WEBRTC_WIN
mDeviceModule->StopPlayout();
if (recordingDevice < 0)
{
mDeviceModule->SetRecordingDevice((webrtc::AudioDeviceModule::WindowsDeviceType)recordingDevice);
Expand All @@ -496,6 +496,8 @@ void LLWebRTCImpl::workerDeployDevices()
mDeviceModule->SetRecordingDevice(recordingDevice);
}
#else
// Calls own StopPlayout from AudioDeviceMac::HandleDeviceChange()
// Don't call twice, StopPlayout's Finalize isn't thread safe
mDeviceModule->SetRecordingDevice(recordingDevice);
#endif
mDeviceModule->InitMicrophone();
Expand Down Expand Up @@ -576,8 +578,22 @@ void LLWebRTCImpl::setCaptureDevice(const std::string &id)
deployDevices();
}

void LLWebRTCImpl::setRenderDevice(const std::string &id)
void LLWebRTCImpl::setRenderDevice(const std::string &id, bool stop_playout)
{
#if !WEBRTC_WIN
// Workaround for a macOS crash
// Due to insecure StopPlayout call, can't call StopPlayout from
// workerDeployDevices, nor can use ForceStopPlayout()
// For now only call StopPlayout when switching devices from preferences
if (stop_playout)
{
mWorkerThread->BlockingCall(
[this]
{
mDeviceModule->StopPlayout();
});
}
#endif
mPlayoutDevice = id;
deployDevices();
}
Expand Down
2 changes: 1 addition & 1 deletion indra/llwebrtc/llwebrtc.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class LLWebRTCDeviceInterface

// set the capture and render devices using the unique identifier for the device
virtual void setCaptureDevice(const std::string& id) = 0;
virtual void setRenderDevice(const std::string& id) = 0;
virtual void setRenderDevice(const std::string& id, bool stop_playout) = 0;
virtual void setDevices(const std::string& caprure_id, const std::string& render_id) = 0;

// Device observers for device change callbacks.
Expand Down
2 changes: 1 addition & 1 deletion indra/llwebrtc/llwebrtc_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ class LLWebRTCImpl : public LLWebRTCDeviceInterface, public webrtc::AudioDeviceO
void unsetDevicesObserver(LLWebRTCDevicesObserver *observer) override;

void setCaptureDevice(const std::string& id) override;
void setRenderDevice(const std::string& id) override;
void setRenderDevice(const std::string& id, bool stop_playout) override;
void setDevices(const std::string& caprure_id, const std::string& render_id) override;

void setTuningMode(bool enable) override;
Expand Down
8 changes: 6 additions & 2 deletions indra/newview/llvoicewebrtc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,11 @@ void LLWebRTCVoiceClient::OnDevicesChangedImpl(const llwebrtc::LLWebRTCVoiceDevi
}
else if (update_render)
{
setRenderDevice(outputDevice);
if (mWebRTCDeviceInterface)
{
LL_DEBUGS("Voice") << "new render device is " << outputDevice << LL_ENDL;
mWebRTCDeviceInterface->setRenderDevice(outputDevice, false);
}
}
else if (update_capture)
{
Expand Down Expand Up @@ -812,7 +816,7 @@ void LLWebRTCVoiceClient::setRenderDevice(const std::string& name)
if (mWebRTCDeviceInterface)
{
LL_DEBUGS("Voice") << "new render device is " << name << LL_ENDL;
mWebRTCDeviceInterface->setRenderDevice(name);
mWebRTCDeviceInterface->setRenderDevice(name, true);
}
}

Expand Down