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 "media/base/limits.h" | 7 #include "media/base/limits.h" |
8 | 8 |
9 AudioParameters::AudioParameters() | 9 AudioParameters::AudioParameters() |
10 : format_(AUDIO_PCM_LINEAR), | 10 : format_(AUDIO_PCM_LINEAR), |
| 11 use_browser_mixer_(false), |
11 channel_layout_(CHANNEL_LAYOUT_NONE), | 12 channel_layout_(CHANNEL_LAYOUT_NONE), |
12 sample_rate_(0), | 13 sample_rate_(0), |
13 bits_per_sample_(0), | 14 bits_per_sample_(0), |
14 frames_per_buffer_(0), | 15 frames_per_buffer_(0), |
15 channels_(0) { | 16 channels_(0) { |
16 } | 17 } |
17 | 18 |
18 AudioParameters::AudioParameters(Format format, ChannelLayout channel_layout, | 19 AudioParameters::AudioParameters(Format format, |
19 int sample_rate, int bits_per_sample, | 20 bool use_browser_mixer, |
| 21 ChannelLayout channel_layout, |
| 22 int sample_rate, |
| 23 int bits_per_sample, |
20 int frames_per_buffer) | 24 int frames_per_buffer) |
21 : format_(format), | 25 : format_(format), |
| 26 use_browser_mixer_(use_browser_mixer), |
22 channel_layout_(channel_layout), | 27 channel_layout_(channel_layout), |
23 sample_rate_(sample_rate), | 28 sample_rate_(sample_rate), |
24 bits_per_sample_(bits_per_sample), | 29 bits_per_sample_(bits_per_sample), |
25 frames_per_buffer_(frames_per_buffer), | 30 frames_per_buffer_(frames_per_buffer), |
26 channels_(ChannelLayoutToChannelCount(channel_layout)) { | 31 channels_(ChannelLayoutToChannelCount(channel_layout)) { |
27 } | 32 } |
28 | 33 |
29 void AudioParameters::Reset(Format format, ChannelLayout channel_layout, | 34 void AudioParameters::Reset(Format format, |
30 int sample_rate, int bits_per_sample, | 35 bool use_browser_mixer, |
| 36 ChannelLayout channel_layout, |
| 37 int sample_rate, |
| 38 int bits_per_sample, |
31 int frames_per_buffer) { | 39 int frames_per_buffer) { |
32 format_ = format; | 40 format_ = format; |
| 41 use_browser_mixer_ = use_browser_mixer; |
33 channel_layout_ = channel_layout; | 42 channel_layout_ = channel_layout; |
34 sample_rate_ = sample_rate; | 43 sample_rate_ = sample_rate; |
35 bits_per_sample_ = bits_per_sample; | 44 bits_per_sample_ = bits_per_sample; |
36 frames_per_buffer_ = frames_per_buffer; | 45 frames_per_buffer_ = frames_per_buffer; |
37 channels_ = ChannelLayoutToChannelCount(channel_layout); | 46 channels_ = ChannelLayoutToChannelCount(channel_layout); |
38 } | 47 } |
39 | 48 |
40 bool AudioParameters::IsValid() const { | 49 bool AudioParameters::IsValid() const { |
41 return (format_ >= 0) && (format_ < AUDIO_LAST_FORMAT) && | 50 return (format_ >= 0) && (format_ < AUDIO_LAST_FORMAT) && |
42 (channels_ > 0) && (channels_ <= media::limits::kMaxChannels) && | 51 (channels_ > 0) && (channels_ <= media::limits::kMaxChannels) && |
(...skipping 17 matching lines...) Expand all Loading... |
60 return channels_ * bits_per_sample_ / 8; | 69 return channels_ * bits_per_sample_ / 8; |
61 } | 70 } |
62 | 71 |
63 bool AudioParameters::Compare::operator()( | 72 bool AudioParameters::Compare::operator()( |
64 const AudioParameters& a, | 73 const AudioParameters& a, |
65 const AudioParameters& b) const { | 74 const AudioParameters& b) const { |
66 if (a.format_ < b.format_) | 75 if (a.format_ < b.format_) |
67 return true; | 76 return true; |
68 if (a.format_ > b.format_) | 77 if (a.format_ > b.format_) |
69 return false; | 78 return false; |
| 79 if (a.use_browser_mixer_ != b.use_browser_mixer_) |
| 80 return a.use_browser_mixer_ < b.use_browser_mixer_; |
70 if (a.channels_ < b.channels_) | 81 if (a.channels_ < b.channels_) |
71 return true; | 82 return true; |
72 if (a.channels_ > b.channels_) | 83 if (a.channels_ > b.channels_) |
73 return false; | 84 return false; |
74 if (a.sample_rate_ < b.sample_rate_) | 85 if (a.sample_rate_ < b.sample_rate_) |
75 return true; | 86 return true; |
76 if (a.sample_rate_ > b.sample_rate_) | 87 if (a.sample_rate_ > b.sample_rate_) |
77 return false; | 88 return false; |
78 if (a.bits_per_sample_ < b.bits_per_sample_) | 89 if (a.bits_per_sample_ < b.bits_per_sample_) |
79 return true; | 90 return true; |
80 if (a.bits_per_sample_ > b.bits_per_sample_) | 91 if (a.bits_per_sample_ > b.bits_per_sample_) |
81 return false; | 92 return false; |
82 return a.frames_per_buffer_ < b.frames_per_buffer_; | 93 return a.frames_per_buffer_ < b.frames_per_buffer_; |
83 } | 94 } |
OLD | NEW |