| Index: webrtc/modules/audio_mixer/audio_frame_manipulator.cc
|
| diff --git a/webrtc/modules/audio_mixer/audio_frame_manipulator.cc b/webrtc/modules/audio_mixer/audio_frame_manipulator.cc
|
| index 8aa0b5ce02dc35c6bd3a9d4a90de48ca82f015d8..fff79a38cf6b4e68f13e30c43a56e31a49dd1efc 100644
|
| --- a/webrtc/modules/audio_mixer/audio_frame_manipulator.cc
|
| +++ b/webrtc/modules/audio_mixer/audio_frame_manipulator.cc
|
| @@ -16,11 +16,16 @@
|
| namespace webrtc {
|
|
|
| uint32_t AudioMixerCalculateEnergy(const AudioFrame& audio_frame) {
|
| + if (audio_frame.muted()) {
|
| + return 0;
|
| + }
|
| +
|
| uint32_t energy = 0;
|
| + const int16_t* frame_data = audio_frame.data();
|
| for (size_t position = 0; position < audio_frame.samples_per_channel_;
|
| position++) {
|
| // TODO(aleloi): This can overflow. Convert to floats.
|
| - energy += audio_frame.data_[position] * audio_frame.data_[position];
|
| + energy += frame_data[position] * frame_data[position];
|
| }
|
| return energy;
|
| }
|
| @@ -29,7 +34,7 @@ void Ramp(float start_gain, float target_gain, AudioFrame* audio_frame) {
|
| RTC_DCHECK(audio_frame);
|
| RTC_DCHECK_GE(start_gain, 0.0f);
|
| RTC_DCHECK_GE(target_gain, 0.0f);
|
| - if (start_gain == target_gain) {
|
| + if (start_gain == target_gain || audio_frame->muted()) {
|
| return;
|
| }
|
|
|
| @@ -37,11 +42,12 @@ void Ramp(float start_gain, float target_gain, AudioFrame* audio_frame) {
|
| RTC_DCHECK_LT(0, samples);
|
| float increment = (target_gain - start_gain) / samples;
|
| float gain = start_gain;
|
| + int16_t* frame_data = audio_frame->mutable_data();
|
| for (size_t i = 0; i < samples; ++i) {
|
| // If the audio is interleaved of several channels, we want to
|
| // apply the same gain change to the ith sample of every channel.
|
| for (size_t ch = 0; ch < audio_frame->num_channels_; ++ch) {
|
| - audio_frame->data_[audio_frame->num_channels_ * i + ch] *= gain;
|
| + frame_data[audio_frame->num_channels_ * i + ch] *= gain;
|
| }
|
| gain += increment;
|
| }
|
|
|