| Index: webrtc/voice_engine/file_recorder.cc
|
| diff --git a/webrtc/voice_engine/file_recorder.cc b/webrtc/voice_engine/file_recorder.cc
|
| index 9a0edb057ba29bb3006b9a837fa7df7bfbc164e5..cb61c9a852c6407146a34f8b92cd062b85280fe1 100644
|
| --- a/webrtc/voice_engine/file_recorder.cc
|
| +++ b/webrtc/voice_engine/file_recorder.cc
|
| @@ -12,6 +12,7 @@
|
|
|
| #include <list>
|
|
|
| +#include "webrtc/audio/utility/audio_frame_operations.h"
|
| #include "webrtc/base/platform_thread.h"
|
| #include "webrtc/common_audio/resampler/include/resampler.h"
|
| #include "webrtc/common_types.h"
|
| @@ -161,12 +162,10 @@ int32_t FileRecorderImpl::RecordAudioToFile(
|
| tempAudioFrame.sample_rate_hz_ = incomingAudioFrame.sample_rate_hz_;
|
| tempAudioFrame.samples_per_channel_ =
|
| incomingAudioFrame.samples_per_channel_;
|
| - for (size_t i = 0; i < (incomingAudioFrame.samples_per_channel_); i++) {
|
| - // Sample value is the average of left and right buffer rounded to
|
| - // closest integer value. Note samples can be either 1 or 2 byte.
|
| - tempAudioFrame.data_[i] = ((incomingAudioFrame.data_[2 * i] +
|
| - incomingAudioFrame.data_[(2 * i) + 1] + 1) >>
|
| - 1);
|
| + if (!incomingAudioFrame.muted()) {
|
| + AudioFrameOperations::StereoToMono(
|
| + incomingAudioFrame.data(), incomingAudioFrame.samples_per_channel_,
|
| + tempAudioFrame.mutable_data());
|
| }
|
| } else if (incomingAudioFrame.num_channels_ == 1 && _moduleFile->IsStereo()) {
|
| // Recording stereo but incoming audio is mono.
|
| @@ -174,10 +173,10 @@ int32_t FileRecorderImpl::RecordAudioToFile(
|
| tempAudioFrame.sample_rate_hz_ = incomingAudioFrame.sample_rate_hz_;
|
| tempAudioFrame.samples_per_channel_ =
|
| incomingAudioFrame.samples_per_channel_;
|
| - for (size_t i = 0; i < (incomingAudioFrame.samples_per_channel_); i++) {
|
| - // Duplicate sample to both channels
|
| - tempAudioFrame.data_[2 * i] = incomingAudioFrame.data_[i];
|
| - tempAudioFrame.data_[2 * i + 1] = incomingAudioFrame.data_[i];
|
| + if (!incomingAudioFrame.muted()) {
|
| + AudioFrameOperations::MonoToStereo(
|
| + incomingAudioFrame.data(), incomingAudioFrame.samples_per_channel_,
|
| + tempAudioFrame.mutable_data());
|
| }
|
| }
|
|
|
| @@ -206,8 +205,9 @@ int32_t FileRecorderImpl::RecordAudioToFile(
|
| _audioResampler.ResetIfNeeded(ptrAudioFrame->sample_rate_hz_,
|
| codec_info_.plfreq,
|
| ptrAudioFrame->num_channels_);
|
| + // TODO(yujo): skip resample if frame is muted.
|
| _audioResampler.Push(
|
| - ptrAudioFrame->data_,
|
| + ptrAudioFrame->data(),
|
| ptrAudioFrame->samples_per_channel_ * ptrAudioFrame->num_channels_,
|
| reinterpret_cast<int16_t*>(_audioBuffer), MAX_AUDIO_BUFFER_IN_BYTES,
|
| outLen);
|
|
|