Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Side by Side Diff: media/audio/audio_parameters.cc

Issue 148553003: Clean up histogram'd media enum max values. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix naming collision Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/audio/audio_output_resampler.cc ('k') | media/audio/linux/audio_manager_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 bits_per_sample_ = bits_per_sample; 78 bits_per_sample_ = bits_per_sample;
79 frames_per_buffer_ = frames_per_buffer; 79 frames_per_buffer_ = frames_per_buffer;
80 } 80 }
81 81
82 bool AudioParameters::IsValid() const { 82 bool AudioParameters::IsValid() const {
83 return (format_ >= AUDIO_PCM_LINEAR) && 83 return (format_ >= AUDIO_PCM_LINEAR) &&
84 (format_ < AUDIO_LAST_FORMAT) && 84 (format_ < AUDIO_LAST_FORMAT) &&
85 (channels_ > 0) && 85 (channels_ > 0) &&
86 (channels_ <= media::limits::kMaxChannels) && 86 (channels_ <= media::limits::kMaxChannels) &&
87 (channel_layout_ > CHANNEL_LAYOUT_UNSUPPORTED) && 87 (channel_layout_ > CHANNEL_LAYOUT_UNSUPPORTED) &&
88 (channel_layout_ < CHANNEL_LAYOUT_MAX) && 88 (channel_layout_ <= CHANNEL_LAYOUT_MAX) &&
89 (input_channels_ >= 0) && 89 (input_channels_ >= 0) &&
90 (input_channels_ <= media::limits::kMaxChannels) && 90 (input_channels_ <= media::limits::kMaxChannels) &&
91 (sample_rate_ >= media::limits::kMinSampleRate) && 91 (sample_rate_ >= media::limits::kMinSampleRate) &&
92 (sample_rate_ <= media::limits::kMaxSampleRate) && 92 (sample_rate_ <= media::limits::kMaxSampleRate) &&
93 (bits_per_sample_ > 0) && 93 (bits_per_sample_ > 0) &&
94 (bits_per_sample_ <= media::limits::kMaxBitsPerSample) && 94 (bits_per_sample_ <= media::limits::kMaxBitsPerSample) &&
95 (frames_per_buffer_ > 0) && 95 (frames_per_buffer_ > 0) &&
96 (frames_per_buffer_ <= media::limits::kMaxSamplesPerPacket); 96 (frames_per_buffer_ <= media::limits::kMaxSamplesPerPacket);
97 } 97 }
98 98
99 int AudioParameters::GetBytesPerBuffer() const { 99 int AudioParameters::GetBytesPerBuffer() const {
100 return frames_per_buffer_ * GetBytesPerFrame(); 100 return frames_per_buffer_ * GetBytesPerFrame();
101 } 101 }
102 102
103 int AudioParameters::GetBytesPerSecond() const { 103 int AudioParameters::GetBytesPerSecond() const {
104 return sample_rate_ * GetBytesPerFrame(); 104 return sample_rate_ * GetBytesPerFrame();
105 } 105 }
106 106
107 int AudioParameters::GetBytesPerFrame() const { 107 int AudioParameters::GetBytesPerFrame() const {
108 return channels_ * bits_per_sample_ / 8; 108 return channels_ * bits_per_sample_ / 8;
109 } 109 }
110 110
111 base::TimeDelta AudioParameters::GetBufferDuration() const { 111 base::TimeDelta AudioParameters::GetBufferDuration() const {
112 return base::TimeDelta::FromMicroseconds( 112 return base::TimeDelta::FromMicroseconds(
113 frames_per_buffer_ * base::Time::kMicrosecondsPerSecond / 113 frames_per_buffer_ * base::Time::kMicrosecondsPerSecond /
114 static_cast<float>(sample_rate_)); 114 static_cast<float>(sample_rate_));
115 } 115 }
116 116
117 } // namespace media 117 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_output_resampler.cc ('k') | media/audio/linux/audio_manager_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698