Chromium Code Reviews| 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/multi_channel_resampler.h" | 5 #include "media/base/multi_channel_resampler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "media/base/audio_bus.h" | 10 #include "media/base/audio_bus.h" |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 resampler_audio_bus_ = AudioBus::Create(channels - 1, request_size); | 35 resampler_audio_bus_ = AudioBus::Create(channels - 1, request_size); |
| 36 for (int i = 0; i < resampler_audio_bus_->channels(); ++i) { | 36 for (int i = 0; i < resampler_audio_bus_->channels(); ++i) { |
| 37 wrapped_resampler_audio_bus_->SetChannelData( | 37 wrapped_resampler_audio_bus_->SetChannelData( |
| 38 i + 1, resampler_audio_bus_->channel(i)); | 38 i + 1, resampler_audio_bus_->channel(i)); |
| 39 } | 39 } |
| 40 } | 40 } |
| 41 } | 41 } |
| 42 | 42 |
| 43 MultiChannelResampler::~MultiChannelResampler() {} | 43 MultiChannelResampler::~MultiChannelResampler() {} |
| 44 | 44 |
| 45 void MultiChannelResampler::PrimeWithSilence() { | |
| 46 DCHECK(!resamplers_.empty()); | |
| 47 for (size_t i = 0; i < resamplers_.size(); ++i) { | |
|
DaleCurtis
2015/07/07 16:38:17
No {} for single line please.
henrika (OOO until Aug 14)
2015/07/08 12:22:59
Done.
| |
| 48 resamplers_[i]->PrimeWithSilence(); | |
| 49 } | |
| 50 } | |
| 51 | |
| 45 void MultiChannelResampler::Resample(int frames, AudioBus* audio_bus) { | 52 void MultiChannelResampler::Resample(int frames, AudioBus* audio_bus) { |
| 46 DCHECK_EQ(static_cast<size_t>(audio_bus->channels()), resamplers_.size()); | 53 DCHECK_EQ(static_cast<size_t>(audio_bus->channels()), resamplers_.size()); |
| 47 | 54 |
| 48 // Optimize the single channel case to avoid the chunking process below. | 55 // Optimize the single channel case to avoid the chunking process below. |
| 49 if (audio_bus->channels() == 1) { | 56 if (audio_bus->channels() == 1) { |
| 50 resamplers_[0]->Resample(frames, audio_bus->channel(0)); | 57 resamplers_[0]->Resample(frames, audio_bus->channel(0)); |
| 51 return; | 58 return; |
| 52 } | 59 } |
| 53 | 60 |
| 54 // We need to ensure that SincResampler only calls ProvideInput once for each | 61 // We need to ensure that SincResampler only calls ProvideInput once for each |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 } | 121 } |
| 115 | 122 |
| 116 | 123 |
| 117 double MultiChannelResampler::BufferedFrames() const { | 124 double MultiChannelResampler::BufferedFrames() const { |
| 118 DCHECK(!resamplers_.empty()); | 125 DCHECK(!resamplers_.empty()); |
| 119 return resamplers_[0]->BufferedFrames(); | 126 return resamplers_[0]->BufferedFrames(); |
| 120 } | 127 } |
| 121 | 128 |
| 122 | 129 |
| 123 } // namespace media | 130 } // namespace media |
| OLD | NEW |