OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // AudioConverter implementation. Uses MultiChannelSincResampler for resampling | 5 // AudioConverter implementation. Uses MultiChannelSincResampler for resampling |
6 // audio, ChannelMixer for channel mixing, and AudioPullFifo for buffering. | 6 // audio, ChannelMixer for channel mixing, and AudioPullFifo for buffering. |
7 // | 7 // |
8 // Delay estimates are provided to InputCallbacks based on the frame delay | 8 // Delay estimates are provided to InputCallbacks based on the frame delay |
9 // information reported via the resampler and FIFO units. | 9 // information reported via the resampler and FIFO units. |
10 | 10 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 if (audio_fifo_) { | 190 if (audio_fifo_) { |
191 buffer_delay += base::TimeDelta::FromMicroseconds( | 191 buffer_delay += base::TimeDelta::FromMicroseconds( |
192 fifo_frame_delay * input_frame_duration_.InMicroseconds()); | 192 fifo_frame_delay * input_frame_duration_.InMicroseconds()); |
193 } | 193 } |
194 | 194 |
195 // If we only have a single input, avoid an extra copy. | 195 // If we only have a single input, avoid an extra copy. |
196 AudioBus* const provide_input_dest = | 196 AudioBus* const provide_input_dest = |
197 transform_inputs_.size() == 1 ? temp_dest : mixer_input_audio_bus_.get(); | 197 transform_inputs_.size() == 1 ? temp_dest : mixer_input_audio_bus_.get(); |
198 | 198 |
199 // Have each mixer render its data into an output buffer then mix the result. | 199 // Have each mixer render its data into an output buffer then mix the result. |
200 for (InputCallbackSet::iterator it = transform_inputs_.begin(); | 200 for (auto* input : transform_inputs_) { |
201 it != transform_inputs_.end(); ++it) { | |
202 InputCallback* input = *it; | |
203 | |
204 const float volume = input->ProvideInput(provide_input_dest, buffer_delay); | 201 const float volume = input->ProvideInput(provide_input_dest, buffer_delay); |
205 | 202 |
206 // Optimize the most common single input, full volume case. | 203 // Optimize the most common single input, full volume case. |
207 if (it == transform_inputs_.begin()) { | 204 if (input == transform_inputs_.front()) { |
208 if (volume == 1.0f) { | 205 if (volume == 1.0f) { |
209 if (temp_dest != provide_input_dest) | 206 if (temp_dest != provide_input_dest) |
210 provide_input_dest->CopyTo(temp_dest); | 207 provide_input_dest->CopyTo(temp_dest); |
211 } else if (volume > 0) { | 208 } else if (volume > 0) { |
212 for (int i = 0; i < provide_input_dest->channels(); ++i) { | 209 for (int i = 0; i < provide_input_dest->channels(); ++i) { |
213 vector_math::FMUL( | 210 vector_math::FMUL( |
214 provide_input_dest->channel(i), volume, | 211 provide_input_dest->channel(i), volume, |
215 provide_input_dest->frames(), temp_dest->channel(i)); | 212 provide_input_dest->frames(), temp_dest->channel(i)); |
216 } | 213 } |
217 } else { | 214 } else { |
(...skipping 27 matching lines...) Expand all Loading... |
245 else | 242 else |
246 SourceCallback(0, dest); | 243 SourceCallback(0, dest); |
247 } | 244 } |
248 | 245 |
249 void AudioConverter::CreateUnmixedAudioIfNecessary(int frames) { | 246 void AudioConverter::CreateUnmixedAudioIfNecessary(int frames) { |
250 if (!unmixed_audio_ || unmixed_audio_->frames() != frames) | 247 if (!unmixed_audio_ || unmixed_audio_->frames() != frames) |
251 unmixed_audio_ = AudioBus::Create(input_channel_count_, frames); | 248 unmixed_audio_ = AudioBus::Create(input_channel_count_, frames); |
252 } | 249 } |
253 | 250 |
254 } // namespace media | 251 } // namespace media |
OLD | NEW |