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 78 matching lines...) Loading... |
89 RTC_DCHECK(state_); | 89 RTC_DCHECK(state_); |
90 return state_; | 90 return state_; |
91 } | 91 } |
92 | 92 |
93 void Initialize(int sample_rate_hz, | 93 void Initialize(int sample_rate_hz, |
94 unsigned char* external_echo_path, | 94 unsigned char* external_echo_path, |
95 size_t echo_path_size_bytes) { | 95 size_t echo_path_size_bytes) { |
96 RTC_DCHECK(state_); | 96 RTC_DCHECK(state_); |
97 int error = WebRtcAecm_Init(state_, sample_rate_hz); | 97 int error = WebRtcAecm_Init(state_, sample_rate_hz); |
98 RTC_DCHECK_EQ(AudioProcessing::kNoError, error); | 98 RTC_DCHECK_EQ(AudioProcessing::kNoError, error); |
99 if (external_echo_path != NULL) { | 99 if (external_echo_path != nullptr) { |
100 error = WebRtcAecm_InitEchoPath(state_, external_echo_path, | 100 error = WebRtcAecm_InitEchoPath(state_, external_echo_path, |
101 echo_path_size_bytes); | 101 echo_path_size_bytes); |
102 RTC_DCHECK_EQ(AudioProcessing::kNoError, error); | 102 RTC_DCHECK_EQ(AudioProcessing::kNoError, error); |
103 } | 103 } |
104 } | 104 } |
105 | 105 |
106 private: | 106 private: |
107 void* state_; | 107 void* state_; |
108 RTC_DISALLOW_COPY_AND_ASSIGN(Canceller); | 108 RTC_DISALLOW_COPY_AND_ASSIGN(Canceller); |
109 }; | 109 }; |
110 | 110 |
111 EchoControlMobileImpl::EchoControlMobileImpl(rtc::CriticalSection* crit_render, | 111 EchoControlMobileImpl::EchoControlMobileImpl(rtc::CriticalSection* crit_render, |
112 rtc::CriticalSection* crit_capture) | 112 rtc::CriticalSection* crit_capture) |
113 : crit_render_(crit_render), | 113 : crit_render_(crit_render), |
114 crit_capture_(crit_capture), | 114 crit_capture_(crit_capture), |
115 routing_mode_(kSpeakerphone), | 115 routing_mode_(kSpeakerphone), |
116 comfort_noise_enabled_(true), | 116 comfort_noise_enabled_(true), |
117 external_echo_path_(NULL) { | 117 external_echo_path_(nullptr) { |
118 RTC_DCHECK(crit_render); | 118 RTC_DCHECK(crit_render); |
119 RTC_DCHECK(crit_capture); | 119 RTC_DCHECK(crit_capture); |
120 } | 120 } |
121 | 121 |
122 EchoControlMobileImpl::~EchoControlMobileImpl() { | 122 EchoControlMobileImpl::~EchoControlMobileImpl() { |
123 if (external_echo_path_ != NULL) { | 123 if (external_echo_path_ != nullptr) { |
124 delete [] external_echo_path_; | 124 delete[] external_echo_path_; |
125 external_echo_path_ = NULL; | 125 external_echo_path_ = nullptr; |
126 } | 126 } |
127 } | 127 } |
128 | 128 |
129 void EchoControlMobileImpl::ProcessRenderAudio( | 129 void EchoControlMobileImpl::ProcessRenderAudio( |
130 rtc::ArrayView<const int16_t> packed_render_audio) { | 130 rtc::ArrayView<const int16_t> packed_render_audio) { |
131 rtc::CritScope cs_capture(crit_capture_); | 131 rtc::CritScope cs_capture(crit_capture_); |
132 if (!enabled_) { | 132 if (!enabled_) { |
133 return; | 133 return; |
134 } | 134 } |
135 | 135 |
(...skipping 58 matching lines...) Loading... |
194 | 194 |
195 int err = AudioProcessing::kNoError; | 195 int err = AudioProcessing::kNoError; |
196 | 196 |
197 // The ordering convention must be followed to pass to the correct AECM. | 197 // The ordering convention must be followed to pass to the correct AECM. |
198 size_t handle_index = 0; | 198 size_t handle_index = 0; |
199 for (size_t capture = 0; capture < audio->num_channels(); ++capture) { | 199 for (size_t capture = 0; capture < audio->num_channels(); ++capture) { |
200 // TODO(ajm): improve how this works, possibly inside AECM. | 200 // TODO(ajm): improve how this works, possibly inside AECM. |
201 // This is kind of hacked up. | 201 // This is kind of hacked up. |
202 const int16_t* noisy = audio->low_pass_reference(capture); | 202 const int16_t* noisy = audio->low_pass_reference(capture); |
203 const int16_t* clean = audio->split_bands_const(capture)[kBand0To8kHz]; | 203 const int16_t* clean = audio->split_bands_const(capture)[kBand0To8kHz]; |
204 if (noisy == NULL) { | 204 if (noisy == nullptr) { |
205 noisy = clean; | 205 noisy = clean; |
206 clean = NULL; | 206 clean = nullptr; |
207 } | 207 } |
208 for (size_t render = 0; render < stream_properties_->num_reverse_channels; | 208 for (size_t render = 0; render < stream_properties_->num_reverse_channels; |
209 ++render) { | 209 ++render) { |
210 err = WebRtcAecm_Process(cancellers_[handle_index]->state(), noisy, clean, | 210 err = WebRtcAecm_Process(cancellers_[handle_index]->state(), noisy, clean, |
211 audio->split_bands(capture)[kBand0To8kHz], | 211 audio->split_bands(capture)[kBand0To8kHz], |
212 audio->num_frames_per_band(), stream_delay_ms); | 212 audio->num_frames_per_band(), stream_delay_ms); |
213 | 213 |
214 if (err != AudioProcessing::kNoError) { | 214 if (err != AudioProcessing::kNoError) { |
215 return MapError(err); | 215 return MapError(err); |
216 } | 216 } |
(...skipping 69 matching lines...) Loading... |
286 bool EchoControlMobileImpl::is_comfort_noise_enabled() const { | 286 bool EchoControlMobileImpl::is_comfort_noise_enabled() const { |
287 rtc::CritScope cs(crit_capture_); | 287 rtc::CritScope cs(crit_capture_); |
288 return comfort_noise_enabled_; | 288 return comfort_noise_enabled_; |
289 } | 289 } |
290 | 290 |
291 int EchoControlMobileImpl::SetEchoPath(const void* echo_path, | 291 int EchoControlMobileImpl::SetEchoPath(const void* echo_path, |
292 size_t size_bytes) { | 292 size_t size_bytes) { |
293 { | 293 { |
294 rtc::CritScope cs_render(crit_render_); | 294 rtc::CritScope cs_render(crit_render_); |
295 rtc::CritScope cs_capture(crit_capture_); | 295 rtc::CritScope cs_capture(crit_capture_); |
296 if (echo_path == NULL) { | 296 if (echo_path == nullptr) { |
297 return AudioProcessing::kNullPointerError; | 297 return AudioProcessing::kNullPointerError; |
298 } | 298 } |
299 if (size_bytes != echo_path_size_bytes()) { | 299 if (size_bytes != echo_path_size_bytes()) { |
300 // Size mismatch | 300 // Size mismatch |
301 return AudioProcessing::kBadParameterError; | 301 return AudioProcessing::kBadParameterError; |
302 } | 302 } |
303 | 303 |
304 if (external_echo_path_ == NULL) { | 304 if (external_echo_path_ == nullptr) { |
305 external_echo_path_ = new unsigned char[size_bytes]; | 305 external_echo_path_ = new unsigned char[size_bytes]; |
306 } | 306 } |
307 memcpy(external_echo_path_, echo_path, size_bytes); | 307 memcpy(external_echo_path_, echo_path, size_bytes); |
308 } | 308 } |
309 | 309 |
310 // TODO(peah): Simplify once the Enable function has been removed from | 310 // TODO(peah): Simplify once the Enable function has been removed from |
311 // the public APM API. | 311 // the public APM API. |
312 RTC_DCHECK(stream_properties_); | 312 RTC_DCHECK(stream_properties_); |
313 Initialize(stream_properties_->sample_rate_hz, | 313 Initialize(stream_properties_->sample_rate_hz, |
314 stream_properties_->num_reverse_channels, | 314 stream_properties_->num_reverse_channels, |
315 stream_properties_->num_output_channels); | 315 stream_properties_->num_output_channels); |
316 return AudioProcessing::kNoError; | 316 return AudioProcessing::kNoError; |
317 } | 317 } |
318 | 318 |
319 int EchoControlMobileImpl::GetEchoPath(void* echo_path, | 319 int EchoControlMobileImpl::GetEchoPath(void* echo_path, |
320 size_t size_bytes) const { | 320 size_t size_bytes) const { |
321 rtc::CritScope cs(crit_capture_); | 321 rtc::CritScope cs(crit_capture_); |
322 if (echo_path == NULL) { | 322 if (echo_path == nullptr) { |
323 return AudioProcessing::kNullPointerError; | 323 return AudioProcessing::kNullPointerError; |
324 } | 324 } |
325 if (size_bytes != echo_path_size_bytes()) { | 325 if (size_bytes != echo_path_size_bytes()) { |
326 // Size mismatch | 326 // Size mismatch |
327 return AudioProcessing::kBadParameterError; | 327 return AudioProcessing::kBadParameterError; |
328 } | 328 } |
329 if (!enabled_) { | 329 if (!enabled_) { |
330 return AudioProcessing::kNotEnabledError; | 330 return AudioProcessing::kNotEnabledError; |
331 } | 331 } |
332 | 332 |
(...skipping 49 matching lines...) Loading... |
382 for (auto& canceller : cancellers_) { | 382 for (auto& canceller : cancellers_) { |
383 int handle_error = WebRtcAecm_set_config(canceller->state(), config); | 383 int handle_error = WebRtcAecm_set_config(canceller->state(), config); |
384 if (handle_error != AudioProcessing::kNoError) { | 384 if (handle_error != AudioProcessing::kNoError) { |
385 error = handle_error; | 385 error = handle_error; |
386 } | 386 } |
387 } | 387 } |
388 return error; | 388 return error; |
389 } | 389 } |
390 | 390 |
391 } // namespace webrtc | 391 } // namespace webrtc |
OLD | NEW |