| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 } // namespace | 59 } // namespace |
| 60 | 60 |
| 61 const size_t EchoControlMobileImpl::kAllowedValuesOfSamplesPerFrame1; | 61 const size_t EchoControlMobileImpl::kAllowedValuesOfSamplesPerFrame1; |
| 62 const size_t EchoControlMobileImpl::kAllowedValuesOfSamplesPerFrame2; | 62 const size_t EchoControlMobileImpl::kAllowedValuesOfSamplesPerFrame2; |
| 63 | 63 |
| 64 size_t EchoControlMobile::echo_path_size_bytes() { | 64 size_t EchoControlMobile::echo_path_size_bytes() { |
| 65 return WebRtcAecm_echo_path_size_bytes(); | 65 return WebRtcAecm_echo_path_size_bytes(); |
| 66 } | 66 } |
| 67 | 67 |
| 68 EchoControlMobileImpl::EchoControlMobileImpl(const AudioProcessing* apm, | 68 EchoControlMobileImpl::EchoControlMobileImpl(const AudioProcessing* apm, |
| 69 CriticalSectionWrapper* crit) | 69 CriticalSectionWrapper* crit, |
| 70 rtc::ThreadChecker* render_thread, |
| 71 rtc::ThreadChecker* capture_thread) |
| 70 : ProcessingComponent(), | 72 : ProcessingComponent(), |
| 71 apm_(apm), | 73 apm_(apm), |
| 72 crit_(crit), | 74 crit_(crit), |
| 75 render_thread_(render_thread), |
| 76 capture_thread_(capture_thread), |
| 73 routing_mode_(kSpeakerphone), | 77 routing_mode_(kSpeakerphone), |
| 74 comfort_noise_enabled_(true), | 78 comfort_noise_enabled_(true), |
| 75 external_echo_path_(NULL), | 79 external_echo_path_(NULL), |
| 76 render_queue_element_max_size_(0) { | 80 render_queue_element_max_size_(0) { |
| 77 AllocateRenderQueue(); | 81 AllocateRenderQueue(); |
| 78 } | 82 } |
| 79 | 83 |
| 80 EchoControlMobileImpl::~EchoControlMobileImpl() { | 84 EchoControlMobileImpl::~EchoControlMobileImpl() { |
| 81 if (external_echo_path_ != NULL) { | 85 if (external_echo_path_ != NULL) { |
| 82 delete [] external_echo_path_; | 86 delete [] external_echo_path_; |
| 83 external_echo_path_ = NULL; | 87 external_echo_path_ = NULL; |
| 84 } | 88 } |
| 85 } | 89 } |
| 86 | 90 |
| 87 int EchoControlMobileImpl::ProcessRenderAudio(const AudioBuffer* audio) { | 91 int EchoControlMobileImpl::ProcessRenderAudio(const AudioBuffer* audio) { |
| 92 RTC_DCHECK(render_thread_->CalledOnValidThread()); |
| 88 if (!is_component_enabled()) { | 93 if (!is_component_enabled()) { |
| 89 return apm_->kNoError; | 94 return apm_->kNoError; |
| 90 } | 95 } |
| 91 | 96 |
| 92 assert(audio->num_frames_per_band() <= 160); | 97 assert(audio->num_frames_per_band() <= 160); |
| 93 assert(audio->num_channels() == apm_->num_reverse_channels()); | 98 assert(audio->num_channels() == apm_->num_reverse_channels()); |
| 94 | 99 |
| 95 int err = apm_->kNoError; | 100 int err = apm_->kNoError; |
| 96 | 101 |
| 97 // The ordering convention must be followed to pass to the correct AECM. | 102 // The ordering convention must be followed to pass to the correct AECM. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 124 | 129 |
| 125 render_queue_buffer_.resize(buffer_index); | 130 render_queue_buffer_.resize(buffer_index); |
| 126 render_signal_queue_->Insert(&render_queue_buffer_); | 131 render_signal_queue_->Insert(&render_queue_buffer_); |
| 127 | 132 |
| 128 return apm_->kNoError; | 133 return apm_->kNoError; |
| 129 } | 134 } |
| 130 | 135 |
| 131 // Read chunks of data that were received and queued on the render side from | 136 // Read chunks of data that were received and queued on the render side from |
| 132 // a queue. All the data chunks are buffered into the farend signal of the AEC. | 137 // a queue. All the data chunks are buffered into the farend signal of the AEC. |
| 133 void EchoControlMobileImpl::ReadQueuedRenderData() { | 138 void EchoControlMobileImpl::ReadQueuedRenderData() { |
| 139 RTC_DCHECK(capture_thread_->CalledOnValidThread()); |
| 134 if (!is_component_enabled()) { | 140 if (!is_component_enabled()) { |
| 135 return; | 141 return; |
| 136 } | 142 } |
| 137 | 143 |
| 138 bool samples_read = render_signal_queue_->Remove(&capture_queue_buffer_); | 144 bool samples_read = render_signal_queue_->Remove(&capture_queue_buffer_); |
| 139 while (samples_read) { | 145 while (samples_read) { |
| 140 size_t handle_index = 0; | 146 size_t handle_index = 0; |
| 141 int buffer_index = 0; | 147 int buffer_index = 0; |
| 142 const int num_frames_per_band = | 148 const int num_frames_per_band = |
| 143 capture_queue_buffer_.size() / | 149 capture_queue_buffer_.size() / |
| 144 (apm_->num_output_channels() * apm_->num_reverse_channels()); | 150 (apm_->num_output_channels() * apm_->num_reverse_channels()); |
| 145 for (int i = 0; i < apm_->num_output_channels(); i++) { | 151 for (int i = 0; i < apm_->num_output_channels(); i++) { |
| 146 for (int j = 0; j < apm_->num_reverse_channels(); j++) { | 152 for (int j = 0; j < apm_->num_reverse_channels(); j++) { |
| 147 Handle* my_handle = static_cast<Handle*>(handle(handle_index)); | 153 Handle* my_handle = static_cast<Handle*>(handle(handle_index)); |
| 148 (void)WebRtcAecm_BufferFarend(my_handle, | 154 (void)WebRtcAecm_BufferFarend(my_handle, |
| 149 &capture_queue_buffer_[buffer_index], | 155 &capture_queue_buffer_[buffer_index], |
| 150 num_frames_per_band); | 156 num_frames_per_band); |
| 151 | 157 |
| 152 buffer_index += num_frames_per_band; | 158 buffer_index += num_frames_per_band; |
| 153 handle_index++; | 159 handle_index++; |
| 154 } | 160 } |
| 155 } | 161 } |
| 156 } | 162 } |
| 157 } | 163 } |
| 158 | 164 |
| 159 int EchoControlMobileImpl::ProcessCaptureAudio(AudioBuffer* audio) { | 165 int EchoControlMobileImpl::ProcessCaptureAudio(AudioBuffer* audio) { |
| 166 RTC_DCHECK(capture_thread_->CalledOnValidThread()); |
| 160 if (!is_component_enabled()) { | 167 if (!is_component_enabled()) { |
| 161 return apm_->kNoError; | 168 return apm_->kNoError; |
| 162 } | 169 } |
| 163 | 170 |
| 164 if (!apm_->was_stream_delay_set()) { | 171 if (!apm_->was_stream_delay_set()) { |
| 165 return apm_->kStreamParameterNotSetError; | 172 return apm_->kStreamParameterNotSetError; |
| 166 } | 173 } |
| 167 | 174 |
| 168 assert(audio->num_frames_per_band() <= 160); | 175 assert(audio->num_frames_per_band() <= 160); |
| 169 assert(audio->num_channels() == apm_->num_output_channels()); | 176 assert(audio->num_channels() == apm_->num_output_channels()); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 return apm_->num_output_channels() * | 371 return apm_->num_output_channels() * |
| 365 apm_->num_reverse_channels(); | 372 apm_->num_reverse_channels(); |
| 366 } | 373 } |
| 367 | 374 |
| 368 int EchoControlMobileImpl::GetHandleError(void* handle) const { | 375 int EchoControlMobileImpl::GetHandleError(void* handle) const { |
| 369 assert(handle != NULL); | 376 assert(handle != NULL); |
| 370 return AudioProcessing::kUnspecifiedError; | 377 return AudioProcessing::kUnspecifiedError; |
| 371 } | 378 } |
| 372 | 379 |
| 373 } // namespace webrtc | 380 } // namespace webrtc |
| OLD | NEW |