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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "media/base/limits.h" | 8 #include "media/base/limits.h" |
9 | 9 |
10 namespace media { | 10 namespace media { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 } | 82 } |
83 | 83 |
84 int AudioParameters::GetBytesPerSecond() const { | 84 int AudioParameters::GetBytesPerSecond() const { |
85 return sample_rate_ * GetBytesPerFrame(); | 85 return sample_rate_ * GetBytesPerFrame(); |
86 } | 86 } |
87 | 87 |
88 int AudioParameters::GetBytesPerFrame() const { | 88 int AudioParameters::GetBytesPerFrame() const { |
89 return channels_ * bits_per_sample_ / 8; | 89 return channels_ * bits_per_sample_ / 8; |
90 } | 90 } |
91 | 91 |
| 92 base::TimeDelta AudioParameters::GetBufferDuration() const { |
| 93 return base::TimeDelta::FromMicroseconds( |
| 94 frames_per_buffer_ * base::Time::kMicrosecondsPerSecond / |
| 95 static_cast<float>(sample_rate_)); |
| 96 } |
| 97 |
92 void AudioParameters::SetDiscreteChannels(int channels) { | 98 void AudioParameters::SetDiscreteChannels(int channels) { |
93 channel_layout_ = CHANNEL_LAYOUT_DISCRETE; | 99 channel_layout_ = CHANNEL_LAYOUT_DISCRETE; |
94 channels_ = channels; | 100 channels_ = channels; |
95 } | 101 } |
96 | 102 |
97 } // namespace media | 103 } // namespace media |
OLD | NEW |