Reset the speech encoder when creating a comfort noise encoder.

This is to make sure that the two encoders are "in sync" (the CNG
encoder can be created from an existing speech encoder).

This is a speculative fix for a crash in the CNG encoder where a packet
is unexpectedly emitted from the speech encoder.

Bug: webrtc:42225071
Change-Id: I42571e56e032897f7f083f04d785f6a08ebfb813
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/355160
Commit-Queue: Jakob Ivarsson‎ <jakobi@webrtc.org>
Reviewed-by: Tomas Lundqvist <tomasl@google.com>
Cr-Commit-Position: refs/heads/main@{#42516}
This commit is contained in:
Jakob Ivarsson 2024-06-20 09:12:36 +00:00 committed by WebRTC LUCI CQ
parent 85c1db046f
commit 0fd67312ea

View File

@ -89,7 +89,9 @@ AudioEncoderCng::AudioEncoderCng(AudioEncoderCngConfig&& config)
: CreateVad(config.vad_mode)),
cng_encoder_(new ComfortNoiseEncoder(SampleRateHz(),
sid_frame_interval_ms_,
num_cng_coefficients_)) {}
num_cng_coefficients_)) {
speech_encoder_->Reset();
}
AudioEncoderCng::~AudioEncoderCng() = default;