Chromium Code Reviews| Index: media/base/multi_channel_resampler.cc |
| diff --git a/media/base/multi_channel_resampler.cc b/media/base/multi_channel_resampler.cc |
| index b8df97d66c39d391e0e0187c7ac04d4da3e07501..f568bda8bbb4ce03354f70da5ebd208a63b32aaf 100644 |
| --- a/media/base/multi_channel_resampler.cc |
| +++ b/media/base/multi_channel_resampler.cc |
| @@ -15,7 +15,8 @@ MultiChannelResampler::MultiChannelResampler(int channels, |
| double io_sample_rate_ratio, |
| const ReadCB& read_cb) |
| : last_frame_count_(0), |
| - read_cb_(read_cb) { |
| + read_cb_(read_cb), |
| + output_frames_ready_(0) { |
| // Allocate each channel's resampler. |
| resamplers_.reserve(channels); |
| for (int i = 0; i < channels; ++i) { |
| @@ -33,10 +34,10 @@ void MultiChannelResampler::Resample(AudioBus* audio_bus, int frames) { |
| // channel. To ensure this, we chunk the number of requested frames into |
| // SincResampler::ChunkSize() sized chunks. SincResampler guarantees it will |
| // only call ProvideInput() once when we resample this way. |
| - int frames_done = 0; |
| + output_frames_ready_ = 0; |
|
Chris Rogers
2012/11/14 23:50:49
As we discussed, I think we need much better comme
|
| int chunk_size = resamplers_[0]->ChunkSize(); |
| - while (frames_done < frames) { |
| - int frames_this_time = std::min(frames - frames_done, chunk_size); |
| + while (output_frames_ready_ < frames) { |
| + int frames_this_time = std::min(frames - output_frames_ready_, chunk_size); |
| // Resample each channel. |
| for (size_t i = 0; i < resamplers_.size(); ++i) { |
| @@ -49,10 +50,10 @@ void MultiChannelResampler::Resample(AudioBus* audio_bus, int frames) { |
| // since they all buffer in the same way and are processing the same |
| // number of frames. |
| resamplers_[i]->Resample( |
| - audio_bus->channel(i) + frames_done, frames_this_time); |
| + audio_bus->channel(i) + output_frames_ready_, frames_this_time); |
| } |
| - frames_done += frames_this_time; |
| + output_frames_ready_ += frames_this_time; |
|
Chris Rogers
2012/11/14 23:50:49
I don't understand how at the end of this loop tha
DaleCurtis
2012/11/15 00:30:59
Queried upstream only in the middle of this loop.
|
| } |
| } |