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

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

Issue 12387006: Pass more detailed audio hardware configuration information to the renderer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 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 | Annotate | Revision Log
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 "media/base/limits.h" 7 #include "media/base/limits.h"
8 8
9 namespace media { 9 namespace media {
10 10
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 bits_per_sample_ = bits_per_sample; 54 bits_per_sample_ = bits_per_sample;
55 frames_per_buffer_ = frames_per_buffer; 55 frames_per_buffer_ = frames_per_buffer;
56 channels_ = ChannelLayoutToChannelCount(channel_layout); 56 channels_ = ChannelLayoutToChannelCount(channel_layout);
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) &&
67 (input_channels_ <= media::limits::kMaxChannels) && 67 (input_channels_ <= media::limits::kMaxChannels) &&
68 (sample_rate_ >= media::limits::kMinSampleRate) && 68 (sample_rate_ >= media::limits::kMinSampleRate) &&
69 (sample_rate_ <= media::limits::kMaxSampleRate) && 69 (sample_rate_ <= media::limits::kMaxSampleRate) &&
70 (bits_per_sample_ > 0) && 70 (bits_per_sample_ > 0) &&
71 (bits_per_sample_ <= media::limits::kMaxBitsPerSample) && 71 (bits_per_sample_ <= media::limits::kMaxBitsPerSample) &&
72 (frames_per_buffer_ > 0) && 72 (frames_per_buffer_ > 0) &&
73 (frames_per_buffer_ <= media::limits::kMaxSamplesPerPacket); 73 (frames_per_buffer_ <= media::limits::kMaxSamplesPerPacket);
74 } 74 }
75 75
76 int AudioParameters::GetBytesPerBuffer() const { 76 int AudioParameters::GetBytesPerBuffer() const {
77 return frames_per_buffer_ * GetBytesPerFrame(); 77 return frames_per_buffer_ * GetBytesPerFrame();
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_UNSUPPORTED;
90 channels_ = channels;
91 }
92
88 } // namespace media 93 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698