Return kSampleUnderrun if the number of samples does not fit in an AudioFrame.

If the number of samples does not fit in an AudioFrame, we should return
kSampleUnderrun to avoid crashes further downstream.

Bug: chromium:1265806
Change-Id: Ie94e1de53810167fd9b52ade72b3cb669a2a4f06
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/238666
Reviewed-by: Jakob Ivarsson <jakobi@webrtc.org>
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Commit-Queue: Ivo Creusen <ivoc@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35459}
This commit is contained in:
Ivo Creusen
2021-11-24 12:32:07 +00:00
committed by WebRTC LUCI CQ
parent 258ed1a38a
commit 500d6e7f14
2 changed files with 71 additions and 0 deletions

View File

@ -798,6 +798,11 @@ int NetEqImpl::GetAudioInternal(AudioFrame* audio_frame,
RTC_DCHECK(audio_frame->muted()); // Reset() should mute the frame.
playout_timestamp_ += static_cast<uint32_t>(output_size_samples_);
audio_frame->sample_rate_hz_ = fs_hz_;
// Make sure the total number of samples fits in the AudioFrame.
if (output_size_samples_ * sync_buffer_->Channels() >
AudioFrame::kMaxDataSizeSamples) {
return kSampleUnderrun;
}
audio_frame->samples_per_channel_ = output_size_samples_;
audio_frame->timestamp_ =
first_packet_