Skip to content

Commit

Permalink
fix(voip-mumble): nullptr check
Browse files Browse the repository at this point in the history
This fixes a nullptr exception when trying to write to the Audio Processing Module while the audioCaptureClient is invalid.

We now also apply the last voice intent mode to the new audio device instead of the default ('speech') mode.
  • Loading branch information
tens0rfl0w committed Oct 31, 2024
1 parent 37b6ac9 commit aaa1246
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions code/components/voip-mumble/src/MumbleAudioInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,22 +139,26 @@ void MumbleAudioInput::ThreadFunc()

if (g_curInputIntentMode != g_lastIntentMode)
{
switch (g_curInputIntentMode)
{
case InputIntentMode::MUSIC:
{
m_apm->noise_suppression()->Enable(false);
m_apm->high_pass_filter()->Enable(false);
break;
}
case InputIntentMode::SPEECH:
default:
if (m_apm)
{
m_apm->noise_suppression()->Enable(true);
m_apm->high_pass_filter()->Enable(true);
break;
switch (g_curInputIntentMode)
{
case InputIntentMode::MUSIC:
{
m_apm->noise_suppression()->Enable(false);
m_apm->high_pass_filter()->Enable(false);
break;
}
case InputIntentMode::SPEECH:
default:
{
m_apm->noise_suppression()->Enable(true);
m_apm->high_pass_filter()->Enable(true);
break;
}
};
}
};

g_lastIntentMode = g_curInputIntentMode;
}

Expand Down Expand Up @@ -705,10 +709,12 @@ void MumbleAudioInput::InitializeAudioDevice()

m_apm->Initialize(pconfig);

m_apm->high_pass_filter()->Enable(true);
m_apm->echo_cancellation()->Enable(false);
m_apm->noise_suppression()->Enable(true);
const bool isVoiceIntent = g_curInputIntentMode == InputIntentMode::SPEECH;
m_apm->high_pass_filter()->Enable(isVoiceIntent);
m_apm->noise_suppression()->Enable(isVoiceIntent);
m_apm->noise_suppression()->set_level(webrtc::NoiseSuppression::kHigh);

m_apm->echo_cancellation()->Enable(false);
m_apm->level_estimator()->Enable(true);
m_apm->voice_detection()->set_likelihood(ConvertLikelihood(m_likelihood));
//m_apm->voice_detection()->set_frame_size_ms(10);
Expand Down

0 comments on commit aaa1246

Please sign in to comment.