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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 } | 70 } |
71 | 71 |
72 int AudioParameters::GetBytesPerSecond() const { | 72 int AudioParameters::GetBytesPerSecond() const { |
73 return sample_rate_ * GetBytesPerFrame(); | 73 return sample_rate_ * GetBytesPerFrame(); |
74 } | 74 } |
75 | 75 |
76 int AudioParameters::GetBytesPerFrame() const { | 76 int AudioParameters::GetBytesPerFrame() const { |
77 return channels_ * bits_per_sample_ / 8; | 77 return channels_ * bits_per_sample_ / 8; |
78 } | 78 } |
79 | 79 |
| 80 double AudioParameters::GetMicrosecondsPerFrame() const { |
| 81 return static_cast<double>(base::Time::kMicrosecondsPerSecond) / sample_rate_; |
| 82 } |
| 83 |
80 base::TimeDelta AudioParameters::GetBufferDuration() const { | 84 base::TimeDelta AudioParameters::GetBufferDuration() const { |
81 return base::TimeDelta::FromMicroseconds(static_cast<int64_t>( | 85 return base::TimeDelta::FromMicroseconds(static_cast<int64_t>( |
82 frames_per_buffer_ * base::Time::kMicrosecondsPerSecond / | 86 frames_per_buffer_ * base::Time::kMicrosecondsPerSecond / |
83 static_cast<float>(sample_rate_))); | 87 static_cast<float>(sample_rate_))); |
84 } | 88 } |
85 | 89 |
86 bool AudioParameters::Equals(const AudioParameters& other) const { | 90 bool AudioParameters::Equals(const AudioParameters& other) const { |
87 return format_ == other.format() && sample_rate_ == other.sample_rate() && | 91 return format_ == other.format() && sample_rate_ == other.sample_rate() && |
88 channel_layout_ == other.channel_layout() && | 92 channel_layout_ == other.channel_layout() && |
89 channels_ == other.channels() && | 93 channels_ == other.channels() && |
90 bits_per_sample_ == other.bits_per_sample() && | 94 bits_per_sample_ == other.bits_per_sample() && |
91 frames_per_buffer_ == other.frames_per_buffer() && | 95 frames_per_buffer_ == other.frames_per_buffer() && |
92 effects_ == other.effects() && mic_positions_ == other.mic_positions_; | 96 effects_ == other.effects() && mic_positions_ == other.mic_positions_; |
93 } | 97 } |
94 | 98 |
95 } // namespace media | 99 } // namespace media |
OLD | NEW |