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

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 "base/logging.h"
7 #include "media/base/limits.h" 8 #include "media/base/limits.h"
8 9
9 namespace media { 10 namespace media {
10 11
11 AudioParameters::AudioParameters() 12 AudioParameters::AudioParameters()
12 : format_(AUDIO_PCM_LINEAR), 13 : format_(AUDIO_PCM_LINEAR),
13 channel_layout_(CHANNEL_LAYOUT_NONE), 14 channel_layout_(CHANNEL_LAYOUT_NONE),
14 sample_rate_(0), 15 sample_rate_(0),
15 bits_per_sample_(0), 16 bits_per_sample_(0),
16 frames_per_buffer_(0), 17 frames_per_buffer_(0),
(...skipping 20 matching lines...) Expand all
37 : format_(format), 38 : format_(format),
38 channel_layout_(channel_layout), 39 channel_layout_(channel_layout),
39 sample_rate_(sample_rate), 40 sample_rate_(sample_rate),
40 bits_per_sample_(bits_per_sample), 41 bits_per_sample_(bits_per_sample),
41 frames_per_buffer_(frames_per_buffer), 42 frames_per_buffer_(frames_per_buffer),
42 channels_(ChannelLayoutToChannelCount(channel_layout)), 43 channels_(ChannelLayoutToChannelCount(channel_layout)),
43 input_channels_(input_channels) { 44 input_channels_(input_channels) {
44 } 45 }
45 46
46 void AudioParameters::Reset(Format format, ChannelLayout channel_layout, 47 void AudioParameters::Reset(Format format, ChannelLayout channel_layout,
47 int input_channels, 48 int channels, int input_channels,
48 int sample_rate, int bits_per_sample, 49 int sample_rate, int bits_per_sample,
49 int frames_per_buffer) { 50 int frames_per_buffer) {
51 if (channel_layout != CHANNEL_LAYOUT_DISCRETE)
52 DCHECK_EQ(channels, ChannelLayoutToChannelCount(channel_layout));
53
50 format_ = format; 54 format_ = format;
51 channel_layout_ = channel_layout; 55 channel_layout_ = channel_layout;
56 channels_ = channels;
52 input_channels_ = input_channels; 57 input_channels_ = input_channels;
53 sample_rate_ = sample_rate; 58 sample_rate_ = sample_rate;
54 bits_per_sample_ = bits_per_sample; 59 bits_per_sample_ = bits_per_sample;
55 frames_per_buffer_ = frames_per_buffer; 60 frames_per_buffer_ = frames_per_buffer;
56 channels_ = ChannelLayoutToChannelCount(channel_layout);
57 } 61 }
58 62
59 bool AudioParameters::IsValid() const { 63 bool AudioParameters::IsValid() const {
60 return (format_ >= AUDIO_PCM_LINEAR) && 64 return (format_ >= AUDIO_PCM_LINEAR) &&
61 (format_ < AUDIO_LAST_FORMAT) && 65 (format_ < AUDIO_LAST_FORMAT) &&
62 (channels_ > 0) && 66 (channels_ > 0) &&
63 (channels_ <= media::limits::kMaxChannels) && 67 (channels_ <= media::limits::kMaxChannels) &&
64 (channel_layout_ > CHANNEL_LAYOUT_UNSUPPORTED) && 68 (channel_layout_ > CHANNEL_LAYOUT_UNSUPPORTED) &&
65 (channel_layout_ < CHANNEL_LAYOUT_MAX) && 69 (channel_layout_ < CHANNEL_LAYOUT_MAX) &&
66 (input_channels_ >= 0) && 70 (input_channels_ >= 0) &&
(...skipping 11 matching lines...) Expand all
78 } 82 }
79 83
80 int AudioParameters::GetBytesPerSecond() const { 84 int AudioParameters::GetBytesPerSecond() const {
81 return sample_rate_ * GetBytesPerFrame(); 85 return sample_rate_ * GetBytesPerFrame();
82 } 86 }
83 87
84 int AudioParameters::GetBytesPerFrame() const { 88 int AudioParameters::GetBytesPerFrame() const {
85 return channels_ * bits_per_sample_ / 8; 89 return channels_ * bits_per_sample_ / 8;
86 } 90 }
87 91
92 void AudioParameters::SetDiscreteChannels(int channels) {
93 channel_layout_ = CHANNEL_LAYOUT_DISCRETE;
94 channels_ = channels;
95 }
96
88 } // namespace media 97 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698