OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 #include "webrtc/modules/audio_processing/aec3/render_delay_controller.h" | 10 #include "webrtc/modules/audio_processing/aec3/render_delay_controller.h" |
11 | 11 |
12 #include <algorithm> | 12 #include <algorithm> |
13 #include <memory> | 13 #include <memory> |
14 #include <string> | 14 #include <string> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "webrtc/base/atomicops.h" | 17 #include "webrtc/base/atomicops.h" |
18 #include "webrtc/base/constructormagic.h" | 18 #include "webrtc/base/constructormagic.h" |
19 #include "webrtc/modules/audio_processing/aec3/aec3_constants.h" | 19 #include "webrtc/modules/audio_processing/aec3/aec3_common.h" |
20 #include "webrtc/modules/audio_processing/aec3/echo_path_delay_estimator.h" | 20 #include "webrtc/modules/audio_processing/aec3/echo_path_delay_estimator.h" |
21 #include "webrtc/system_wrappers/include/logging.h" | 21 #include "webrtc/system_wrappers/include/logging.h" |
22 | 22 |
23 namespace webrtc { | 23 namespace webrtc { |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
27 class RenderBuffer { | 27 class RenderBuffer { |
28 public: | 28 public: |
29 explicit RenderBuffer(size_t size) | 29 explicit RenderBuffer(size_t size) |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 ComputeNewBufferDelay(delay_, max_delay_, echo_path_delay_samples_); | 140 ComputeNewBufferDelay(delay_, max_delay_, echo_path_delay_samples_); |
141 if (new_delay != delay_ && align_call_counter_ > 250) { | 141 if (new_delay != delay_ && align_call_counter_ > 250) { |
142 delay_ = new_delay; | 142 delay_ = new_delay; |
143 } | 143 } |
144 | 144 |
145 // Update render delay buffer headroom. | 145 // Update render delay buffer headroom. |
146 blocks_since_last_delay_estimate_ = 0; | 146 blocks_since_last_delay_estimate_ = 0; |
147 const int headroom = echo_path_delay_samples_ - delay_ * kBlockSize; | 147 const int headroom = echo_path_delay_samples_ - delay_ * kBlockSize; |
148 RTC_DCHECK_LE(0, headroom); | 148 RTC_DCHECK_LE(0, headroom); |
149 headroom_samples_ = rtc::Optional<size_t>(headroom); | 149 headroom_samples_ = rtc::Optional<size_t>(headroom); |
150 } else if (++blocks_since_last_delay_estimate_ > 25000) { | 150 } else if (++blocks_since_last_delay_estimate_ > 250 * 20) { |
151 headroom_samples_ = rtc::Optional<size_t>(); | 151 headroom_samples_ = rtc::Optional<size_t>(); |
152 } | 152 } |
153 | 153 |
154 data_dumper_->DumpRaw("aec3_render_delay_controller_delay", 1, | 154 data_dumper_->DumpRaw("aec3_render_delay_controller_delay", 1, |
155 &echo_path_delay_samples_); | 155 &echo_path_delay_samples_); |
156 data_dumper_->DumpRaw("aec3_render_delay_controller_buffer_delay", delay_); | 156 data_dumper_->DumpRaw("aec3_render_delay_controller_buffer_delay", delay_); |
157 | 157 |
158 return delay_; | 158 return delay_; |
159 } | 159 } |
160 | 160 |
161 bool RenderDelayControllerImpl::AnalyzeRender( | 161 bool RenderDelayControllerImpl::AnalyzeRender( |
162 rtc::ArrayView<const float> render) { | 162 rtc::ArrayView<const float> render) { |
163 return render_buffer_.Insert(render); | 163 return render_buffer_.Insert(render); |
164 } | 164 } |
165 | 165 |
166 } // namespace | 166 } // namespace |
167 | 167 |
168 RenderDelayController* RenderDelayController::Create( | 168 RenderDelayController* RenderDelayController::Create( |
169 int sample_rate_hz, | 169 int sample_rate_hz, |
170 const RenderDelayBuffer& render_delay_buffer) { | 170 const RenderDelayBuffer& render_delay_buffer) { |
171 return new RenderDelayControllerImpl(sample_rate_hz, render_delay_buffer); | 171 return new RenderDelayControllerImpl(sample_rate_hz, render_delay_buffer); |
172 } | 172 } |
173 | 173 |
174 } // namespace webrtc | 174 } // namespace webrtc |
OLD | NEW |