Chromium Code Reviews| 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/audio_parameters.h" | 5 #include "media/audio/audio_parameters.h" |
| 6 | 6 |
| 7 #include "media/base/limits.h" | 7 #include "media/base/limits.h" |
| 8 | 8 |
| 9 namespace media { | 9 namespace media { |
| 10 | 10 |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 : format_(format), | 37 : format_(format), |
| 38 channel_layout_(channel_layout), | 38 channel_layout_(channel_layout), |
| 39 sample_rate_(sample_rate), | 39 sample_rate_(sample_rate), |
| 40 bits_per_sample_(bits_per_sample), | 40 bits_per_sample_(bits_per_sample), |
| 41 frames_per_buffer_(frames_per_buffer), | 41 frames_per_buffer_(frames_per_buffer), |
| 42 channels_(ChannelLayoutToChannelCount(channel_layout)), | 42 channels_(ChannelLayoutToChannelCount(channel_layout)), |
| 43 input_channels_(input_channels) { | 43 input_channels_(input_channels) { |
| 44 } | 44 } |
| 45 | 45 |
| 46 void AudioParameters::Reset(Format format, ChannelLayout channel_layout, | 46 void AudioParameters::Reset(Format format, ChannelLayout channel_layout, |
| 47 int input_channels, | 47 int channels, int input_channels, |
| 48 int sample_rate, int bits_per_sample, | 48 int sample_rate, int bits_per_sample, |
| 49 int frames_per_buffer) { | 49 int frames_per_buffer) { |
| 50 format_ = format; | 50 format_ = format; |
| 51 channel_layout_ = channel_layout; | 51 channel_layout_ = channel_layout; |
| 52 channels_ = channels; | |
| 52 input_channels_ = input_channels; | 53 input_channels_ = input_channels; |
| 53 sample_rate_ = sample_rate; | 54 sample_rate_ = sample_rate; |
| 54 bits_per_sample_ = bits_per_sample; | 55 bits_per_sample_ = bits_per_sample; |
| 55 frames_per_buffer_ = frames_per_buffer; | 56 frames_per_buffer_ = frames_per_buffer; |
| 56 channels_ = ChannelLayoutToChannelCount(channel_layout); | |
|
DaleCurtis
2013/03/11 19:21:50
Keep this as:
if (channel_layout_ != CHANNEL_LAYO
Chris Rogers
2013/03/12 22:32:31
Done.
| |
| 57 } | 57 } |
| 58 | 58 |
| 59 bool AudioParameters::IsValid() const { | 59 bool AudioParameters::IsValid() const { |
| 60 return (format_ >= AUDIO_PCM_LINEAR) && | 60 return (format_ >= AUDIO_PCM_LINEAR) && |
| 61 (format_ < AUDIO_LAST_FORMAT) && | 61 (format_ < AUDIO_LAST_FORMAT) && |
| 62 (channels_ > 0) && | 62 (channels_ > 0) && |
| 63 (channels_ <= media::limits::kMaxChannels) && | 63 (channels_ <= media::limits::kMaxChannels) && |
| 64 (channel_layout_ > CHANNEL_LAYOUT_UNSUPPORTED) && | 64 (channel_layout_ > CHANNEL_LAYOUT_UNSUPPORTED) && |
| 65 (channel_layout_ < CHANNEL_LAYOUT_MAX) && | 65 (channel_layout_ < CHANNEL_LAYOUT_MAX) && |
| 66 (input_channels_ >= 0) && | 66 (input_channels_ >= 0) && |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 78 } | 78 } |
| 79 | 79 |
| 80 int AudioParameters::GetBytesPerSecond() const { | 80 int AudioParameters::GetBytesPerSecond() const { |
| 81 return sample_rate_ * GetBytesPerFrame(); | 81 return sample_rate_ * GetBytesPerFrame(); |
| 82 } | 82 } |
| 83 | 83 |
| 84 int AudioParameters::GetBytesPerFrame() const { | 84 int AudioParameters::GetBytesPerFrame() const { |
| 85 return channels_ * bits_per_sample_ / 8; | 85 return channels_ * bits_per_sample_ / 8; |
| 86 } | 86 } |
| 87 | 87 |
| 88 void AudioParameters::SetDiscreteChannels(int channels) { | |
| 89 channel_layout_ = CHANNEL_LAYOUT_DISCRETE; | |
| 90 channels_ = channels; | |
| 91 } | |
| 92 | |
| 88 } // namespace media | 93 } // namespace media |
| OLD | NEW |