From 4cc763621eeeb29d0bf1d16d69b2f96d711ead2b Mon Sep 17 00:00:00 2001 From: "kwiberg@webrtc.org" Date: Thu, 8 May 2014 07:10:11 +0000 Subject: [PATCH] AudioBuffer: Eliminate data_was_mixed_, and document what's left of data_ data_was_mixed_ was always false, so it can be removed. That makes the role of data_ simpler, but not so simple that it doesn't merit an explanation. BUG= R=aluebs@webrtc.org, andrew@webrtc.org Review URL: https://webrtc-codereview.appspot.com/17409004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@6076 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/modules/audio_processing/audio_buffer.cc | 13 ++----------- webrtc/modules/audio_processing/audio_buffer.h | 6 ++++-- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/webrtc/modules/audio_processing/audio_buffer.cc b/webrtc/modules/audio_processing/audio_buffer.cc index 9160f694a2..024b700cac 100644 --- a/webrtc/modules/audio_processing/audio_buffer.cc +++ b/webrtc/modules/audio_processing/audio_buffer.cc @@ -97,7 +97,6 @@ AudioBuffer::AudioBuffer(int input_samples_per_channel, samples_per_split_channel_(proc_samples_per_channel_), num_mixed_channels_(0), num_mixed_low_pass_channels_(0), - data_was_mixed_(false), reference_copied_(false), activity_(AudioFrame::kVadUnknown), is_muted_(false), @@ -220,7 +219,6 @@ void AudioBuffer::CopyTo(int samples_per_channel, void AudioBuffer::InitForNewData() { data_ = NULL; keyboard_data_ = NULL; - data_was_mixed_ = false; num_mixed_channels_ = 0; num_mixed_low_pass_channels_ = 0; reference_copied_ = false; @@ -231,6 +229,7 @@ void AudioBuffer::InitForNewData() { const int16_t* AudioBuffer::data(int channel) const { assert(channel >= 0 && channel < num_proc_channels_); if (data_ != NULL) { + assert(channel == 0 && num_proc_channels_ == 1); return data_; } @@ -370,15 +369,7 @@ void AudioBuffer::InterleaveTo(AudioFrame* frame, bool data_changed) const { } if (num_proc_channels_ == 1) { - if (data_was_mixed_) { - memcpy(frame->data_, - channels_->channel(0), - sizeof(int16_t) * proc_samples_per_channel_); - } else { - // These should point to the same buffer in this case. - assert(data_ == frame->data_); - } - + assert(data_ == frame->data_); return; } diff --git a/webrtc/modules/audio_processing/audio_buffer.h b/webrtc/modules/audio_processing/audio_buffer.h index 79f4689200..2b93510638 100644 --- a/webrtc/modules/audio_processing/audio_buffer.h +++ b/webrtc/modules/audio_processing/audio_buffer.h @@ -104,13 +104,15 @@ class AudioBuffer { int samples_per_split_channel_; int num_mixed_channels_; int num_mixed_low_pass_channels_; - // Whether the original data was replaced with mixed data. - bool data_was_mixed_; bool reference_copied_; AudioFrame::VADActivity activity_; bool is_muted_; + // If non-null, use this instead of channels_->channel(0). This is an + // optimization for the case num_proc_channels_ == 1 that allows us to point + // to the data instead of copying it. int16_t* data_; + const float* keyboard_data_; scoped_ptr > channels_; scoped_ptr split_channels_;