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

Unified Diff: media/audio/audio_output_controller.cc

Issue 478543003: Use AudioStreamMonitor to control power save blocking. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup. 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
Index: media/audio/audio_output_controller.cc
diff --git a/media/audio/audio_output_controller.cc b/media/audio/audio_output_controller.cc
index fb01254568adebb5b56baa9cb421dcc0940716ca..45d308db3effd64f12394570200c1f90b515ea4f 100644
--- a/media/audio/audio_output_controller.cc
+++ b/media/audio/audio_output_controller.cc
@@ -17,12 +17,6 @@ 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,
@@ -39,11 +33,9 @@ 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_);
@@ -200,11 +192,9 @@ 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;
}
@@ -306,9 +296,8 @@ int AudioOutputController::OnMoreData(AudioBus* dest,
sync_reader_->UpdatePendingBytes(
buffers_state.total_bytes() + frames * params_.GetBytesPerFrame());
-#if defined(AUDIO_POWER_MONITORING)
- power_monitor_.Scan(*dest, frames);
-#endif
+ if (will_monitor_audio_levels())
+ power_monitor_.Scan(*dest, frames);
return frames;
}
@@ -412,12 +401,8 @@ void AudioOutputController::DoStopDiverting() {
}
std::pair<float, bool> AudioOutputController::ReadCurrentPowerAndClip() {
-#if defined(AUDIO_POWER_MONITORING)
+ DCHECK(will_monitor_audio_levels());
return power_monitor_.ReadCurrentPowerAndClip();
-#else
- NOTREACHED();
- return std::make_pair(AudioPowerMonitor::zero_power(), false);
-#endif
}
void AudioOutputController::WedgeCheck() {
« media/audio/audio_output_controller.h ('K') | « media/audio/audio_output_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698