Make AudioBuffer::InterleaveTo const

The only non-const operation was a one-time initialization of a member only used in this function. I've moved it to the ctor.

BUG=webrtc:5298

Review-Url: https://codereview.webrtc.org/2741733002
Cr-Commit-Position: refs/heads/master@{#17223}
This commit is contained in:
kthelgason 2017-03-14 03:10:07 -07:00 committed by Commit bot
parent cfd88bbe80
commit c7daea8d6a
2 changed files with 4 additions and 7 deletions

View File

@ -61,7 +61,8 @@ AudioBuffer::AudioBuffer(size_t input_num_frames,
reference_copied_(false),
activity_(AudioFrame::kVadUnknown),
keyboard_data_(NULL),
data_(new IFChannelBuffer(proc_num_frames_, num_proc_channels_)) {
data_(new IFChannelBuffer(proc_num_frames_, num_proc_channels_)),
output_buffer_(new IFChannelBuffer(output_num_frames_, num_channels_)) {
RTC_DCHECK_GT(input_num_frames_, 0);
RTC_DCHECK_GT(proc_num_frames_, 0);
RTC_DCHECK_GT(output_num_frames_, 0);
@ -416,7 +417,7 @@ void AudioBuffer::DeinterleaveFrom(AudioFrame* frame) {
}
}
void AudioBuffer::InterleaveTo(AudioFrame* frame, bool data_changed) {
void AudioBuffer::InterleaveTo(AudioFrame* frame, bool data_changed) const {
frame->vad_activity_ = activity_;
if (!data_changed) {
return;
@ -428,10 +429,6 @@ void AudioBuffer::InterleaveTo(AudioFrame* frame, bool data_changed) {
// Resample if necessary.
IFChannelBuffer* data_ptr = data_.get();
if (proc_num_frames_ != output_num_frames_) {
if (!output_buffer_) {
output_buffer_.reset(
new IFChannelBuffer(output_num_frames_, num_channels_));
}
for (size_t i = 0; i < num_channels_; ++i) {
output_resamplers_[i]->Resample(
data_->fbuf()->channels()[i], proc_num_frames_,

View File

@ -110,7 +110,7 @@ class AudioBuffer {
void DeinterleaveFrom(AudioFrame* audioFrame);
// If |data_changed| is false, only the non-audio data members will be copied
// to |frame|.
void InterleaveTo(AudioFrame* frame, bool data_changed);
void InterleaveTo(AudioFrame* frame, bool data_changed) const;
// Use for float deinterleaved data.
void CopyFrom(const float* const* data, const StreamConfig& stream_config);