| 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 | |
| 10 namespace media { | 7 namespace media { |
| 11 | 8 |
| 12 AudioHardwareConfig::AudioHardwareConfig( | 9 AudioHardwareConfig::AudioHardwareConfig( |
| 13 const AudioParameters& input_params, | 10 int output_buffer_size, int output_sample_rate, |
| 14 const AudioParameters& output_params) | 11 int input_sample_rate, ChannelLayout input_channel_layout) |
| 15 : input_params_(input_params), | 12 : output_buffer_size_(output_buffer_size), |
| 16 output_params_(output_params) { | 13 output_sample_rate_(output_sample_rate), |
| 14 input_sample_rate_(input_sample_rate), |
| 15 input_channel_layout_(input_channel_layout) { |
| 17 } | 16 } |
| 18 | 17 |
| 19 AudioHardwareConfig::~AudioHardwareConfig() {} | 18 AudioHardwareConfig::~AudioHardwareConfig() {} |
| 20 | 19 |
| 21 int AudioHardwareConfig::GetOutputBufferSize() const { | 20 int AudioHardwareConfig::GetOutputBufferSize() { |
| 22 AutoLock auto_lock(config_lock_); | 21 base::AutoLock auto_lock(config_lock_); |
| 23 return output_params_.frames_per_buffer(); | 22 return output_buffer_size_; |
| 24 } | 23 } |
| 25 | 24 |
| 26 int AudioHardwareConfig::GetOutputSampleRate() const { | 25 int AudioHardwareConfig::GetOutputSampleRate() { |
| 27 AutoLock auto_lock(config_lock_); | 26 base::AutoLock auto_lock(config_lock_); |
| 28 return output_params_.sample_rate(); | 27 return output_sample_rate_; |
| 29 } | 28 } |
| 30 | 29 |
| 31 ChannelLayout AudioHardwareConfig::GetOutputChannelLayout() const { | 30 int AudioHardwareConfig::GetInputSampleRate() { |
| 32 AutoLock auto_lock(config_lock_); | 31 base::AutoLock auto_lock(config_lock_); |
| 33 return output_params_.channel_layout(); | 32 return input_sample_rate_; |
| 34 } | 33 } |
| 35 | 34 |
| 36 int AudioHardwareConfig::GetOutputChannels() const { | 35 ChannelLayout AudioHardwareConfig::GetInputChannelLayout() { |
| 37 AutoLock auto_lock(config_lock_); | 36 base::AutoLock auto_lock(config_lock_); |
| 38 return output_params_.channels(); | 37 return input_channel_layout_; |
| 39 } | |
| 40 | |
| 41 int AudioHardwareConfig::GetInputSampleRate() const { | |
| 42 AutoLock auto_lock(config_lock_); | |
| 43 return input_params_.sample_rate(); | |
| 44 } | |
| 45 | |
| 46 ChannelLayout AudioHardwareConfig::GetInputChannelLayout() const { | |
| 47 AutoLock auto_lock(config_lock_); | |
| 48 return input_params_.channel_layout(); | |
| 49 } | |
| 50 | |
| 51 int AudioHardwareConfig::GetInputChannels() const { | |
| 52 AutoLock auto_lock(config_lock_); | |
| 53 return input_params_.channels(); | |
| 54 } | |
| 55 | |
| 56 media::AudioParameters | |
| 57 AudioHardwareConfig::GetInputConfig() const { | |
| 58 AutoLock auto_lock(config_lock_); | |
| 59 return input_params_; | |
| 60 } | |
| 61 | |
| 62 media::AudioParameters | |
| 63 AudioHardwareConfig::GetOutputConfig() const { | |
| 64 AutoLock auto_lock(config_lock_); | |
| 65 return output_params_; | |
| 66 } | 38 } |
| 67 | 39 |
| 68 void AudioHardwareConfig::UpdateInputConfig( | 40 void AudioHardwareConfig::UpdateInputConfig( |
| 69 const AudioParameters& input_params) { | 41 int sample_rate, media::ChannelLayout channel_layout) { |
| 70 AutoLock auto_lock(config_lock_); | 42 base::AutoLock auto_lock(config_lock_); |
| 71 input_params_ = input_params; | 43 input_sample_rate_ = sample_rate; |
| 44 input_channel_layout_ = channel_layout; |
| 72 } | 45 } |
| 73 | 46 |
| 74 void AudioHardwareConfig::UpdateOutputConfig( | 47 void AudioHardwareConfig::UpdateOutputConfig(int buffer_size, int sample_rate) { |
| 75 const AudioParameters& output_params) { | 48 base::AutoLock auto_lock(config_lock_); |
| 76 AutoLock auto_lock(config_lock_); | 49 output_buffer_size_ = buffer_size; |
| 77 output_params_ = output_params; | 50 output_sample_rate_ = sample_rate; |
| 78 } | 51 } |
| 79 | 52 |
| 80 } // namespace media | 53 } // namespace media |
| OLD | NEW |