Index: webrtc/modules/audio_processing/audio_buffer.cc |
diff --git a/webrtc/modules/audio_processing/audio_buffer.cc b/webrtc/modules/audio_processing/audio_buffer.cc |
index 04dcaea799d60af6bbc48d899e9ded8134d6ce03..144a33333e03958c63eb9b75b0c11f6756654beb 100644 |
--- a/webrtc/modules/audio_processing/audio_buffer.cc |
+++ b/webrtc/modules/audio_processing/audio_buffer.cc |
@@ -436,20 +436,27 @@ void AudioBuffer::DeinterleaveFrom(AudioFrame* frame) { |
} |
void AudioBuffer::InterleaveTo(AudioFrame* frame, bool data_changed) const { |
+ if (!data_changed) { |
+ return; |
+ } |
+ |
assert(proc_num_frames_ == output_num_frames_); |
- assert(num_channels_ == num_input_channels_); |
- assert(frame->num_channels_ == num_channels_); |
+ assert(frame->num_channels_ == num_channels_ || num_channels_ == 1); |
assert(frame->samples_per_channel_ == proc_num_frames_); |
frame->vad_activity_ = activity_; |
- if (!data_changed) { |
- return; |
+ if (frame->num_channels_ == num_channels_) { |
+ Interleave(data_->ibuf()->channels(), proc_num_frames_, num_channels_, |
+ frame->data_); |
+ } else { |
+ // Copy single AudioBuffer channel into all AudioFrame channels |
+ int16_t* const* channel_ptr_copies[frame->num_channels_]; |
aluebs-webrtc
2015/07/20 19:33:43
int16_t* channel_ptr_copies[frame->num_channels_];
ekm
2015/07/21 01:02:43
Done.
|
+ for (int i = 0; i < frame->num_channels_; i++) { |
aluebs-webrtc
2015/07/20 19:33:43
++i
ekm
2015/07/21 01:02:43
Done.
|
+ channel_ptr_copies[i] = data_->ibuf()->channels(); |
aluebs-webrtc
2015/07/20 19:33:43
data->ibuf()->channels()[0];
ekm
2015/07/21 01:02:43
Done.
|
+ } |
+ Interleave(data_->ibuf()->channels(), proc_num_frames_, num_channels_, |
aluebs-webrtc
2015/07/20 19:33:43
channel_ptr_copies
ekm
2015/07/21 01:02:43
Done. Phew, nice catch.
|
+ frame->data_); |
} |
- |
- Interleave(data_->ibuf()->channels(), |
- proc_num_frames_, |
- num_channels_, |
- frame->data_); |
} |
void AudioBuffer::CopyLowPassToReference() { |