Skip to content

Commit

Permalink
Fix crash issue when toggling echo cancellation off
Browse files Browse the repository at this point in the history
When duplex mode is disabled (due to echo cancellation = off) then
WebRTC preprocessor is still active in echo cancellation mode. WebRTC
then tries to access an AudioFrame::output_samples which is no longer
available.

In other words the WebRTC preprocessor is configured in a way that is
incompatible with the sound device configuration. WebRTC can only echo
cancel when sound devices are initialized with
TT_InitSoundDuplexDevices().
  • Loading branch information
bear101 committed Mar 5, 2025
1 parent 3dc9d89 commit dd12c2b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Library/TeamTalkLib/avstream/WebRTCPreprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,20 @@ bool IsEnabled(const webrtc::AudioProcessing::Config& cfg)
int WebRTCPreprocess(webrtc::AudioProcessing& apm, const media::AudioFrame& infrm,
media::AudioFrame& outfrm, webrtc::AudioProcessingStats* stats /*= nullptr*/)
{
assert(infrm.inputfmt.IsValid());
assert(!outfrm.inputfmt.IsValid() || infrm.inputfmt == outfrm.inputfmt);

webrtc::StreamConfig in_cfg(infrm.inputfmt.samplerate, infrm.inputfmt.channels),
out_cfg(infrm.inputfmt.samplerate, infrm.inputfmt.channels),
echo_cfg(infrm.outputfmt.samplerate, infrm.outputfmt.channels);

bool echo = apm.GetConfig().echo_canceller.enabled;
// Check that echo cancellation is configured correctly.
// Output frame must be available in order to echo cancel.
if (echo && infrm.inputfmt != infrm.outputfmt)
return -1;

assert(!echo || infrm.outputfmt.IsValid());
assert(!echo || infrm.inputfmt == infrm.outputfmt);

if (echo)
{
Expand Down

0 comments on commit dd12c2b

Please sign in to comment.