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

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

Issue 593653003: Refactoring AudioParameters |operator==| to |Equals()| method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved implementation to .cc Created 6 years, 2 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_manager_base.cc ('k') | media/audio/audio_parameters.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 #ifndef MEDIA_AUDIO_AUDIO_PARAMETERS_H_ 5 #ifndef MEDIA_AUDIO_AUDIO_PARAMETERS_H_
6 #define MEDIA_AUDIO_AUDIO_PARAMETERS_H_ 6 #define MEDIA_AUDIO_AUDIO_PARAMETERS_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "media/base/channel_layout.h" 10 #include "media/base/channel_layout.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // Returns the number of bytes representing one second of audio. 78 // Returns the number of bytes representing one second of audio.
79 int GetBytesPerSecond() const; 79 int GetBytesPerSecond() const;
80 80
81 // Returns the number of bytes representing a frame of audio. 81 // Returns the number of bytes representing a frame of audio.
82 int GetBytesPerFrame() const; 82 int GetBytesPerFrame() const;
83 83
84 // Returns the duration of this buffer as calculated from frames_per_buffer() 84 // Returns the duration of this buffer as calculated from frames_per_buffer()
85 // and sample_rate(). 85 // and sample_rate().
86 base::TimeDelta GetBufferDuration() const; 86 base::TimeDelta GetBufferDuration() const;
87 87
88 // Comparison with other AudioParams.
89 bool Equals(const AudioParameters& other) const;
90
88 Format format() const { return format_; } 91 Format format() const { return format_; }
89 ChannelLayout channel_layout() const { return channel_layout_; } 92 ChannelLayout channel_layout() const { return channel_layout_; }
90 int sample_rate() const { return sample_rate_; } 93 int sample_rate() const { return sample_rate_; }
91 int bits_per_sample() const { return bits_per_sample_; } 94 int bits_per_sample() const { return bits_per_sample_; }
92 int frames_per_buffer() const { return frames_per_buffer_; } 95 int frames_per_buffer() const { return frames_per_buffer_; }
93 int channels() const { return channels_; } 96 int channels() const { return channels_; }
94 int effects() const { return effects_; } 97 int effects() const { return effects_; }
95 98
96 // Comparison with other AudioParams.
97 bool operator==(const AudioParameters& other) const {
98 return format_ == other.format() &&
99 sample_rate_ == other.sample_rate() &&
100 channel_layout_ == other.channel_layout() &&
101 channels_ == other.channels() &&
102 bits_per_sample_ == other.bits_per_sample() &&
103 frames_per_buffer_ == other.frames_per_buffer() &&
104 effects_ == other.effects();
105 }
106
107 private: 99 private:
108 // These members are mutable to support entire struct assignment. They should 100 // These members are mutable to support entire struct assignment. They should
109 // not be mutated individually. 101 // not be mutated individually.
110 Format format_; // Format of the stream. 102 Format format_; // Format of the stream.
111 ChannelLayout channel_layout_; // Order of surround sound channels. 103 ChannelLayout channel_layout_; // Order of surround sound channels.
112 int sample_rate_; // Sampling frequency/rate. 104 int sample_rate_; // Sampling frequency/rate.
113 int bits_per_sample_; // Number of bits per sample. 105 int bits_per_sample_; // Number of bits per sample.
114 int frames_per_buffer_; // Number of frames in a buffer. 106 int frames_per_buffer_; // Number of frames in a buffer.
115 107
116 int channels_; // Number of channels. Value set based on 108 int channels_; // Number of channels. Value set based on
(...skipping 10 matching lines...) Expand all
127 if (a.sample_rate() != b.sample_rate()) 119 if (a.sample_rate() != b.sample_rate())
128 return a.sample_rate() < b.sample_rate(); 120 return a.sample_rate() < b.sample_rate();
129 if (a.bits_per_sample() != b.bits_per_sample()) 121 if (a.bits_per_sample() != b.bits_per_sample())
130 return a.bits_per_sample() < b.bits_per_sample(); 122 return a.bits_per_sample() < b.bits_per_sample();
131 return a.frames_per_buffer() < b.frames_per_buffer(); 123 return a.frames_per_buffer() < b.frames_per_buffer();
132 } 124 }
133 125
134 } // namespace media 126 } // namespace media
135 127
136 #endif // MEDIA_AUDIO_AUDIO_PARAMETERS_H_ 128 #endif // MEDIA_AUDIO_AUDIO_PARAMETERS_H_
OLDNEW
« no previous file with comments | « media/audio/audio_manager_base.cc ('k') | media/audio/audio_parameters.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698