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

Unified Diff: media/audio/audio_output_controller.cc

Issue 562863002: Gardening: Revert "Use AudioStreamMonitor to control power save blocking." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 45d308db3effd64f12394570200c1f90b515ea4f..fb01254568adebb5b56baa9cb421dcc0940716ca 100644
--- a/media/audio/audio_output_controller.cc
+++ b/media/audio/audio_output_controller.cc
@@ -17,6 +17,12 @@ using base::TimeDelta;
namespace media {
+#if defined(AUDIO_POWER_MONITORING)
+// Time constant for AudioPowerMonitor. See AudioPowerMonitor ctor comments for
+// semantics. This value was arbitrarily chosen, but seems to work well.
+static const int kPowerMeasurementTimeConstantMillis = 10;
+#endif
+
AudioOutputController::AudioOutputController(
AudioManager* audio_manager,
EventHandler* handler,
@@ -33,9 +39,11 @@ AudioOutputController::AudioOutputController(
state_(kEmpty),
sync_reader_(sync_reader),
message_loop_(audio_manager->GetTaskRunner()),
+#if defined(AUDIO_POWER_MONITORING)
power_monitor_(
params.sample_rate(),
TimeDelta::FromMilliseconds(kPowerMeasurementTimeConstantMillis)),
+#endif
on_more_io_data_called_(0) {
DCHECK(audio_manager);
DCHECK(handler_);
@@ -192,9 +200,11 @@ void AudioOutputController::StopStream() {
wedge_timer_.reset();
stream_->Stop();
+#if defined(AUDIO_POWER_MONITORING)
// A stopped stream is silent, and power_montior_.Scan() is no longer being
// called; so we must reset the power monitor.
power_monitor_.Reset();
+#endif
state_ = kPaused;
}
@@ -296,8 +306,9 @@ int AudioOutputController::OnMoreData(AudioBus* dest,
sync_reader_->UpdatePendingBytes(
buffers_state.total_bytes() + frames * params_.GetBytesPerFrame());
- if (will_monitor_audio_levels())
- power_monitor_.Scan(*dest, frames);
+#if defined(AUDIO_POWER_MONITORING)
+ power_monitor_.Scan(*dest, frames);
+#endif
return frames;
}
@@ -401,8 +412,12 @@ void AudioOutputController::DoStopDiverting() {
}
std::pair<float, bool> AudioOutputController::ReadCurrentPowerAndClip() {
- DCHECK(will_monitor_audio_levels());
+#if defined(AUDIO_POWER_MONITORING)
return power_monitor_.ReadCurrentPowerAndClip();
+#else
+ NOTREACHED();
+ return std::make_pair(AudioPowerMonitor::zero_power(), false);
+#endif
}
void AudioOutputController::WedgeCheck() {
« 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