| 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 29 matching lines...) Expand all Loading... |
| 40 return 2; | 40 return 2; |
| 41 case NoiseSuppression::kVeryHigh: | 41 case NoiseSuppression::kVeryHigh: |
| 42 return 3; | 42 return 3; |
| 43 } | 43 } |
| 44 assert(false); | 44 assert(false); |
| 45 return -1; | 45 return -1; |
| 46 } | 46 } |
| 47 } // namespace | 47 } // namespace |
| 48 | 48 |
| 49 NoiseSuppressionImpl::NoiseSuppressionImpl(const AudioProcessing* apm, | 49 NoiseSuppressionImpl::NoiseSuppressionImpl(const AudioProcessing* apm, |
| 50 CriticalSectionWrapper* crit) | 50 CriticalSectionWrapper* crit, |
| 51 : ProcessingComponent(), | 51 rtc::ThreadChecker* capture_thread) |
| 52 apm_(apm), | 52 : ProcessingComponent(), |
| 53 crit_(crit), | 53 apm_(apm), |
| 54 level_(kModerate) {} | 54 crit_(crit), |
| 55 capture_thread_(capture_thread), |
| 56 level_(kModerate) {} |
| 55 | 57 |
| 56 NoiseSuppressionImpl::~NoiseSuppressionImpl() {} | 58 NoiseSuppressionImpl::~NoiseSuppressionImpl() {} |
| 57 | 59 |
| 58 int NoiseSuppressionImpl::AnalyzeCaptureAudio(AudioBuffer* audio) { | 60 int NoiseSuppressionImpl::AnalyzeCaptureAudio(AudioBuffer* audio) { |
| 61 RTC_DCHECK(capture_thread_->CalledOnValidThread()); |
| 59 #if defined(WEBRTC_NS_FLOAT) | 62 #if defined(WEBRTC_NS_FLOAT) |
| 60 if (!is_component_enabled()) { | 63 if (!is_component_enabled()) { |
| 61 return apm_->kNoError; | 64 return apm_->kNoError; |
| 62 } | 65 } |
| 63 assert(audio->num_frames_per_band() <= 160); | 66 assert(audio->num_frames_per_band() <= 160); |
| 64 assert(audio->num_channels() == num_handles()); | 67 assert(audio->num_channels() == num_handles()); |
| 65 | 68 |
| 66 for (int i = 0; i < num_handles(); ++i) { | 69 for (int i = 0; i < num_handles(); ++i) { |
| 67 Handle* my_handle = static_cast<Handle*>(handle(i)); | 70 Handle* my_handle = static_cast<Handle*>(handle(i)); |
| 68 | 71 |
| 69 WebRtcNs_Analyze(my_handle, audio->split_bands_const_f(i)[kBand0To8kHz]); | 72 WebRtcNs_Analyze(my_handle, audio->split_bands_const_f(i)[kBand0To8kHz]); |
| 70 } | 73 } |
| 71 #endif | 74 #endif |
| 72 return apm_->kNoError; | 75 return apm_->kNoError; |
| 73 } | 76 } |
| 74 | 77 |
| 75 int NoiseSuppressionImpl::ProcessCaptureAudio(AudioBuffer* audio) { | 78 int NoiseSuppressionImpl::ProcessCaptureAudio(AudioBuffer* audio) { |
| 79 RTC_DCHECK(capture_thread_->CalledOnValidThread()); |
| 76 if (!is_component_enabled()) { | 80 if (!is_component_enabled()) { |
| 77 return apm_->kNoError; | 81 return apm_->kNoError; |
| 78 } | 82 } |
| 79 assert(audio->num_frames_per_band() <= 160); | 83 assert(audio->num_frames_per_band() <= 160); |
| 80 assert(audio->num_channels() == num_handles()); | 84 assert(audio->num_channels() == num_handles()); |
| 81 | 85 |
| 82 for (int i = 0; i < num_handles(); ++i) { | 86 for (int i = 0; i < num_handles(); ++i) { |
| 83 Handle* my_handle = static_cast<Handle*>(handle(i)); | 87 Handle* my_handle = static_cast<Handle*>(handle(i)); |
| 84 #if defined(WEBRTC_NS_FLOAT) | 88 #if defined(WEBRTC_NS_FLOAT) |
| 85 WebRtcNs_Process(my_handle, | 89 WebRtcNs_Process(my_handle, |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 int NoiseSuppressionImpl::num_handles_required() const { | 176 int NoiseSuppressionImpl::num_handles_required() const { |
| 173 return apm_->num_output_channels(); | 177 return apm_->num_output_channels(); |
| 174 } | 178 } |
| 175 | 179 |
| 176 int NoiseSuppressionImpl::GetHandleError(void* handle) const { | 180 int NoiseSuppressionImpl::GetHandleError(void* handle) const { |
| 177 // The NS has no get_error() function. | 181 // The NS has no get_error() function. |
| 178 assert(handle != NULL); | 182 assert(handle != NULL); |
| 179 return apm_->kUnspecifiedError; | 183 return apm_->kUnspecifiedError; |
| 180 } | 184 } |
| 181 } // namespace webrtc | 185 } // namespace webrtc |
| OLD | NEW |