Chromium Code Reviews| Index: webrtc/modules/audio_processing/aec/aec_core.cc |
| diff --git a/webrtc/modules/audio_processing/aec/aec_core.cc b/webrtc/modules/audio_processing/aec/aec_core.cc |
| index 2cb6dd2ce7664cfc302b388644ccd77fca44c43a..4c109d7d9ce50cfe1455c5ad7b317c6c14bac8a3 100644 |
| --- a/webrtc/modules/audio_processing/aec/aec_core.cc |
| +++ b/webrtc/modules/audio_processing/aec/aec_core.cc |
| @@ -33,9 +33,37 @@ extern "C" { |
| #include "webrtc/modules/audio_processing/logging/apm_data_dumper.h" |
| #include "webrtc/modules/audio_processing/utility/delay_estimator_wrapper.h" |
| #include "webrtc/system_wrappers/include/cpu_features_wrapper.h" |
| +#include "webrtc/system_wrappers/include/metrics.h" |
| #include "webrtc/typedefs.h" |
| namespace webrtc { |
| +namespace { |
| +enum class DelaySource { |
| + kSystemDelay, // The delay values come from the OS. |
| + kDelayAgnostic, // The delay values come from the DA-AEC. |
| +}; |
| + |
| +constexpr int kMinDelayLogValue = -200; |
| +constexpr int kMaxDelayLogValue = 200; |
| +constexpr int kNumDelayLogBuckets = 100; |
| + |
| +void MaybeLogDelayAdjustment(int moved_ms, DelaySource source) { |
| + if (moved_ms == 0) |
|
peah-webrtc
2016/05/18 10:54:19
I'd rather put this check when calling the method.
|
| + return; |
| + switch (source) { |
| + case DelaySource::kSystemDelay: |
| + RTC_HISTOGRAM_COUNTS("WebRTC.Audio.AecDelayAdjustmentMsSystemValue", |
| + moved_ms, kMinDelayLogValue, kMaxDelayLogValue, |
| + kNumDelayLogBuckets); |
| + return; |
| + case DelaySource::kDelayAgnostic: |
| + RTC_HISTOGRAM_COUNTS("WebRTC.Audio.AecDelayAdjustmentMsAgnosticValue", |
| + moved_ms, kMinDelayLogValue, kMaxDelayLogValue, |
| + kNumDelayLogBuckets); |
| + return; |
| + } |
| +} |
| +} // namespace |
| // Buffer size (samples) |
| static const size_t kBufSizePartitions = 250; // 1 second of audio in 16 kHz. |
| @@ -1785,11 +1813,15 @@ void WebRtcAec_ProcessFrames(AecCore* aec, |
| // rounding, like -16. |
| int move_elements = (aec->knownDelay - knownDelay - 32) / PART_LEN; |
| int moved_elements = WebRtc_MoveReadPtr(aec->far_time_buf, move_elements); |
| + MaybeLogDelayAdjustment(moved_elements * (aec->sampFreq == 8000 ? 8 : 4), |
|
peah-webrtc
2016/05/18 10:54:19
I'd rather put the if-statement contained inside t
|
| + DelaySource::kSystemDelay); |
| aec->knownDelay -= moved_elements * PART_LEN; |
| } else { |
| // 2 b) Apply signal based delay correction. |
| int move_elements = SignalBasedDelayCorrection(aec); |
| int moved_elements = WebRtc_MoveReadPtr(aec->far_time_buf, move_elements); |
| + MaybeLogDelayAdjustment(moved_elements * (aec->sampFreq == 8000 ? 8 : 4), |
| + DelaySource::kDelayAgnostic); |
| int far_near_buffer_diff = |
| WebRtc_available_read(aec->far_time_buf) - |
| WebRtc_available_read(aec->nearFrBuf) / PART_LEN; |