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..f354c6684a4ea1bd1d02fb8526fd05b32a7e7439 100644 |
--- a/webrtc/modules/audio_mixer/audio_frame_manipulator.cc |
+++ b/webrtc/modules/audio_mixer/audio_frame_manipulator.cc |
@@ -17,10 +17,13 @@ namespace webrtc { |
uint32_t AudioMixerCalculateEnergy(const AudioFrame& audio_frame) { |
uint32_t energy = 0; |
- 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]; |
+ if (!audio_frame.muted()) { |
+ 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 += frame_data[position] * frame_data[position]; |
+ } |
} |
return energy; |
} |
@@ -29,7 +32,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 +40,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; |
} |