Corrected the computation of the headroom in the AEC3 buffer alignment

This CL corrects the computation of the delay headroom so that
it is only updated when the delay is updated. This is important
as otherwise a too large headroom will be reported, which then
could cause buffer access issues.

Bug: webrtc:7878, chromium:736893
Change-Id: Ib37cb608b064dd5d4df3f8fc423448ee80ed0106
Reviewed-on: https://chromium-review.googlesource.com/549335
Commit-Queue: Per Åhgren <peah@webrtc.org>
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#18781}
This commit is contained in:
Per Åhgren 2017-06-27 11:44:27 +02:00 committed by Commit Bot
parent 17c11ec37c
commit f0a6fb19c6

View File

@ -105,20 +105,20 @@ size_t RenderDelayControllerImpl::GetDelay(
rtc::Optional<size_t> echo_path_delay_samples =
delay_estimator_.EstimateDelay(render_buffer, capture);
if (echo_path_delay_samples) {
blocks_since_last_delay_estimate_ = 0;
echo_path_delay_samples_ = *echo_path_delay_samples;
// Compute and set new render delay buffer delay.
const size_t new_delay =
ComputeNewBufferDelay(delay_, echo_path_delay_samples_);
if (new_delay != delay_ && align_call_counter_ > kNumBlocksPerSecond) {
if (align_call_counter_ > kNumBlocksPerSecond) {
delay_ = new_delay;
}
// Update render delay buffer headroom.
blocks_since_last_delay_estimate_ = 0;
const int headroom = echo_path_delay_samples_ - delay_ * kBlockSize;
RTC_DCHECK_LE(0, headroom);
headroom_samples_ = rtc::Optional<size_t>(headroom);
// Update render delay buffer headroom.
const int headroom = echo_path_delay_samples_ - delay_ * kBlockSize;
RTC_DCHECK_LE(0, headroom);
headroom_samples_ = rtc::Optional<size_t>(headroom);
}
} else if (++blocks_since_last_delay_estimate_ > 20 * kNumBlocksPerSecond) {
headroom_samples_ = rtc::Optional<size_t>();
}