Skip to content

Commit 9a2ff16

Browse files
committed
#4871 Fix webrtc crash on tuningGetEnergy
1 parent 528c4b5 commit 9a2ff16

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

indra/newview/llvoicewebrtc.cpp

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ void LLWebRTCVoiceClient::updateSettings()
396396
config.mNoiseSuppressionLevel = noiseSuppressionLevel;
397397
audioConfigChanged = true;
398398
}
399-
if (audioConfigChanged)
399+
if (audioConfigChanged && mWebRTCDeviceInterface)
400400
{
401401
mWebRTCDeviceInterface->setAudioConfig(config);
402402
}
@@ -797,7 +797,10 @@ void LLWebRTCVoiceClient::tuningStart()
797797
{
798798
if (!mIsInTuningMode)
799799
{
800-
mWebRTCDeviceInterface->setTuningMode(true);
800+
if (mWebRTCDeviceInterface)
801+
{
802+
mWebRTCDeviceInterface->setTuningMode(true);
803+
}
801804
mIsInTuningMode = true;
802805
}
803806
}
@@ -806,7 +809,10 @@ void LLWebRTCVoiceClient::tuningStop()
806809
{
807810
if (mIsInTuningMode)
808811
{
809-
mWebRTCDeviceInterface->setTuningMode(false);
812+
if (mWebRTCDeviceInterface)
813+
{
814+
mWebRTCDeviceInterface->setTuningMode(false);
815+
}
810816
mIsInTuningMode = false;
811817
}
812818
}
@@ -839,6 +845,10 @@ void LLWebRTCVoiceClient::tuningSetSpeakerVolume(float volume)
839845

840846
float LLWebRTCVoiceClient::tuningGetEnergy(void)
841847
{
848+
if (!mWebRTCDeviceInterface)
849+
{
850+
return 0.f;
851+
}
842852
float rms = mWebRTCDeviceInterface->getTuningAudioLevel();
843853
return TUNING_LEVEL_START_POINT - TUNING_LEVEL_SCALE * rms;
844854
}
@@ -866,7 +876,10 @@ void LLWebRTCVoiceClient::refreshDeviceLists(bool clearCurrentList)
866876
clearCaptureDevices();
867877
clearRenderDevices();
868878
}
869-
mWebRTCDeviceInterface->refreshDevices();
879+
if (mWebRTCDeviceInterface)
880+
{
881+
mWebRTCDeviceInterface->refreshDevices();
882+
}
870883
}
871884

872885

@@ -1174,7 +1187,7 @@ void LLWebRTCVoiceClient::sendPositionUpdate(bool force)
11741187
void LLWebRTCVoiceClient::updateOwnVolume()
11751188
{
11761189
F32 audio_level = 0.0f;
1177-
if (!mMuteMic)
1190+
if (!mMuteMic && mWebRTCDeviceInterface)
11781191
{
11791192
float rms = mWebRTCDeviceInterface->getPeerConnectionAudioLevel();
11801193
audio_level = LEVEL_START_POINT - LEVEL_SCALE * rms;

0 commit comments

Comments
 (0)