Commit 015d9908 authored by burnik's avatar burnik Committed by Commit bot

Refactoring AudioParameters |operator==| to |Equals()| method

The == operator is re-factored to:

  bool Equals(const AudioParameters& other) const;

This will also help avoid expressions like !(a == b), transforming them to !a.Equals(b) instead.

BUG=416506

Review URL: https://codereview.chromium.org/593653003

Cr-Commit-Position: refs/heads/master@{#296230}
parent 54be1287
...@@ -273,7 +273,7 @@ void WebRtcLocalAudioRenderer::ReconfigureSink( ...@@ -273,7 +273,7 @@ void WebRtcLocalAudioRenderer::ReconfigureSink(
DVLOG(1) << "DUCKING not forced ON for output"; DVLOG(1) << "DUCKING not forced ON for output";
} }
if (source_params_ == params) if (source_params_.Equals(params))
return; return;
// Reset the |source_params_|, |sink_params_| and |loopback_fifo_| to match // Reset the |source_params_|, |sink_params_| and |loopback_fifo_| to match
......
...@@ -62,8 +62,8 @@ class AudioManagerBase::CompareByParams { ...@@ -62,8 +62,8 @@ class AudioManagerBase::CompareByParams {
// existing dispatcher are the same as the requested dispatcher. // existing dispatcher are the same as the requested dispatcher.
// 2) Unified IO is used, input_params and output_params of the existing // 2) Unified IO is used, input_params and output_params of the existing
// dispatcher are the same as the request dispatcher. // dispatcher are the same as the request dispatcher.
return (dispatcher_->input_params == dispatcher_in->input_params && return (dispatcher_->input_params.Equals(dispatcher_in->input_params) &&
dispatcher_->output_params == dispatcher_in->output_params && dispatcher_->output_params.Equals(dispatcher_in->output_params) &&
dispatcher_->output_device_id == dispatcher_in->output_device_id); dispatcher_->output_device_id == dispatcher_in->output_device_id);
} }
......
...@@ -105,4 +105,14 @@ base::TimeDelta AudioParameters::GetBufferDuration() const { ...@@ -105,4 +105,14 @@ base::TimeDelta AudioParameters::GetBufferDuration() const {
static_cast<float>(sample_rate_)); static_cast<float>(sample_rate_));
} }
bool AudioParameters::Equals(const AudioParameters& other) const {
return format_ == other.format() &&
sample_rate_ == other.sample_rate() &&
channel_layout_ == other.channel_layout() &&
channels_ == other.channels() &&
bits_per_sample_ == other.bits_per_sample() &&
frames_per_buffer_ == other.frames_per_buffer() &&
effects_ == other.effects();
}
} // namespace media } // namespace media
...@@ -85,6 +85,9 @@ class MEDIA_EXPORT AudioParameters { ...@@ -85,6 +85,9 @@ class MEDIA_EXPORT AudioParameters {
// and sample_rate(). // and sample_rate().
base::TimeDelta GetBufferDuration() const; base::TimeDelta GetBufferDuration() const;
// Comparison with other AudioParams.
bool Equals(const AudioParameters& other) const;
Format format() const { return format_; } Format format() const { return format_; }
ChannelLayout channel_layout() const { return channel_layout_; } ChannelLayout channel_layout() const { return channel_layout_; }
int sample_rate() const { return sample_rate_; } int sample_rate() const { return sample_rate_; }
...@@ -93,17 +96,6 @@ class MEDIA_EXPORT AudioParameters { ...@@ -93,17 +96,6 @@ class MEDIA_EXPORT AudioParameters {
int channels() const { return channels_; } int channels() const { return channels_; }
int effects() const { return effects_; } int effects() const { return effects_; }
// Comparison with other AudioParams.
bool operator==(const AudioParameters& other) const {
return format_ == other.format() &&
sample_rate_ == other.sample_rate() &&
channel_layout_ == other.channel_layout() &&
channels_ == other.channels() &&
bits_per_sample_ == other.bits_per_sample() &&
frames_per_buffer_ == other.frames_per_buffer() &&
effects_ == other.effects();
}
private: private:
// These members are mutable to support entire struct assignment. They should // These members are mutable to support entire struct assignment. They should
// not be mutated individually. // not be mutated individually.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment