OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 | 10 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 return AudioProcessing::kNoError; | 97 return AudioProcessing::kNoError; |
98 } | 98 } |
99 | 99 |
100 assert(audio->num_frames_per_band() <= 160); | 100 assert(audio->num_frames_per_band() <= 160); |
101 assert(audio->num_channels() == apm_->num_reverse_channels()); | 101 assert(audio->num_channels() == apm_->num_reverse_channels()); |
102 | 102 |
103 int err = AudioProcessing::kNoError; | 103 int err = AudioProcessing::kNoError; |
104 // The ordering convention must be followed to pass to the correct AECM. | 104 // The ordering convention must be followed to pass to the correct AECM. |
105 size_t handle_index = 0; | 105 size_t handle_index = 0; |
106 render_queue_buffer_.clear(); | 106 render_queue_buffer_.clear(); |
107 for (int i = 0; i < apm_->num_output_channels(); i++) { | 107 for (size_t i = 0; i < apm_->num_output_channels(); i++) { |
108 for (int j = 0; j < audio->num_channels(); j++) { | 108 for (size_t j = 0; j < audio->num_channels(); j++) { |
109 Handle* my_handle = static_cast<Handle*>(handle(handle_index)); | 109 Handle* my_handle = static_cast<Handle*>(handle(handle_index)); |
110 err = WebRtcAecm_GetBufferFarendError( | 110 err = WebRtcAecm_GetBufferFarendError( |
111 my_handle, audio->split_bands_const(j)[kBand0To8kHz], | 111 my_handle, audio->split_bands_const(j)[kBand0To8kHz], |
112 audio->num_frames_per_band()); | 112 audio->num_frames_per_band()); |
113 | 113 |
114 if (err != AudioProcessing::kNoError) | 114 if (err != AudioProcessing::kNoError) |
115 return MapError(err); // TODO(ajm): warning possible?); | 115 return MapError(err); // TODO(ajm): warning possible?); |
116 | 116 |
117 // Buffer the samples in the render queue. | 117 // Buffer the samples in the render queue. |
118 render_queue_buffer_.insert(render_queue_buffer_.end(), | 118 render_queue_buffer_.insert(render_queue_buffer_.end(), |
(...skipping 25 matching lines...) Expand all Loading... |
144 if (!is_component_enabled()) { | 144 if (!is_component_enabled()) { |
145 return; | 145 return; |
146 } | 146 } |
147 | 147 |
148 while (render_signal_queue_->Remove(&capture_queue_buffer_)) { | 148 while (render_signal_queue_->Remove(&capture_queue_buffer_)) { |
149 size_t handle_index = 0; | 149 size_t handle_index = 0; |
150 size_t buffer_index = 0; | 150 size_t buffer_index = 0; |
151 const size_t num_frames_per_band = | 151 const size_t num_frames_per_band = |
152 capture_queue_buffer_.size() / | 152 capture_queue_buffer_.size() / |
153 (apm_->num_output_channels() * apm_->num_reverse_channels()); | 153 (apm_->num_output_channels() * apm_->num_reverse_channels()); |
154 for (int i = 0; i < apm_->num_output_channels(); i++) { | 154 for (size_t i = 0; i < apm_->num_output_channels(); i++) { |
155 for (int j = 0; j < apm_->num_reverse_channels(); j++) { | 155 for (size_t j = 0; j < apm_->num_reverse_channels(); j++) { |
156 Handle* my_handle = static_cast<Handle*>(handle(handle_index)); | 156 Handle* my_handle = static_cast<Handle*>(handle(handle_index)); |
157 WebRtcAecm_BufferFarend(my_handle, &capture_queue_buffer_[buffer_index], | 157 WebRtcAecm_BufferFarend(my_handle, &capture_queue_buffer_[buffer_index], |
158 num_frames_per_band); | 158 num_frames_per_band); |
159 | 159 |
160 buffer_index += num_frames_per_band; | 160 buffer_index += num_frames_per_band; |
161 handle_index++; | 161 handle_index++; |
162 } | 162 } |
163 } | 163 } |
164 } | 164 } |
165 } | 165 } |
166 | 166 |
167 int EchoControlMobileImpl::ProcessCaptureAudio(AudioBuffer* audio) { | 167 int EchoControlMobileImpl::ProcessCaptureAudio(AudioBuffer* audio) { |
168 rtc::CritScope cs_capture(crit_capture_); | 168 rtc::CritScope cs_capture(crit_capture_); |
169 | 169 |
170 if (!is_component_enabled()) { | 170 if (!is_component_enabled()) { |
171 return AudioProcessing::kNoError; | 171 return AudioProcessing::kNoError; |
172 } | 172 } |
173 | 173 |
174 if (!apm_->was_stream_delay_set()) { | 174 if (!apm_->was_stream_delay_set()) { |
175 return AudioProcessing::kStreamParameterNotSetError; | 175 return AudioProcessing::kStreamParameterNotSetError; |
176 } | 176 } |
177 | 177 |
178 assert(audio->num_frames_per_band() <= 160); | 178 assert(audio->num_frames_per_band() <= 160); |
179 assert(audio->num_channels() == apm_->num_output_channels()); | 179 assert(audio->num_channels() == apm_->num_output_channels()); |
180 | 180 |
181 int err = AudioProcessing::kNoError; | 181 int err = AudioProcessing::kNoError; |
182 | 182 |
183 // The ordering convention must be followed to pass to the correct AECM. | 183 // The ordering convention must be followed to pass to the correct AECM. |
184 size_t handle_index = 0; | 184 size_t handle_index = 0; |
185 for (int i = 0; i < audio->num_channels(); i++) { | 185 for (size_t i = 0; i < audio->num_channels(); i++) { |
186 // TODO(ajm): improve how this works, possibly inside AECM. | 186 // TODO(ajm): improve how this works, possibly inside AECM. |
187 // This is kind of hacked up. | 187 // This is kind of hacked up. |
188 const int16_t* noisy = audio->low_pass_reference(i); | 188 const int16_t* noisy = audio->low_pass_reference(i); |
189 const int16_t* clean = audio->split_bands_const(i)[kBand0To8kHz]; | 189 const int16_t* clean = audio->split_bands_const(i)[kBand0To8kHz]; |
190 if (noisy == NULL) { | 190 if (noisy == NULL) { |
191 noisy = clean; | 191 noisy = clean; |
192 clean = NULL; | 192 clean = NULL; |
193 } | 193 } |
194 for (int j = 0; j < apm_->num_reverse_channels(); j++) { | 194 for (size_t j = 0; j < apm_->num_reverse_channels(); j++) { |
195 Handle* my_handle = static_cast<Handle*>(handle(handle_index)); | 195 Handle* my_handle = static_cast<Handle*>(handle(handle_index)); |
196 err = WebRtcAecm_Process( | 196 err = WebRtcAecm_Process( |
197 my_handle, | 197 my_handle, |
198 noisy, | 198 noisy, |
199 clean, | 199 clean, |
200 audio->split_bands(i)[kBand0To8kHz], | 200 audio->split_bands(i)[kBand0To8kHz], |
201 audio->num_frames_per_band(), | 201 audio->num_frames_per_band(), |
202 apm_->stream_delay_ms()); | 202 apm_->stream_delay_ms()); |
203 | 203 |
204 if (err != AudioProcessing::kNoError) | 204 if (err != AudioProcessing::kNoError) |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 int EchoControlMobileImpl::ConfigureHandle(void* handle) const { | 387 int EchoControlMobileImpl::ConfigureHandle(void* handle) const { |
388 rtc::CritScope cs_render(crit_render_); | 388 rtc::CritScope cs_render(crit_render_); |
389 rtc::CritScope cs_capture(crit_capture_); | 389 rtc::CritScope cs_capture(crit_capture_); |
390 AecmConfig config; | 390 AecmConfig config; |
391 config.cngMode = comfort_noise_enabled_; | 391 config.cngMode = comfort_noise_enabled_; |
392 config.echoMode = MapSetting(routing_mode_); | 392 config.echoMode = MapSetting(routing_mode_); |
393 | 393 |
394 return WebRtcAecm_set_config(static_cast<Handle*>(handle), config); | 394 return WebRtcAecm_set_config(static_cast<Handle*>(handle), config); |
395 } | 395 } |
396 | 396 |
397 int EchoControlMobileImpl::num_handles_required() const { | 397 size_t EchoControlMobileImpl::num_handles_required() const { |
398 // Not locked as it only relies on APM public API which is threadsafe. | 398 // Not locked as it only relies on APM public API which is threadsafe. |
399 return apm_->num_output_channels() * apm_->num_reverse_channels(); | 399 return apm_->num_output_channels() * apm_->num_reverse_channels(); |
400 } | 400 } |
401 | 401 |
402 int EchoControlMobileImpl::GetHandleError(void* handle) const { | 402 int EchoControlMobileImpl::GetHandleError(void* handle) const { |
403 // Not locked as it does not rely on anything in the state. | 403 // Not locked as it does not rely on anything in the state. |
404 assert(handle != NULL); | 404 assert(handle != NULL); |
405 return AudioProcessing::kUnspecifiedError; | 405 return AudioProcessing::kUnspecifiedError; |
406 } | 406 } |
407 } // namespace webrtc | 407 } // namespace webrtc |
OLD | NEW |