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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 // AEC_UNINITIALIZED_ERROR | 51 // AEC_UNINITIALIZED_ERROR |
52 // AEC_NULL_POINTER_ERROR | 52 // AEC_NULL_POINTER_ERROR |
53 return AudioProcessing::kUnspecifiedError; | 53 return AudioProcessing::kUnspecifiedError; |
54 } | 54 } |
55 } | 55 } |
56 } // namespace | 56 } // namespace |
57 | 57 |
58 const size_t EchoCancellationImpl::kAllowedValuesOfSamplesPerFrame1; | 58 const size_t EchoCancellationImpl::kAllowedValuesOfSamplesPerFrame1; |
59 const size_t EchoCancellationImpl::kAllowedValuesOfSamplesPerFrame2; | 59 const size_t EchoCancellationImpl::kAllowedValuesOfSamplesPerFrame2; |
60 | 60 |
61 EchoCancellationImpl::EchoCancellationImpl(const AudioProcessing* apm, | 61 EchoCancellationImpl::EchoCancellationImpl( |
62 CriticalSectionWrapper* crit) | 62 const AudioProcessing* apm, |
| 63 CriticalSectionWrapper* crit, |
| 64 const rtc::ThreadChecker* render_thread_checker) |
63 : ProcessingComponent(), | 65 : ProcessingComponent(), |
64 apm_(apm), | 66 apm_(apm), |
65 crit_(crit), | 67 crit_(crit), |
| 68 render_thread_checker_(render_thread_checker), |
66 drift_compensation_enabled_(false), | 69 drift_compensation_enabled_(false), |
67 metrics_enabled_(false), | 70 metrics_enabled_(false), |
68 suppression_level_(kModerateSuppression), | 71 suppression_level_(kModerateSuppression), |
69 stream_drift_samples_(0), | 72 stream_drift_samples_(0), |
70 was_stream_drift_set_(false), | 73 was_stream_drift_set_(false), |
71 stream_has_echo_(false), | 74 stream_has_echo_(false), |
72 delay_logging_enabled_(false), | 75 delay_logging_enabled_(false), |
73 extended_filter_enabled_(false), | 76 extended_filter_enabled_(false), |
74 delay_agnostic_enabled_(false), | 77 delay_agnostic_enabled_(false), |
75 render_queue_element_max_size_(0) { | 78 render_queue_element_max_size_(0) { |
76 AllocateRenderQueue(); | 79 AllocateRenderQueue(); |
77 } | 80 } |
78 | 81 |
79 EchoCancellationImpl::~EchoCancellationImpl() {} | 82 EchoCancellationImpl::~EchoCancellationImpl() {} |
80 | 83 |
81 int EchoCancellationImpl::ProcessRenderAudio(const AudioBuffer* audio) { | 84 int EchoCancellationImpl::ProcessRenderAudio(const AudioBuffer* audio) { |
| 85 RTC_DCHECK(render_thread_checker_->CalledOnValidThread()); |
82 if (!is_component_enabled()) { | 86 if (!is_component_enabled()) { |
83 return apm_->kNoError; | 87 return apm_->kNoError; |
84 } | 88 } |
85 | 89 |
86 assert(audio->num_frames_per_band() <= 160); | 90 assert(audio->num_frames_per_band() <= 160); |
87 assert(audio->num_channels() == apm_->num_reverse_channels()); | 91 assert(audio->num_channels() == apm_->num_reverse_channels()); |
88 | 92 |
89 int err = apm_->kNoError; | 93 int err = apm_->kNoError; |
90 | 94 |
91 // The ordering convention must be followed to pass to the correct AEC. | 95 // The ordering convention must be followed to pass to the correct AEC. |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 48000); | 435 48000); |
432 } | 436 } |
433 | 437 |
434 int EchoCancellationImpl::ConfigureHandle(void* handle) const { | 438 int EchoCancellationImpl::ConfigureHandle(void* handle) const { |
435 assert(handle != NULL); | 439 assert(handle != NULL); |
436 AecConfig config; | 440 AecConfig config; |
437 config.metricsMode = metrics_enabled_; | 441 config.metricsMode = metrics_enabled_; |
438 config.nlpMode = MapSetting(suppression_level_); | 442 config.nlpMode = MapSetting(suppression_level_); |
439 config.skewMode = drift_compensation_enabled_; | 443 config.skewMode = drift_compensation_enabled_; |
440 config.delay_logging = delay_logging_enabled_; | 444 config.delay_logging = delay_logging_enabled_; |
441 | |
442 WebRtcAec_enable_extended_filter( | 445 WebRtcAec_enable_extended_filter( |
443 WebRtcAec_aec_core(static_cast<Handle*>(handle)), | 446 WebRtcAec_aec_core(static_cast<Handle*>(handle)), |
444 extended_filter_enabled_ ? 1 : 0); | 447 extended_filter_enabled_ ? 1 : 0); |
445 WebRtcAec_enable_delay_agnostic( | 448 WebRtcAec_enable_delay_agnostic( |
446 WebRtcAec_aec_core(static_cast<Handle*>(handle)), | 449 WebRtcAec_aec_core(static_cast<Handle*>(handle)), |
447 delay_agnostic_enabled_ ? 1 : 0); | 450 delay_agnostic_enabled_ ? 1 : 0); |
448 return WebRtcAec_set_config(static_cast<Handle*>(handle), config); | 451 return WebRtcAec_set_config(static_cast<Handle*>(handle), config); |
449 } | 452 } |
450 | 453 |
451 int EchoCancellationImpl::num_handles_required() const { | 454 int EchoCancellationImpl::num_handles_required() const { |
452 return apm_->num_output_channels() * | 455 return apm_->num_output_channels() * |
453 apm_->num_reverse_channels(); | 456 apm_->num_reverse_channels(); |
454 } | 457 } |
455 | 458 |
456 int EchoCancellationImpl::GetHandleError(void* handle) const { | 459 int EchoCancellationImpl::GetHandleError(void* handle) const { |
457 assert(handle != NULL); | 460 assert(handle != NULL); |
458 return AudioProcessing::kUnspecifiedError; | 461 return AudioProcessing::kUnspecifiedError; |
459 } | 462 } |
460 } // namespace webrtc | 463 } // namespace webrtc |
OLD | NEW |