Chromium Code Reviews| Index: media/audio/audio_output_controller.cc |
| diff --git a/media/audio/audio_output_controller.cc b/media/audio/audio_output_controller.cc |
| index fdca8112f14caba8fe3da63ef0d365914576dfd8..7d6dbee8cafa3d27cdb8cd25efe89075bc710870 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(); |
|
liberato (no reviews please)
2017/05/30 17:00:53
i think that this will be default-constructed to 0
ossu-chromium
2017/05/31 11:44:40
Acknowledged.
ossu-chromium
2017/05/31 11:44:40
It needs to be reset to something in DoPlay, and N
liberato (no reviews please)
2017/05/31 19:39:22
ah -- i mis-read the diff. yeah, you're right.
a
|
| + } |
| + |
| stream_->Start(this); |
| // For UMA tracking purposes, start the wedge detection timer. This allows us |
| @@ -288,9 +296,22 @@ 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) { |
| + std::pair<float, bool> power_and_clip = |
| + power_monitor_.ReadCurrentPowerAndClip(); |
| + |
| + handler_->OnLog( |
| + base::StringPrintf("AOC::OnMoreData: average audio level=%.2f dBFS", |
| + power_and_clip.first)); |
| + last_audio_level_log_time_ = now; |
| + } |
| + } |
| + |
| return frames; |
| } |