Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1051)

Side by Side Diff: webrtc/modules/audio_processing/audio_processing_impl.cc

Issue 1213733004: Adds UMA histogram for system delay jumps (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 #include "webrtc/modules/audio_processing/audio_processing_impl.h" 11 #include "webrtc/modules/audio_processing/audio_processing_impl.h"
12 12
13 #include <assert.h> 13 #include <assert.h>
14 14
15 #include "webrtc/base/platform_file.h" 15 #include "webrtc/base/platform_file.h"
16 #include "webrtc/common_audio/include/audio_util.h" 16 #include "webrtc/common_audio/include/audio_util.h"
17 #include "webrtc/common_audio/channel_buffer.h" 17 #include "webrtc/common_audio/channel_buffer.h"
18 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h" 18 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h"
19 extern "C" {
20 #include "webrtc/modules/audio_processing/aec/aec_core.h"
21 }
19 #include "webrtc/modules/audio_processing/agc/agc_manager_direct.h" 22 #include "webrtc/modules/audio_processing/agc/agc_manager_direct.h"
20 #include "webrtc/modules/audio_processing/audio_buffer.h" 23 #include "webrtc/modules/audio_processing/audio_buffer.h"
21 #include "webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.h" 24 #include "webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.h"
22 #include "webrtc/modules/audio_processing/common.h" 25 #include "webrtc/modules/audio_processing/common.h"
23 #include "webrtc/modules/audio_processing/echo_cancellation_impl.h" 26 #include "webrtc/modules/audio_processing/echo_cancellation_impl.h"
24 #include "webrtc/modules/audio_processing/echo_control_mobile_impl.h" 27 #include "webrtc/modules/audio_processing/echo_control_mobile_impl.h"
25 #include "webrtc/modules/audio_processing/gain_control_impl.h" 28 #include "webrtc/modules/audio_processing/gain_control_impl.h"
26 #include "webrtc/modules/audio_processing/high_pass_filter_impl.h" 29 #include "webrtc/modules/audio_processing/high_pass_filter_impl.h"
27 #include "webrtc/modules/audio_processing/level_estimator_impl.h" 30 #include "webrtc/modules/audio_processing/level_estimator_impl.h"
28 #include "webrtc/modules/audio_processing/noise_suppression_impl.h" 31 #include "webrtc/modules/audio_processing/noise_suppression_impl.h"
29 #include "webrtc/modules/audio_processing/processing_component.h" 32 #include "webrtc/modules/audio_processing/processing_component.h"
30 #include "webrtc/modules/audio_processing/transient/transient_suppressor.h" 33 #include "webrtc/modules/audio_processing/transient/transient_suppressor.h"
31 #include "webrtc/modules/audio_processing/voice_detection_impl.h" 34 #include "webrtc/modules/audio_processing/voice_detection_impl.h"
32 #include "webrtc/modules/interface/module_common_types.h" 35 #include "webrtc/modules/interface/module_common_types.h"
33 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" 36 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
34 #include "webrtc/system_wrappers/interface/file_wrapper.h" 37 #include "webrtc/system_wrappers/interface/file_wrapper.h"
35 #include "webrtc/system_wrappers/interface/logging.h" 38 #include "webrtc/system_wrappers/interface/logging.h"
39 #include "webrtc/system_wrappers/interface/metrics.h"
36 40
37 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 41 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
38 // Files generated at build-time by the protobuf compiler. 42 // Files generated at build-time by the protobuf compiler.
39 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD 43 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD
40 #include "external/webrtc/webrtc/modules/audio_processing/debug.pb.h" 44 #include "external/webrtc/webrtc/modules/audio_processing/debug.pb.h"
41 #else 45 #else
42 #include "webrtc/audio_processing/debug.pb.h" 46 #include "webrtc/audio_processing/debug.pb.h"
43 #endif 47 #endif
44 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP 48 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
45 49
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 #endif 167 #endif
164 fwd_in_format_(kSampleRate16kHz, 1), 168 fwd_in_format_(kSampleRate16kHz, 1),
165 fwd_proc_format_(kSampleRate16kHz), 169 fwd_proc_format_(kSampleRate16kHz),
166 fwd_out_format_(kSampleRate16kHz, 1), 170 fwd_out_format_(kSampleRate16kHz, 1),
167 rev_in_format_(kSampleRate16kHz, 1), 171 rev_in_format_(kSampleRate16kHz, 1),
168 rev_proc_format_(kSampleRate16kHz, 1), 172 rev_proc_format_(kSampleRate16kHz, 1),
169 split_rate_(kSampleRate16kHz), 173 split_rate_(kSampleRate16kHz),
170 stream_delay_ms_(0), 174 stream_delay_ms_(0),
171 delay_offset_ms_(0), 175 delay_offset_ms_(0),
172 was_stream_delay_set_(false), 176 was_stream_delay_set_(false),
177 last_stream_delay_ms_(0),
178 last_aec_system_delay_ms_(0),
173 output_will_be_muted_(false), 179 output_will_be_muted_(false),
174 key_pressed_(false), 180 key_pressed_(false),
175 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) 181 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS)
176 use_new_agc_(false), 182 use_new_agc_(false),
177 #else 183 #else
178 use_new_agc_(config.Get<ExperimentalAgc>().enabled), 184 use_new_agc_(config.Get<ExperimentalAgc>().enabled),
179 #endif 185 #endif
180 agc_startup_min_volume_(config.Get<ExperimentalAgc>().startup_min_volume), 186 agc_startup_min_volume_(config.Get<ExperimentalAgc>().startup_min_volume),
181 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) 187 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS)
182 transient_suppressor_enabled_(false), 188 transient_suppressor_enabled_(false),
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 586 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
581 if (debug_file_->Open()) { 587 if (debug_file_->Open()) {
582 audioproc::Stream* msg = event_msg_->mutable_stream(); 588 audioproc::Stream* msg = event_msg_->mutable_stream();
583 msg->set_delay(stream_delay_ms_); 589 msg->set_delay(stream_delay_ms_);
584 msg->set_drift(echo_cancellation_->stream_drift_samples()); 590 msg->set_drift(echo_cancellation_->stream_drift_samples());
585 msg->set_level(gain_control()->stream_analog_level()); 591 msg->set_level(gain_control()->stream_analog_level());
586 msg->set_keypress(key_pressed_); 592 msg->set_keypress(key_pressed_);
587 } 593 }
588 #endif 594 #endif
589 595
596 MaybeUpdateHistograms();
597
590 AudioBuffer* ca = capture_audio_.get(); // For brevity. 598 AudioBuffer* ca = capture_audio_.get(); // For brevity.
591 if (use_new_agc_ && gain_control_->is_enabled()) { 599 if (use_new_agc_ && gain_control_->is_enabled()) {
592 agc_manager_->AnalyzePreProcess(ca->channels()[0], 600 agc_manager_->AnalyzePreProcess(ca->channels()[0],
593 ca->num_channels(), 601 ca->num_channels(),
594 fwd_proc_format_.samples_per_channel()); 602 fwd_proc_format_.samples_per_channel());
595 } 603 }
596 604
597 bool data_processed = is_data_processed(); 605 bool data_processed = is_data_processed();
598 if (analysis_needed(data_processed)) { 606 if (analysis_needed(data_processed)) {
599 ca->SplitIntoFrequencyBands(); 607 ca->SplitIntoFrequencyBands();
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 991
984 void AudioProcessingImpl::InitializeBeamformer() { 992 void AudioProcessingImpl::InitializeBeamformer() {
985 if (beamformer_enabled_) { 993 if (beamformer_enabled_) {
986 if (!beamformer_) { 994 if (!beamformer_) {
987 beamformer_.reset(new NonlinearBeamformer(array_geometry_)); 995 beamformer_.reset(new NonlinearBeamformer(array_geometry_));
988 } 996 }
989 beamformer_->Initialize(kChunkSizeMs, split_rate_); 997 beamformer_->Initialize(kChunkSizeMs, split_rate_);
990 } 998 }
991 } 999 }
992 1000
1001 void AudioProcessingImpl::MaybeUpdateHistograms() {
1002 static const int kMinDiffDelayMs = 50;
1003
1004 if (echo_cancellation()->is_enabled()) {
1005 // Detect a jump in platform reported system delay and log the difference.
1006 const int diff_stream_delay_ms = stream_delay_ms_ - last_stream_delay_ms_;
1007 if (diff_stream_delay_ms > kMinDiffDelayMs && last_stream_delay_ms_ != 0) {
1008 RTC_HISTOGRAM_COUNTS("WebRTC.Audio.PlatformReportedStreamDelayJump",
1009 diff_stream_delay_ms, kMinDiffDelayMs, 1000,
1010 1001 - kMinDiffDelayMs);
hlundin-webrtc 2015/06/29 08:53:18 Do we need granularity of 1 ms?
bjornv1 2015/06/29 10:40:23 No we don't. 10 ms should be just fine.
1011 }
1012 last_stream_delay_ms_ = stream_delay_ms_;
1013
1014 // Detect a jump in AEC system delay and log the difference.
1015 const int frames_per_ms = split_rate_ / 1000;
hlundin-webrtc 2015/06/29 08:53:18 This should be an exact division (zero remainder),
bjornv1 2015/06/29 10:40:23 Done.
1016 const int aec_system_delay_ms =
hlundin-webrtc 2015/06/29 08:53:18 (I'm guessing this one is not expected to be an ex
bjornv1 2015/06/29 10:40:23 No, this can end up with rounding.
1017 WebRtcAec_system_delay(echo_cancellation()->aec_core()) / frames_per_ms;
1018 const int diff_aec_system_delay_ms = aec_system_delay_ms -
1019 last_aec_system_delay_ms_;
1020 if (diff_aec_system_delay_ms > kMinDiffDelayMs &&
1021 last_aec_system_delay_ms_ != 0) {
1022 RTC_HISTOGRAM_COUNTS("WebRTC.Audio.AecSystemDelayJump",
1023 diff_aec_system_delay_ms, kMinDiffDelayMs, 1000,
1024 1001 - kMinDiffDelayMs);
hlundin-webrtc 2015/06/29 08:53:18 Same here.
bjornv1 2015/06/29 10:40:23 Done.
1025 }
1026 last_aec_system_delay_ms_ = aec_system_delay_ms;
1027 }
1028 }
1029
993 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 1030 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
994 int AudioProcessingImpl::WriteMessageToDebugFile() { 1031 int AudioProcessingImpl::WriteMessageToDebugFile() {
995 int32_t size = event_msg_->ByteSize(); 1032 int32_t size = event_msg_->ByteSize();
996 if (size <= 0) { 1033 if (size <= 0) {
997 return kUnspecifiedError; 1034 return kUnspecifiedError;
998 } 1035 }
999 #if defined(WEBRTC_ARCH_BIG_ENDIAN) 1036 #if defined(WEBRTC_ARCH_BIG_ENDIAN)
1000 // TODO(ajm): Use little-endian "on the wire". For the moment, we can be 1037 // TODO(ajm): Use little-endian "on the wire". For the moment, we can be
1001 // pretty safe in assuming little-endian. 1038 // pretty safe in assuming little-endian.
1002 #endif 1039 #endif
(...skipping 28 matching lines...) Expand all
1031 int err = WriteMessageToDebugFile(); 1068 int err = WriteMessageToDebugFile();
1032 if (err != kNoError) { 1069 if (err != kNoError) {
1033 return err; 1070 return err;
1034 } 1071 }
1035 1072
1036 return kNoError; 1073 return kNoError;
1037 } 1074 }
1038 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP 1075 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
1039 1076
1040 } // namespace webrtc 1077 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698