| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/base/audio_hardware_config.h" | 5 #include "media/base/audio_hardware_config.h" |
| 6 | 6 |
| 7 using base::AutoLock; |
| 8 using media::AudioParameters; |
| 9 |
| 7 namespace media { | 10 namespace media { |
| 8 | 11 |
| 9 AudioHardwareConfig::AudioHardwareConfig( | 12 AudioHardwareConfig::AudioHardwareConfig( |
| 10 int output_buffer_size, int output_sample_rate, | 13 const AudioParameters& input_params, |
| 11 int input_sample_rate, ChannelLayout input_channel_layout) | 14 const AudioParameters& output_params) |
| 12 : output_buffer_size_(output_buffer_size), | 15 : input_params_(input_params), |
| 13 output_sample_rate_(output_sample_rate), | 16 output_params_(output_params) { |
| 14 input_sample_rate_(input_sample_rate), | |
| 15 input_channel_layout_(input_channel_layout) { | |
| 16 } | 17 } |
| 17 | 18 |
| 18 AudioHardwareConfig::~AudioHardwareConfig() {} | 19 AudioHardwareConfig::~AudioHardwareConfig() {} |
| 19 | 20 |
| 20 int AudioHardwareConfig::GetOutputBufferSize() { | 21 int AudioHardwareConfig::GetOutputBufferSize() { |
| 21 base::AutoLock auto_lock(config_lock_); | 22 AutoLock auto_lock(config_lock_); |
| 22 return output_buffer_size_; | 23 return output_params_.frames_per_buffer(); |
| 23 } | 24 } |
| 24 | 25 |
| 25 int AudioHardwareConfig::GetOutputSampleRate() { | 26 int AudioHardwareConfig::GetOutputSampleRate() { |
| 26 base::AutoLock auto_lock(config_lock_); | 27 AutoLock auto_lock(config_lock_); |
| 27 return output_sample_rate_; | 28 return output_params_.sample_rate(); |
| 29 } |
| 30 |
| 31 ChannelLayout AudioHardwareConfig::GetOutputChannelLayout() { |
| 32 AutoLock auto_lock(config_lock_); |
| 33 return output_params_.channel_layout(); |
| 34 } |
| 35 |
| 36 int AudioHardwareConfig::GetOutputChannels() { |
| 37 AutoLock auto_lock(config_lock_); |
| 38 return output_params_.channels(); |
| 28 } | 39 } |
| 29 | 40 |
| 30 int AudioHardwareConfig::GetInputSampleRate() { | 41 int AudioHardwareConfig::GetInputSampleRate() { |
| 31 base::AutoLock auto_lock(config_lock_); | 42 AutoLock auto_lock(config_lock_); |
| 32 return input_sample_rate_; | 43 return input_params_.sample_rate(); |
| 33 } | 44 } |
| 34 | 45 |
| 35 ChannelLayout AudioHardwareConfig::GetInputChannelLayout() { | 46 ChannelLayout AudioHardwareConfig::GetInputChannelLayout() { |
| 36 base::AutoLock auto_lock(config_lock_); | 47 AutoLock auto_lock(config_lock_); |
| 37 return input_channel_layout_; | 48 return input_params_.channel_layout(); |
| 49 } |
| 50 |
| 51 int AudioHardwareConfig::GetInputChannels() { |
| 52 AutoLock auto_lock(config_lock_); |
| 53 return input_params_.channels(); |
| 38 } | 54 } |
| 39 | 55 |
| 40 void AudioHardwareConfig::UpdateInputConfig( | 56 void AudioHardwareConfig::UpdateInputConfig( |
| 41 int sample_rate, media::ChannelLayout channel_layout) { | 57 const AudioParameters& input_params) { |
| 42 base::AutoLock auto_lock(config_lock_); | 58 AutoLock auto_lock(config_lock_); |
| 43 input_sample_rate_ = sample_rate; | 59 input_params_ = input_params; |
| 44 input_channel_layout_ = channel_layout; | |
| 45 } | 60 } |
| 46 | 61 |
| 47 void AudioHardwareConfig::UpdateOutputConfig(int buffer_size, int sample_rate) { | 62 void AudioHardwareConfig::UpdateOutputConfig( |
| 48 base::AutoLock auto_lock(config_lock_); | 63 const AudioParameters& output_params) { |
| 49 output_buffer_size_ = buffer_size; | 64 AutoLock auto_lock(config_lock_); |
| 50 output_sample_rate_ = sample_rate; | 65 output_params_ = output_params; |
| 51 } | 66 } |
| 52 | 67 |
| 53 } // namespace media | 68 } // namespace media |
| OLD | NEW |