Chromium Code Reviews| Index: media/audio/audio_parameters.h |
| diff --git a/media/audio/audio_parameters.h b/media/audio/audio_parameters.h |
| index a73982e6ba259721770158a9c00bbf707b28f283..57fb960e488fe09a4532f9cbeb321ed61d9b6a92 100644 |
| --- a/media/audio/audio_parameters.h |
| +++ b/media/audio/audio_parameters.h |
| @@ -80,18 +80,17 @@ class MEDIA_EXPORT AudioParameters { |
| }; |
| AudioParameters(); |
| - AudioParameters(Format format, ChannelLayout channel_layout, |
| - int sample_rate, int bits_per_sample, |
| + AudioParameters(Format format, |
| + ChannelLayout channel_layout, |
| + int sample_rate, |
|
tommi (sloooow) - chröme
2015/09/05 09:49:58
this is a great improvement over how things were.
ajm
2015/09/06 07:24:14
I could see using an enum for bits_per_sample, sin
|
| + int bits_per_sample, |
| int frames_per_buffer); |
| - AudioParameters(Format format, ChannelLayout channel_layout, |
| - int sample_rate, int bits_per_sample, |
| - int frames_per_buffer, int effects); |
| - AudioParameters(Format format, ChannelLayout channel_layout, |
| - int channels, int sample_rate, int bits_per_sample, |
| - int frames_per_buffer, int effects); |
| - |
| - void Reset(Format format, ChannelLayout channel_layout, |
| - int channels, int sample_rate, int bits_per_sample, |
| + |
| + // Re-initializes all members. |
| + void Reset(Format format, |
| + ChannelLayout channel_layout, |
| + int sample_rate, |
| + int bits_per_sample, |
| int frames_per_buffer); |
| // Checks that all values are in the expected range. All limits are specified |
| @@ -118,25 +117,48 @@ class MEDIA_EXPORT AudioParameters { |
| // Comparison with other AudioParams. |
| bool Equals(const AudioParameters& other) const; |
| + void set_format(Format format) { format_ = format; } |
| Format format() const { return format_; } |
| + |
| + // A setter for channel_layout_ is intentionally excluded. |
| ChannelLayout channel_layout() const { return channel_layout_; } |
| + |
| + // The number of channels is usually computed from channel_layout_. Setting |
| + // this explictly is only required with CHANNEL_LAYOUT_DISCRETE. |
| + void set_channels_for_discrete(int channels) { |
| + DCHECK(channel_layout_ == CHANNEL_LAYOUT_DISCRETE || |
| + channels == ChannelLayoutToChannelCount(channel_layout_)); |
| + channels_ = channels; |
| + } |
| + int channels() const { return channels_; } |
| + |
| + void set_sample_rate(int sample_rate) { sample_rate_ = sample_rate; } |
| int sample_rate() const { return sample_rate_; } |
| + |
| + void set_bits_per_sample(int bits_per_sample) { |
| + bits_per_sample_ = bits_per_sample; |
| + } |
| int bits_per_sample() const { return bits_per_sample_; } |
| + |
| + void set_frames_per_buffer(int frames_per_buffer) { |
| + frames_per_buffer_ = frames_per_buffer; |
| + } |
| int frames_per_buffer() const { return frames_per_buffer_; } |
| - int channels() const { return channels_; } |
| + |
| + void set_effects(int effects) { effects_ = effects; } |
| int effects() const { return effects_; } |
| + AudioParameters(const AudioParameters&) = default; |
| + AudioParameters& operator=(const AudioParameters&) = default; |
| + |
| private: |
| - // These members are mutable to support entire struct assignment. They should |
| - // not be mutated individually. |
| Format format_; // Format of the stream. |
| ChannelLayout channel_layout_; // Order of surround sound channels. |
| + int channels_; // Number of channels. Value set based on |
| + // |channel_layout|. |
| int sample_rate_; // Sampling frequency/rate. |
| int bits_per_sample_; // Number of bits per sample. |
| int frames_per_buffer_; // Number of frames in a buffer. |
| - |
| - int channels_; // Number of channels. Value set based on |
| - // |channel_layout|. |
| int effects_; // Bitmask using PlatformEffectsMask. |
| }; |