| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/audio/cras/cras_input.h" | 5 #include "media/audio/cras/cras_input.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 latency_ts.tv_nsec / base::Time::kNanosecondsPerMicrosecond; | 215 latency_ts.tv_nsec / base::Time::kNanosecondsPerMicrosecond; |
| 216 double frames_latency = | 216 double frames_latency = |
| 217 latency_usec * params_.sample_rate() / base::Time::kMicrosecondsPerSecond; | 217 latency_usec * params_.sample_rate() / base::Time::kMicrosecondsPerSecond; |
| 218 unsigned int bytes_latency = | 218 unsigned int bytes_latency = |
| 219 static_cast<unsigned int>(frames_latency * bytes_per_frame_); | 219 static_cast<unsigned int>(frames_latency * bytes_per_frame_); |
| 220 | 220 |
| 221 // Update the AGC volume level once every second. Note that, |volume| is | 221 // Update the AGC volume level once every second. Note that, |volume| is |
| 222 // also updated each time SetVolume() is called through IPC by the | 222 // also updated each time SetVolume() is called through IPC by the |
| 223 // render-side AGC. | 223 // render-side AGC. |
| 224 double normalized_volume = 0.0; | 224 double normalized_volume = 0.0; |
| 225 QueryAgcVolume(&normalized_volume); | 225 GetAgcVolume(&normalized_volume); |
| 226 | 226 |
| 227 callback_->OnData(this, | 227 callback_->OnData(this, |
| 228 buffer, | 228 buffer, |
| 229 frames * bytes_per_frame_, | 229 frames * bytes_per_frame_, |
| 230 bytes_latency, | 230 bytes_latency, |
| 231 normalized_volume); | 231 normalized_volume); |
| 232 } | 232 } |
| 233 | 233 |
| 234 void CrasInputStream::NotifyStreamError(int err) { | 234 void CrasInputStream::NotifyStreamError(int err) { |
| 235 if (callback_) | 235 if (callback_) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 | 270 |
| 271 double CrasInputStream::GetVolumeRatioFromDecibels(double dB) const { | 271 double CrasInputStream::GetVolumeRatioFromDecibels(double dB) const { |
| 272 return pow(10, dB / 20.0); | 272 return pow(10, dB / 20.0); |
| 273 } | 273 } |
| 274 | 274 |
| 275 double CrasInputStream::GetDecibelsFromVolumeRatio(double volume_ratio) const { | 275 double CrasInputStream::GetDecibelsFromVolumeRatio(double volume_ratio) const { |
| 276 return 20 * log10(volume_ratio); | 276 return 20 * log10(volume_ratio); |
| 277 } | 277 } |
| 278 | 278 |
| 279 } // namespace media | 279 } // namespace media |
| OLD | NEW |