Index: media/audio/audio_power_monitor.cc |
diff --git a/media/audio/audio_power_monitor.cc b/media/audio/audio_power_monitor.cc |
index 6536f464b9c16905e7d4080a907b5a4df5678acf..d696ac9d2b9dbd9b684f564aa40c1633166052f0 100644 |
--- a/media/audio/audio_power_monitor.cc |
+++ b/media/audio/audio_power_monitor.cc |
@@ -15,6 +15,8 @@ |
namespace media { |
+static const float kTimeConstantInSec = 0.01f; |
+ |
AudioPowerMonitor::AudioPowerMonitor( |
int sample_rate, const base::TimeDelta& time_constant) |
: sample_weight_( |
@@ -22,6 +24,13 @@ AudioPowerMonitor::AudioPowerMonitor( |
Reset(); |
} |
+AudioPowerMonitor::AudioPowerMonitor(const AudioParameters& params) |
+ : sample_weight_( |
+ 1.0f - expf(-1.0f / (params.sample_rate() * kTimeConstantInSec))), |
no longer working on chromium
2014/05/19 15:15:48
indentation.
|
+ audio_bus_(AudioBus::Create(params)), |
+ params_(params) { |
+} |
+ |
AudioPowerMonitor::~AudioPowerMonitor() { |
} |
@@ -66,6 +75,13 @@ void AudioPowerMonitor::Scan(const AudioBus& buffer, int num_frames) { |
} |
} |
+void AudioPowerMonitor::Scan(const void* data, uint32 size) { |
no longer working on chromium
2014/05/19 15:15:48
Ideally we should not change this audio_power_moni
henrika (OOO until Aug 14)
2014/05/19 15:25:46
It is a rather big change to do that for all platf
|
+ DCHECK_EQ(static_cast<int>(size), params_.GetBytesPerBuffer()); |
+ audio_bus_->FromInterleaved( |
+ data, audio_bus_->frames(), params_.bits_per_sample() / 8); |
+ Scan(*audio_bus_, audio_bus_->frames()); |
+} |
+ |
std::pair<float, bool> AudioPowerMonitor::ReadCurrentPowerAndClip() { |
base::AutoLock for_reading(reading_lock_); |