Skip to content
Merged
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
48 changes: 27 additions & 21 deletions indra/llwebrtc/llwebrtc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -368,8 +378,6 @@ void LLWebRTCImpl::terminate()
{
if (mDeviceModule)
{
mDeviceModule->StopRecording();
mDeviceModule->StopPlayout();
mDeviceModule->Terminate();
}
mDeviceModule = nullptr;
Expand Down Expand Up @@ -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")
{
Expand All @@ -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;
}
}
Expand All @@ -479,18 +489,20 @@ 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++)
{
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;
}
}
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -609,7 +615,7 @@ void LLWebRTCImpl::updateDevices()

void LLWebRTCImpl::OnDevicesUpdated()
{
deployDevices();
updateDevices();
}


Expand Down
6 changes: 4 additions & 2 deletions indra/llwebrtc/llwebrtc_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,10 @@ class LLWebRTCAudioDeviceModule : public webrtc::AudioDeviceModule
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(); }
Expand Down