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

Unified Diff: content/renderer/media/webrtc_audio_capturer.cc

Issue 229573003: Adds more logging for audio input issues. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/webrtc_audio_capturer.cc
diff --git a/content/renderer/media/webrtc_audio_capturer.cc b/content/renderer/media/webrtc_audio_capturer.cc
index 7318cba1ba5e32b5c89f6aacfc41fa94f2106f9e..419f15b83f696488f309a7b0b5c58ccab0b6255b 100644
--- a/content/renderer/media/webrtc_audio_capturer.cc
+++ b/content/renderer/media/webrtc_audio_capturer.cc
@@ -38,6 +38,13 @@ const int kValidInputRates[] = {48000, 44100};
const int kValidInputRates[] = {44100};
#endif
+// Time constant for AudioPowerMonitor. See AudioPowerMonitor ctor comments
+// for semantics. This value was arbitrarily chosen, but seems to work well.
+const int kPowerMonitorTimeConstantMs = 10;
+
+// The time between two audio power level samples.
+const int kPowerMonitorLogIntervalSeconds = 10;
+
} // namespace
// Reference counted container of WebRtcLocalAudioTrack delegate.
@@ -201,7 +208,6 @@ bool WebRtcAudioCapturer::Initialize() {
// information from the capturer.
if (audio_device_)
audio_device_->AddAudioCapturer(this);
-
return true;
}
@@ -222,7 +228,10 @@ WebRtcAudioCapturer::WebRtcAudioCapturer(
peer_connection_mode_(false),
key_pressed_(false),
need_audio_processing_(false),
- audio_device_(audio_device) {
+ audio_device_(audio_device),
+ audio_power_monitor_(
+ device_info_.device.input.sample_rate,
+ base::TimeDelta::FromMilliseconds(kPowerMonitorTimeConstantMs)) {
DVLOG(1) << "WebRtcAudioCapturer::WebRtcAudioCapturer()";
}
@@ -483,6 +492,20 @@ void WebRtcAudioCapturer::Capture(media::AudioBus* audio_source,
(*it)->SetAudioProcessor(audio_processor_);
}
+ if ((base::TimeTicks::Now() - last_audio_level_log_time_).InSeconds() >
+ kPowerMonitorLogIntervalSeconds) {
+ audio_power_monitor_.Scan(*audio_source, audio_source->frames());
+
+ last_audio_level_log_time_ = base::TimeTicks::Now();
+
+ std::pair<float, bool> result =
+ audio_power_monitor_.ReadCurrentPowerAndClip();
tommi (sloooow) - chröme 2014/04/10 09:07:22 nit: I don't suppose there's a single threaded Aud
jiayl 2014/04/10 16:46:34 No, there isn't.
+ WebRtcLogMessage(base::StringPrintf(
+ "WAC::Capture: current_audio_power=%.2fdBFS.", result.first));
tommi (sloooow) - chröme 2014/04/10 09:07:22 indent
jiayl 2014/04/10 16:46:34 Done.
+
+ audio_power_monitor_.Reset();
+ }
+
// Push the data to the processor for processing.
audio_processor_->PushCaptureData(audio_source);

Powered by Google App Engine
This is Rietveld 408576698