| 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 #include "media/base/audio_converter.h" | 5 #include "media/base/audio_converter.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 input_channel_count_(input_params.channels()) { | 23 input_channel_count_(input_params.channels()) { |
| 24 CHECK(input_params.IsValid()); | 24 CHECK(input_params.IsValid()); |
| 25 CHECK(output_params.IsValid()); | 25 CHECK(output_params.IsValid()); |
| 26 | 26 |
| 27 // Handle different input and output channel layouts. | 27 // Handle different input and output channel layouts. |
| 28 if (input_params.channel_layout() != output_params.channel_layout()) { | 28 if (input_params.channel_layout() != output_params.channel_layout()) { |
| 29 DVLOG(1) << "Remixing channel layout from " << input_params.channel_layout() | 29 DVLOG(1) << "Remixing channel layout from " << input_params.channel_layout() |
| 30 << " to " << output_params.channel_layout() << "; from " | 30 << " to " << output_params.channel_layout() << "; from " |
| 31 << input_params.channels() << " channels to " | 31 << input_params.channels() << " channels to " |
| 32 << output_params.channels() << " channels."; | 32 << output_params.channels() << " channels."; |
| 33 channel_mixer_.reset(new ChannelMixer( | 33 channel_mixer_.reset(new ChannelMixer(input_params, output_params)); |
| 34 input_params.channel_layout(), output_params.channel_layout())); | |
| 35 | 34 |
| 36 // Pare off data as early as we can for efficiency. | 35 // Pare off data as early as we can for efficiency. |
| 37 downmix_early_ = input_params.channels() > output_params.channels(); | 36 downmix_early_ = input_params.channels() > output_params.channels(); |
| 38 if (downmix_early_) { | 37 if (downmix_early_) { |
| 39 DVLOG(1) << "Remixing channel layout prior to resampling."; | 38 DVLOG(1) << "Remixing channel layout prior to resampling."; |
| 40 // |unmixed_audio_| will be allocated on the fly. | 39 // |unmixed_audio_| will be allocated on the fly. |
| 41 } else { | 40 } else { |
| 42 // Instead, if we're not downmixing early we need a temporary AudioBus | 41 // Instead, if we're not downmixing early we need a temporary AudioBus |
| 43 // which matches the input channel count but uses the output frame size | 42 // which matches the input channel count but uses the output frame size |
| 44 // since we'll mix into the AudioBus from the output stream. | 43 // since we'll mix into the AudioBus from the output stream. |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 | 203 |
| 205 void AudioConverter::ProvideInput(int resampler_frame_delay, AudioBus* dest) { | 204 void AudioConverter::ProvideInput(int resampler_frame_delay, AudioBus* dest) { |
| 206 resampler_frame_delay_ = resampler_frame_delay; | 205 resampler_frame_delay_ = resampler_frame_delay; |
| 207 if (audio_fifo_) | 206 if (audio_fifo_) |
| 208 audio_fifo_->Consume(dest, dest->frames()); | 207 audio_fifo_->Consume(dest, dest->frames()); |
| 209 else | 208 else |
| 210 SourceCallback(0, dest); | 209 SourceCallback(0, dest); |
| 211 } | 210 } |
| 212 | 211 |
| 213 } // namespace media | 212 } // namespace media |
| OLD | NEW |