| 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/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "media/audio/audio_device_description.h" |
| 12 #include "media/audio/audio_manager.h" | 13 #include "media/audio/audio_manager.h" |
| 13 #include "media/audio/cras/audio_manager_cras.h" | 14 #include "media/audio/cras/audio_manager_cras.h" |
| 14 | 15 |
| 15 namespace media { | 16 namespace media { |
| 16 | 17 |
| 17 CrasInputStream::CrasInputStream(const AudioParameters& params, | 18 CrasInputStream::CrasInputStream(const AudioParameters& params, |
| 18 AudioManagerCras* manager, | 19 AudioManagerCras* manager, |
| 19 const std::string& device_id) | 20 const std::string& device_id) |
| 20 : audio_manager_(manager), | 21 : audio_manager_(manager), |
| 21 bytes_per_frame_(0), | 22 bytes_per_frame_(0), |
| 22 callback_(NULL), | 23 callback_(NULL), |
| 23 client_(NULL), | 24 client_(NULL), |
| 24 params_(params), | 25 params_(params), |
| 25 started_(false), | 26 started_(false), |
| 26 stream_id_(0), | 27 stream_id_(0), |
| 27 stream_direction_(CRAS_STREAM_INPUT), | 28 stream_direction_(CRAS_STREAM_INPUT), |
| 28 pin_device_(NO_DEVICE), | 29 pin_device_(NO_DEVICE), |
| 29 is_loopback_(device_id == AudioManagerBase::kLoopbackInputDeviceId) { | 30 is_loopback_(device_id == |
| 31 AudioDeviceDescription::kLoopbackInputDeviceId) { |
| 30 DCHECK(audio_manager_); | 32 DCHECK(audio_manager_); |
| 31 audio_bus_ = AudioBus::Create(params_); | 33 audio_bus_ = AudioBus::Create(params_); |
| 32 } | 34 } |
| 33 | 35 |
| 34 CrasInputStream::~CrasInputStream() { | 36 CrasInputStream::~CrasInputStream() { |
| 35 DCHECK(!client_); | 37 DCHECK(!client_); |
| 36 } | 38 } |
| 37 | 39 |
| 38 bool CrasInputStream::Open() { | 40 bool CrasInputStream::Open() { |
| 39 if (client_) { | 41 if (client_) { |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 | 334 |
| 333 double CrasInputStream::GetVolumeRatioFromDecibels(double dB) const { | 335 double CrasInputStream::GetVolumeRatioFromDecibels(double dB) const { |
| 334 return pow(10, dB / 20.0); | 336 return pow(10, dB / 20.0); |
| 335 } | 337 } |
| 336 | 338 |
| 337 double CrasInputStream::GetDecibelsFromVolumeRatio(double volume_ratio) const { | 339 double CrasInputStream::GetDecibelsFromVolumeRatio(double volume_ratio) const { |
| 338 return 20 * log10(volume_ratio); | 340 return 20 * log10(volume_ratio); |
| 339 } | 341 } |
| 340 | 342 |
| 341 } // namespace media | 343 } // namespace media |
| OLD | NEW |