Avoid crashing on error code 6450 in isac.

Isac is not able to effectively compress all types of signals. This
should be extremely rare with real audio signals, but mostly happens
with artificially created test signals. When this happens, we should
avoid crashing and just carry on.

Bug: chromium:1170167
Change-Id: I97b551fbbdcccb0186f3e6497991ac52d2301f68
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/205626
Commit-Queue: Ivo Creusen <ivoc@webrtc.org>
Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33193}
This commit is contained in:
Ivo Creusen
2021-02-04 14:03:44 +01:00
committed by Commit Bot
parent 68c225d76d
commit 1142e0bfb2

View File

@ -140,6 +140,11 @@ AudioEncoder::EncodedInfo AudioEncoderIsacT<T>::EncodeImpl(
kSufficientEncodeBufferSizeBytes, [&](rtc::ArrayView<uint8_t> encoded) {
int r = T::Encode(isac_state_, audio.data(), encoded.data());
if (T::GetErrorCode(isac_state_) == 6450) {
// Isac is not able to effectively compress all types of signals. This
// is a limitation of the codec that cannot be easily fixed.
r = 0;
}
RTC_CHECK_GE(r, 0) << "Encode failed (error code "
<< T::GetErrorCode(isac_state_) << ")";