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

Unified Diff: media/audio/audio_output_controller.cc

Issue 2902823005: Added logging of average power levels to AudioOutputController. (Closed)
Patch Set: Rebase Created 3 years, 7 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
« no previous file with comments | « media/audio/audio_output_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/audio_output_controller.cc
diff --git a/media/audio/audio_output_controller.cc b/media/audio/audio_output_controller.cc
index ecdac3d635ea8739fe080382a8964cb55dffeec2..e4ecaa9267cb4ee792e6270ae5a9b65b7264a3dd 100644
--- a/media/audio/audio_output_controller.cc
+++ b/media/audio/audio_output_controller.cc
@@ -22,6 +22,10 @@
using base::TimeDelta;
namespace media {
+namespace {
+// Time in seconds between two successive measurements of audio power levels.
+constexpr int kPowerMonitorLogIntervalSeconds = 15;
+} // namespace
AudioOutputController::AudioOutputController(
AudioManager* audio_manager,
@@ -165,6 +169,10 @@ void AudioOutputController::DoPlay() {
state_ = kPlaying;
+ if (will_monitor_audio_levels()) {
+ last_audio_level_log_time_ = base::TimeTicks::Now();
+ }
+
stream_->Start(this);
// For UMA tracking purposes, start the wedge detection timer. This allows us
@@ -193,6 +201,10 @@ void AudioOutputController::StopStream() {
wedge_timer_.reset();
stream_->Stop();
+ if (will_monitor_audio_levels()) {
+ LogAudioPowerLevel("StopStream");
+ }
+
// A stopped stream is silent, and power_montior_.Scan() is no longer being
// called; so we must reset the power monitor.
power_monitor_.Reset();
@@ -288,9 +300,17 @@ int AudioOutputController::OnMoreData(base::TimeDelta delay,
std::move(copy), reference_time));
}
- if (will_monitor_audio_levels())
+ if (will_monitor_audio_levels()) {
power_monitor_.Scan(*dest, frames);
+ const auto now = base::TimeTicks::Now();
+ if ((now - last_audio_level_log_time_).InSeconds() >
+ kPowerMonitorLogIntervalSeconds) {
+ LogAudioPowerLevel("OnMoreData");
+ last_audio_level_log_time_ = now;
+ }
+ }
+
return frames;
}
@@ -313,6 +333,13 @@ void AudioOutputController::BroadcastDataToDuplicationTargets(
(*duplication_targets_.begin())->OnData(std::move(audio_bus), reference_time);
}
+void AudioOutputController::LogAudioPowerLevel(const std::string& call_name) {
+ std::pair<float, bool> power_and_clip =
+ power_monitor_.ReadCurrentPowerAndClip();
+ handler_->OnLog(base::StringPrintf("AOC::%s: average audio level=%.2f dBFS",
+ call_name.c_str(), power_and_clip.first));
+}
+
void AudioOutputController::OnError() {
{
base::AutoLock auto_lock(error_lock_);
« no previous file with comments | « media/audio/audio_output_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698