| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 return apm_->kNoError; | 57 return apm_->kNoError; |
| 58 } | 58 } |
| 59 | 59 |
| 60 assert(audio->num_frames_per_band() <= 160); | 60 assert(audio->num_frames_per_band() <= 160); |
| 61 | 61 |
| 62 for (int i = 0; i < num_handles(); i++) { | 62 for (int i = 0; i < num_handles(); i++) { |
| 63 Handle* my_handle = static_cast<Handle*>(handle(i)); | 63 Handle* my_handle = static_cast<Handle*>(handle(i)); |
| 64 int err = WebRtcAgc_AddFarend( | 64 int err = WebRtcAgc_AddFarend( |
| 65 my_handle, | 65 my_handle, |
| 66 audio->mixed_low_pass_data(), | 66 audio->mixed_low_pass_data(), |
| 67 static_cast<int16_t>(audio->num_frames_per_band())); | 67 audio->num_frames_per_band()); |
| 68 | 68 |
| 69 if (err != apm_->kNoError) { | 69 if (err != apm_->kNoError) { |
| 70 return GetHandleError(my_handle); | 70 return GetHandleError(my_handle); |
| 71 } | 71 } |
| 72 } | 72 } |
| 73 | 73 |
| 74 return apm_->kNoError; | 74 return apm_->kNoError; |
| 75 } | 75 } |
| 76 | 76 |
| 77 int GainControlImpl::AnalyzeCaptureAudio(AudioBuffer* audio) { | 77 int GainControlImpl::AnalyzeCaptureAudio(AudioBuffer* audio) { |
| 78 if (!is_component_enabled()) { | 78 if (!is_component_enabled()) { |
| 79 return apm_->kNoError; | 79 return apm_->kNoError; |
| 80 } | 80 } |
| 81 | 81 |
| 82 assert(audio->num_frames_per_band() <= 160); | 82 assert(audio->num_frames_per_band() <= 160); |
| 83 assert(audio->num_channels() == num_handles()); | 83 assert(audio->num_channels() == num_handles()); |
| 84 | 84 |
| 85 int err = apm_->kNoError; | 85 int err = apm_->kNoError; |
| 86 | 86 |
| 87 if (mode_ == kAdaptiveAnalog) { | 87 if (mode_ == kAdaptiveAnalog) { |
| 88 capture_levels_.assign(num_handles(), analog_capture_level_); | 88 capture_levels_.assign(num_handles(), analog_capture_level_); |
| 89 for (int i = 0; i < num_handles(); i++) { | 89 for (int i = 0; i < num_handles(); i++) { |
| 90 Handle* my_handle = static_cast<Handle*>(handle(i)); | 90 Handle* my_handle = static_cast<Handle*>(handle(i)); |
| 91 err = WebRtcAgc_AddMic( | 91 err = WebRtcAgc_AddMic( |
| 92 my_handle, | 92 my_handle, |
| 93 audio->split_bands(i), | 93 audio->split_bands(i), |
| 94 audio->num_bands(), | 94 audio->num_bands(), |
| 95 static_cast<int16_t>(audio->num_frames_per_band())); | 95 audio->num_frames_per_band()); |
| 96 | 96 |
| 97 if (err != apm_->kNoError) { | 97 if (err != apm_->kNoError) { |
| 98 return GetHandleError(my_handle); | 98 return GetHandleError(my_handle); |
| 99 } | 99 } |
| 100 } | 100 } |
| 101 } else if (mode_ == kAdaptiveDigital) { | 101 } else if (mode_ == kAdaptiveDigital) { |
| 102 | 102 |
| 103 for (int i = 0; i < num_handles(); i++) { | 103 for (int i = 0; i < num_handles(); i++) { |
| 104 Handle* my_handle = static_cast<Handle*>(handle(i)); | 104 Handle* my_handle = static_cast<Handle*>(handle(i)); |
| 105 int32_t capture_level_out = 0; | 105 int32_t capture_level_out = 0; |
| 106 | 106 |
| 107 err = WebRtcAgc_VirtualMic( | 107 err = WebRtcAgc_VirtualMic( |
| 108 my_handle, | 108 my_handle, |
| 109 audio->split_bands(i), | 109 audio->split_bands(i), |
| 110 audio->num_bands(), | 110 audio->num_bands(), |
| 111 static_cast<int16_t>(audio->num_frames_per_band()), | 111 audio->num_frames_per_band(), |
| 112 analog_capture_level_, | 112 analog_capture_level_, |
| 113 &capture_level_out); | 113 &capture_level_out); |
| 114 | 114 |
| 115 capture_levels_[i] = capture_level_out; | 115 capture_levels_[i] = capture_level_out; |
| 116 | 116 |
| 117 if (err != apm_->kNoError) { | 117 if (err != apm_->kNoError) { |
| 118 return GetHandleError(my_handle); | 118 return GetHandleError(my_handle); |
| 119 } | 119 } |
| 120 | 120 |
| 121 } | 121 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 139 stream_is_saturated_ = false; | 139 stream_is_saturated_ = false; |
| 140 for (int i = 0; i < num_handles(); i++) { | 140 for (int i = 0; i < num_handles(); i++) { |
| 141 Handle* my_handle = static_cast<Handle*>(handle(i)); | 141 Handle* my_handle = static_cast<Handle*>(handle(i)); |
| 142 int32_t capture_level_out = 0; | 142 int32_t capture_level_out = 0; |
| 143 uint8_t saturation_warning = 0; | 143 uint8_t saturation_warning = 0; |
| 144 | 144 |
| 145 int err = WebRtcAgc_Process( | 145 int err = WebRtcAgc_Process( |
| 146 my_handle, | 146 my_handle, |
| 147 audio->split_bands_const(i), | 147 audio->split_bands_const(i), |
| 148 audio->num_bands(), | 148 audio->num_bands(), |
| 149 static_cast<int16_t>(audio->num_frames_per_band()), | 149 audio->num_frames_per_band(), |
| 150 audio->split_bands(i), | 150 audio->split_bands(i), |
| 151 capture_levels_[i], | 151 capture_levels_[i], |
| 152 &capture_level_out, | 152 &capture_level_out, |
| 153 apm_->echo_cancellation()->stream_has_echo(), | 153 apm_->echo_cancellation()->stream_has_echo(), |
| 154 &saturation_warning); | 154 &saturation_warning); |
| 155 | 155 |
| 156 if (err != apm_->kNoError) { | 156 if (err != apm_->kNoError) { |
| 157 return GetHandleError(my_handle); | 157 return GetHandleError(my_handle); |
| 158 } | 158 } |
| 159 | 159 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 return apm_->num_output_channels(); | 334 return apm_->num_output_channels(); |
| 335 } | 335 } |
| 336 | 336 |
| 337 int GainControlImpl::GetHandleError(void* handle) const { | 337 int GainControlImpl::GetHandleError(void* handle) const { |
| 338 // The AGC has no get_error() function. | 338 // The AGC has no get_error() function. |
| 339 // (Despite listing errors in its interface...) | 339 // (Despite listing errors in its interface...) |
| 340 assert(handle != NULL); | 340 assert(handle != NULL); |
| 341 return apm_->kUnspecifiedError; | 341 return apm_->kUnspecifiedError; |
| 342 } | 342 } |
| 343 } // namespace webrtc | 343 } // namespace webrtc |
| OLD | NEW |