Chromium Code Reviews| Index: media/audio/audio_output_resampler.cc |
| diff --git a/media/audio/audio_output_resampler.cc b/media/audio/audio_output_resampler.cc |
| index 34343d75337c6598126a3696f252690a9bdfdefb..75e9621d05a4a3d4e7f38d2b91aabadb94084e89 100644 |
| --- a/media/audio/audio_output_resampler.cc |
| +++ b/media/audio/audio_output_resampler.cc |
| @@ -103,14 +103,29 @@ AudioOutputResampler::~AudioOutputResampler() {} |
| void AudioOutputResampler::Initialize() { |
| io_ratio_ = 1; |
| + if (params_.frames_per_buffer() != output_params_.frames_per_buffer()) { |
|
DaleCurtis
2012/09/17 23:54:45
I don't understand what you're trying to do here.
no longer working on chromium
2012/09/18 09:37:30
The idea is simple. Basically, we should allow the
|
| + double in_buffer_s = static_cast<double>(params_.frames_per_buffer()) / |
| + static_cast<double>(params_.sample_rate()); |
| + double out_buffer_s = |
| + static_cast<double>(output_params_.frames_per_buffer()) / |
| + static_cast<double>(output_params_.sample_rate()); |
| + if (in_buffer_s != out_buffer_s) { |
| + int out_buffer_size = in_buffer_s * output_params_.sample_rate(); |
|
no longer working on chromium
2012/09/17 21:56:28
I will add + 0.5 to do the correct truncation here
|
| + output_params_.Reset(output_params_.format(), |
| + output_params_.channel_layout(), |
| + output_params_.sample_rate(), |
| + output_params_.bits_per_sample(), |
| + out_buffer_size); |
| + } |
| + } |
| + |
| // TODO(dalecurtis): Add channel remixing. http://crbug.com/138762 |
| DCHECK_EQ(params_.channels(), output_params_.channels()); |
| // Only resample or rebuffer if the input parameters don't match the output |
| // parameters to avoid any unnecessary work. |
| if (params_.channels() != output_params_.channels() || |
| params_.sample_rate() != output_params_.sample_rate() || |
| - params_.bits_per_sample() != output_params_.bits_per_sample() || |
| - params_.frames_per_buffer() != output_params_.frames_per_buffer()) { |
| + params_.bits_per_sample() != output_params_.bits_per_sample()) { |
| // Only resample if necessary since it's expensive. |
| if (params_.sample_rate() != output_params_.sample_rate()) { |
| DVLOG(1) << "Resampling from " << params_.sample_rate() << " to " |
| @@ -135,8 +150,7 @@ void AudioOutputResampler::Initialize() { |
| // Since the resampler / output device may want a different buffer size than |
| // the caller asked for, we need to use a FIFO to ensure that both sides |
| // read in chunk sizes they're configured for. |
| - if (params_.sample_rate() != output_params_.sample_rate() || |
| - params_.frames_per_buffer() != output_params_.frames_per_buffer()) { |
| + if (params_.sample_rate() != output_params_.sample_rate()) { |
| DVLOG(1) << "Rebuffering from " << params_.frames_per_buffer() |
| << " to " << output_params_.frames_per_buffer(); |
| audio_fifo_.reset(new AudioPullFifo( |