Chromium Code Reviews| 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 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1124 // from the returned pointer. | 1124 // from the returned pointer. |
| 1125 return public_submodules_->noise_suppression.get(); | 1125 return public_submodules_->noise_suppression.get(); |
| 1126 } | 1126 } |
| 1127 | 1127 |
| 1128 VoiceDetection* AudioProcessingImpl::voice_detection() const { | 1128 VoiceDetection* AudioProcessingImpl::voice_detection() const { |
| 1129 // Adding a lock here has no effect as it allows any access to the submodule | 1129 // Adding a lock here has no effect as it allows any access to the submodule |
| 1130 // from the returned pointer. | 1130 // from the returned pointer. |
| 1131 return public_submodules_->voice_detection.get(); | 1131 return public_submodules_->voice_detection.get(); |
| 1132 } | 1132 } |
| 1133 | 1133 |
| 1134 bool AudioProcessingImpl::is_data_processed() const { | 1134 bool AudioProcessingImpl::is_data_processed() const { |
|
hlundin-webrtc
2016/02/18 15:15:56
Wow, that was a really convoluted function. Nice c
| |
| 1135 if (capture_nonlocked_.beamformer_enabled) { | 1135 // The beamformer, noise suppressor and highpass filter |
| 1136 // modify the data. | |
| 1137 if (capture_nonlocked_.beamformer_enabled || | |
| 1138 public_submodules_->high_pass_filter->is_enabled() || | |
| 1139 public_submodules_->noise_suppression->is_enabled()) { | |
| 1136 return true; | 1140 return true; |
| 1137 } | 1141 } |
| 1138 | 1142 |
| 1139 int enabled_count = 0; | 1143 // All of the private submodules modify the data. |
| 1140 for (auto item : private_submodules_->component_list) { | 1144 for (auto item : private_submodules_->component_list) { |
| 1141 if (item->is_component_enabled()) { | 1145 if (item->is_component_enabled()) { |
| 1142 enabled_count++; | 1146 return true; |
| 1143 } | 1147 } |
| 1144 } | 1148 } |
| 1145 if (public_submodules_->high_pass_filter->is_enabled()) { | |
| 1146 enabled_count++; | |
| 1147 } | |
| 1148 if (public_submodules_->noise_suppression->is_enabled()) { | |
| 1149 enabled_count++; | |
| 1150 } | |
| 1151 if (public_submodules_->level_estimator->is_enabled()) { | |
| 1152 enabled_count++; | |
| 1153 } | |
| 1154 if (public_submodules_->voice_detection->is_enabled()) { | |
| 1155 enabled_count++; | |
| 1156 } | |
| 1157 | 1149 |
| 1158 // Data is unchanged if no components are enabled, or if only | 1150 // The capture data is otherwise unchanged. |
| 1159 // public_submodules_->level_estimator | 1151 return false; |
| 1160 // or public_submodules_->voice_detection is enabled. | |
| 1161 if (enabled_count == 0) { | |
| 1162 return false; | |
| 1163 } else if (enabled_count == 1) { | |
| 1164 if (public_submodules_->level_estimator->is_enabled() || | |
| 1165 public_submodules_->voice_detection->is_enabled()) { | |
| 1166 return false; | |
| 1167 } | |
| 1168 } else if (enabled_count == 2) { | |
| 1169 if (public_submodules_->level_estimator->is_enabled() && | |
| 1170 public_submodules_->voice_detection->is_enabled()) { | |
| 1171 return false; | |
| 1172 } | |
| 1173 } | |
| 1174 return true; | |
| 1175 } | 1152 } |
| 1176 | 1153 |
| 1177 bool AudioProcessingImpl::output_copy_needed(bool is_data_processed) const { | 1154 bool AudioProcessingImpl::output_copy_needed(bool is_data_processed) const { |
| 1178 // Check if we've upmixed or downmixed the audio. | 1155 // Check if we've upmixed or downmixed the audio. |
| 1179 return ((formats_.api_format.output_stream().num_channels() != | 1156 return ((formats_.api_format.output_stream().num_channels() != |
| 1180 formats_.api_format.input_stream().num_channels()) || | 1157 formats_.api_format.input_stream().num_channels()) || |
| 1181 is_data_processed || capture_.transient_suppressor_enabled); | 1158 is_data_processed || capture_.transient_suppressor_enabled); |
| 1182 } | 1159 } |
| 1183 | 1160 |
| 1184 bool AudioProcessingImpl::synthesis_needed(bool is_data_processed) const { | 1161 bool AudioProcessingImpl::synthesis_needed(bool is_data_processed) const { |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1479 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); | 1456 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); |
| 1480 | 1457 |
| 1481 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), | 1458 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), |
| 1482 &debug_dump_.num_bytes_left_for_log_, | 1459 &debug_dump_.num_bytes_left_for_log_, |
| 1483 &crit_debug_, &debug_dump_.capture)); | 1460 &crit_debug_, &debug_dump_.capture)); |
| 1484 return kNoError; | 1461 return kNoError; |
| 1485 } | 1462 } |
| 1486 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP | 1463 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP |
| 1487 | 1464 |
| 1488 } // namespace webrtc | 1465 } // namespace webrtc |
| OLD | NEW |