 Chromium Code Reviews
 Chromium Code Reviews Issue 1422013002:
  Preparational work for an upcoming addition of a threadchecking scheme for APM  (Closed) 
  Base URL: https://chromium.googlesource.com/external/webrtc.git@bundling_of_state_CL
    
  
    Issue 1422013002:
  Preparational work for an upcoming addition of a threadchecking scheme for APM  (Closed) 
  Base URL: https://chromium.googlesource.com/external/webrtc.git@bundling_of_state_CL| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 } | 55 } | 
| 56 | 56 | 
| 57 // Maximum length that a frame of samples can have. | 57 // Maximum length that a frame of samples can have. | 
| 58 static const size_t kMaxAllowedValuesOfSamplesPerFrame = 160; | 58 static const size_t kMaxAllowedValuesOfSamplesPerFrame = 160; | 
| 59 // Maximum number of frames to buffer in the render queue. | 59 // Maximum number of frames to buffer in the render queue. | 
| 60 // TODO(peah): Decrease this once we properly handle hugely unbalanced | 60 // TODO(peah): Decrease this once we properly handle hugely unbalanced | 
| 61 // reverse and forward call numbers. | 61 // reverse and forward call numbers. | 
| 62 static const size_t kMaxNumFramesToBuffer = 100; | 62 static const size_t kMaxNumFramesToBuffer = 100; | 
| 63 } // namespace | 63 } // namespace | 
| 64 | 64 | 
| 65 EchoCancellationImpl::EchoCancellationImpl(const AudioProcessing* apm, | 65 EchoCancellationImpl::EchoCancellationImpl( | 
| 66 CriticalSectionWrapper* crit) | 66 const AudioProcessing* apm, | 
| 67 CriticalSectionWrapper* crit, | |
| 68 const rtc::ThreadChecker* render_thread_checker) | |
| 67 : ProcessingComponent(), | 69 : ProcessingComponent(), | 
| 68 apm_(apm), | 70 apm_(apm), | 
| 69 crit_(crit), | 71 crit_(crit), | 
| 72 render_thread_checker_(render_thread_checker), | |
| 70 drift_compensation_enabled_(false), | 73 drift_compensation_enabled_(false), | 
| 71 metrics_enabled_(false), | 74 metrics_enabled_(false), | 
| 72 suppression_level_(kModerateSuppression), | 75 suppression_level_(kModerateSuppression), | 
| 73 stream_drift_samples_(0), | 76 stream_drift_samples_(0), | 
| 74 was_stream_drift_set_(false), | 77 was_stream_drift_set_(false), | 
| 75 stream_has_echo_(false), | 78 stream_has_echo_(false), | 
| 76 delay_logging_enabled_(false), | 79 delay_logging_enabled_(false), | 
| 77 extended_filter_enabled_(false), | 80 extended_filter_enabled_(false), | 
| 78 delay_agnostic_enabled_(false), | 81 delay_agnostic_enabled_(false), | 
| 79 render_queue_element_max_size_(0) {} | 82 render_queue_element_max_size_(0) {} | 
| 80 | 83 | 
| 81 EchoCancellationImpl::~EchoCancellationImpl() {} | 84 EchoCancellationImpl::~EchoCancellationImpl() {} | 
| 82 | 85 | 
| 83 int EchoCancellationImpl::ProcessRenderAudio(const AudioBuffer* audio) { | 86 int EchoCancellationImpl::ProcessRenderAudio(const AudioBuffer* audio) { | 
| 87 RTC_DCHECK(render_thread_checker_->CalledOnValidThread()); | |
| 84 if (!is_component_enabled()) { | 88 if (!is_component_enabled()) { | 
| 85 return apm_->kNoError; | 89 return apm_->kNoError; | 
| 86 } | 90 } | 
| 87 | 91 | 
| 88 assert(audio->num_frames_per_band() <= 160); | 92 assert(audio->num_frames_per_band() <= 160); | 
| 89 assert(audio->num_channels() == apm_->num_reverse_channels()); | 93 assert(audio->num_channels() == apm_->num_reverse_channels()); | 
| 90 | 94 | 
| 91 int err = apm_->kNoError; | 95 int err = apm_->kNoError; | 
| 92 | 96 | 
| 93 // The ordering convention must be followed to pass to the correct AEC. | 97 // The ordering convention must be followed to pass to the correct AEC. | 
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 WebRtcAec_BufferFarend(my_handle, &capture_queue_buffer_[buffer_index], | 148 WebRtcAec_BufferFarend(my_handle, &capture_queue_buffer_[buffer_index], | 
| 145 num_frames_per_band); | 149 num_frames_per_band); | 
| 146 | 150 | 
| 147 buffer_index += num_frames_per_band; | 151 buffer_index += num_frames_per_band; | 
| 148 handle_index++; | 152 handle_index++; | 
| 149 } | 153 } | 
| 150 } | 154 } | 
| 151 } | 155 } | 
| 152 } | 156 } | 
| 153 | 157 | 
| 154 int EchoCancellationImpl::ProcessCaptureAudio(AudioBuffer* audio) { | 158 int EchoCancellationImpl::ProcessCaptureAudio(AudioBuffer* audio) { | 
| 
the sun
2015/11/23 12:46:21
Why no check on the capture_thread_checker here, l
 
peah-webrtc
2015/11/23 13:49:40
You are definitely correct in that. The history be
 | |
| 155 if (!is_component_enabled()) { | 159 if (!is_component_enabled()) { | 
| 156 return apm_->kNoError; | 160 return apm_->kNoError; | 
| 157 } | 161 } | 
| 158 | 162 | 
| 159 if (!apm_->was_stream_delay_set()) { | 163 if (!apm_->was_stream_delay_set()) { | 
| 160 return apm_->kStreamParameterNotSetError; | 164 return apm_->kStreamParameterNotSetError; | 
| 161 } | 165 } | 
| 162 | 166 | 
| 163 if (drift_compensation_enabled_ && !was_stream_drift_set_) { | 167 if (drift_compensation_enabled_ && !was_stream_drift_set_) { | 
| 164 return apm_->kStreamParameterNotSetError; | 168 return apm_->kStreamParameterNotSetError; | 
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 434 48000); | 438 48000); | 
| 435 } | 439 } | 
| 436 | 440 | 
| 437 int EchoCancellationImpl::ConfigureHandle(void* handle) const { | 441 int EchoCancellationImpl::ConfigureHandle(void* handle) const { | 
| 438 assert(handle != NULL); | 442 assert(handle != NULL); | 
| 439 AecConfig config; | 443 AecConfig config; | 
| 440 config.metricsMode = metrics_enabled_; | 444 config.metricsMode = metrics_enabled_; | 
| 441 config.nlpMode = MapSetting(suppression_level_); | 445 config.nlpMode = MapSetting(suppression_level_); | 
| 442 config.skewMode = drift_compensation_enabled_; | 446 config.skewMode = drift_compensation_enabled_; | 
| 443 config.delay_logging = delay_logging_enabled_; | 447 config.delay_logging = delay_logging_enabled_; | 
| 444 | |
| 445 WebRtcAec_enable_extended_filter( | 448 WebRtcAec_enable_extended_filter( | 
| 446 WebRtcAec_aec_core(static_cast<Handle*>(handle)), | 449 WebRtcAec_aec_core(static_cast<Handle*>(handle)), | 
| 447 extended_filter_enabled_ ? 1 : 0); | 450 extended_filter_enabled_ ? 1 : 0); | 
| 448 WebRtcAec_enable_delay_agnostic( | 451 WebRtcAec_enable_delay_agnostic( | 
| 449 WebRtcAec_aec_core(static_cast<Handle*>(handle)), | 452 WebRtcAec_aec_core(static_cast<Handle*>(handle)), | 
| 450 delay_agnostic_enabled_ ? 1 : 0); | 453 delay_agnostic_enabled_ ? 1 : 0); | 
| 451 return WebRtcAec_set_config(static_cast<Handle*>(handle), config); | 454 return WebRtcAec_set_config(static_cast<Handle*>(handle), config); | 
| 452 } | 455 } | 
| 453 | 456 | 
| 454 int EchoCancellationImpl::num_handles_required() const { | 457 int EchoCancellationImpl::num_handles_required() const { | 
| 455 return apm_->num_output_channels() * | 458 return apm_->num_output_channels() * | 
| 456 apm_->num_reverse_channels(); | 459 apm_->num_reverse_channels(); | 
| 457 } | 460 } | 
| 458 | 461 | 
| 459 int EchoCancellationImpl::GetHandleError(void* handle) const { | 462 int EchoCancellationImpl::GetHandleError(void* handle) const { | 
| 460 assert(handle != NULL); | 463 assert(handle != NULL); | 
| 461 return AudioProcessing::kUnspecifiedError; | 464 return AudioProcessing::kUnspecifiedError; | 
| 462 } | 465 } | 
| 463 } // namespace webrtc | 466 } // namespace webrtc | 
| OLD | NEW |