OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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/block_processor.h" | 10 #include "webrtc/modules/audio_processing/aec3/block_processor.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 // Update the render buffers with new render data, filling the buffers with | 106 // Update the render buffers with new render data, filling the buffers with |
107 // empty blocks when there is no render data available. | 107 // empty blocks when there is no render data available. |
108 render_buffer_underrun = !render_buffer_->UpdateBuffers(); | 108 render_buffer_underrun = !render_buffer_->UpdateBuffers(); |
109 | 109 |
110 // Compute and and apply the render delay required to achieve proper signal | 110 // Compute and and apply the render delay required to achieve proper signal |
111 // alignment. | 111 // alignment. |
112 const size_t old_delay = render_buffer_->Delay(); | 112 const size_t old_delay = render_buffer_->Delay(); |
113 const size_t new_delay = delay_controller_->GetDelay( | 113 const size_t new_delay = delay_controller_->GetDelay( |
114 render_buffer_->GetDownsampledRenderBuffer(), (*capture_block)[0]); | 114 render_buffer_->GetDownsampledRenderBuffer(), (*capture_block)[0]); |
115 render_buffer_->SetDelay(new_delay); | |
116 const size_t achieved_delay = render_buffer_->Delay(); | |
117 | 115 |
118 // Inform the delay controller of the actually set delay to allow it to | 116 bool delay_change; |
119 // properly react to a non-feasible delay. | 117 if (new_delay >= kMinEchoPathDelayBlocks) { |
120 delay_controller_->SetDelay(achieved_delay); | 118 render_buffer_->SetDelay(new_delay); |
| 119 const size_t achieved_delay = render_buffer_->Delay(); |
| 120 delay_change = old_delay != achieved_delay || old_delay != new_delay || |
| 121 render_buffer_overrun_occurred_; |
| 122 |
| 123 // Inform the delay controller of the actually set delay to allow it to |
| 124 // properly react to a non-feasible delay. |
| 125 delay_controller_->SetDelay(achieved_delay); |
| 126 } else { |
| 127 delay_controller_->Reset(); |
| 128 render_buffer_->Reset(); |
| 129 delay_change = true; |
| 130 } |
121 | 131 |
122 // Remove the echo from the capture signal. | 132 // Remove the echo from the capture signal. |
123 echo_remover_->ProcessCapture( | 133 echo_remover_->ProcessCapture( |
124 delay_controller_->AlignmentHeadroomSamples(), | 134 delay_controller_->AlignmentHeadroomSamples(), |
125 EchoPathVariability(echo_path_gain_change, | 135 EchoPathVariability(echo_path_gain_change, delay_change), |
126 old_delay != achieved_delay || | |
127 old_delay != new_delay || | |
128 render_buffer_overrun_occurred_), | |
129 capture_signal_saturation, render_buffer_->GetRenderBuffer(), | 136 capture_signal_saturation, render_buffer_->GetRenderBuffer(), |
130 capture_block); | 137 capture_block); |
131 | 138 |
132 // Update the metrics. | 139 // Update the metrics. |
133 metrics_.UpdateCapture(render_buffer_underrun); | 140 metrics_.UpdateCapture(render_buffer_underrun); |
134 | 141 |
135 render_buffer_overrun_occurred_ = false; | 142 render_buffer_overrun_occurred_ = false; |
136 } | 143 } |
137 | 144 |
138 void BlockProcessorImpl::BufferRender( | 145 void BlockProcessorImpl::BufferRender( |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 int sample_rate_hz, | 205 int sample_rate_hz, |
199 std::unique_ptr<RenderDelayBuffer> render_buffer, | 206 std::unique_ptr<RenderDelayBuffer> render_buffer, |
200 std::unique_ptr<RenderDelayController> delay_controller, | 207 std::unique_ptr<RenderDelayController> delay_controller, |
201 std::unique_ptr<EchoRemover> echo_remover) { | 208 std::unique_ptr<EchoRemover> echo_remover) { |
202 return new BlockProcessorImpl(sample_rate_hz, std::move(render_buffer), | 209 return new BlockProcessorImpl(sample_rate_hz, std::move(render_buffer), |
203 std::move(delay_controller), | 210 std::move(delay_controller), |
204 std::move(echo_remover)); | 211 std::move(echo_remover)); |
205 } | 212 } |
206 | 213 |
207 } // namespace webrtc | 214 } // namespace webrtc |
OLD | NEW |