| 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/logging.h" | 10 #include "base/logging.h" |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 } | 294 } |
| 295 | 295 |
| 296 double CrasInputStream::GetVolume() { | 296 double CrasInputStream::GetVolume() { |
| 297 if (!client_) | 297 if (!client_) |
| 298 return 0.0; | 298 return 0.0; |
| 299 | 299 |
| 300 long dB = cras_client_get_system_capture_gain(client_) / 100.0; | 300 long dB = cras_client_get_system_capture_gain(client_) / 100.0; |
| 301 return GetVolumeRatioFromDecibels(dB); | 301 return GetVolumeRatioFromDecibels(dB); |
| 302 } | 302 } |
| 303 | 303 |
| 304 bool CrasInputStream::IsMuted() { |
| 305 return false; |
| 306 } |
| 307 |
| 304 double CrasInputStream::GetVolumeRatioFromDecibels(double dB) const { | 308 double CrasInputStream::GetVolumeRatioFromDecibels(double dB) const { |
| 305 return pow(10, dB / 20.0); | 309 return pow(10, dB / 20.0); |
| 306 } | 310 } |
| 307 | 311 |
| 308 double CrasInputStream::GetDecibelsFromVolumeRatio(double volume_ratio) const { | 312 double CrasInputStream::GetDecibelsFromVolumeRatio(double volume_ratio) const { |
| 309 return 20 * log10(volume_ratio); | 313 return 20 * log10(volume_ratio); |
| 310 } | 314 } |
| 311 | 315 |
| 312 } // namespace media | 316 } // namespace media |
| OLD | NEW |