| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_buffer_converter.h" | 5 #include "media/base/audio_buffer_converter.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "media/base/audio_buffer.h" | 10 #include "media/base/audio_buffer.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 } | 135 } |
| 136 | 136 |
| 137 void AudioBufferConverter::ResetConverter( | 137 void AudioBufferConverter::ResetConverter( |
| 138 const scoped_refptr<AudioBuffer>& buffer) { | 138 const scoped_refptr<AudioBuffer>& buffer) { |
| 139 Flush(); | 139 Flush(); |
| 140 audio_converter_.reset(); | 140 audio_converter_.reset(); |
| 141 input_params_.Reset( | 141 input_params_.Reset( |
| 142 input_params_.format(), | 142 input_params_.format(), |
| 143 buffer->channel_layout(), | 143 buffer->channel_layout(), |
| 144 buffer->channel_count(), | 144 buffer->channel_count(), |
| 145 0, |
| 145 buffer->sample_rate(), | 146 buffer->sample_rate(), |
| 146 input_params_.bits_per_sample(), | 147 input_params_.bits_per_sample(), |
| 147 // If resampling is needed and the FIFO disabled, the AudioConverter will | 148 // If resampling is needed and the FIFO disabled, the AudioConverter will |
| 148 // always request SincResampler::kDefaultRequestSize frames. Otherwise it | 149 // always request SincResampler::kDefaultRequestSize frames. Otherwise it |
| 149 // will use the output frame size. | 150 // will use the output frame size. |
| 150 buffer->sample_rate() == output_params_.sample_rate() | 151 buffer->sample_rate() == output_params_.sample_rate() |
| 151 ? output_params_.frames_per_buffer() | 152 ? output_params_.frames_per_buffer() |
| 152 : SincResampler::kDefaultRequestSize); | 153 : SincResampler::kDefaultRequestSize); |
| 153 | 154 |
| 154 io_sample_rate_ratio_ = static_cast<double>(input_params_.sample_rate()) / | 155 io_sample_rate_ratio_ = static_cast<double>(input_params_.sample_rate()) / |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 is_flushing_ = false; | 240 is_flushing_ = false; |
| 240 audio_converter_->Reset(); | 241 audio_converter_->Reset(); |
| 241 DCHECK_EQ(input_frames_, 0); | 242 DCHECK_EQ(input_frames_, 0); |
| 242 DCHECK_EQ(last_input_buffer_offset_, 0); | 243 DCHECK_EQ(last_input_buffer_offset_, 0); |
| 243 DCHECK_LT(buffered_input_frames_, 1.0); | 244 DCHECK_LT(buffered_input_frames_, 1.0); |
| 244 DCHECK(queued_inputs_.empty()); | 245 DCHECK(queued_inputs_.empty()); |
| 245 buffered_input_frames_ = 0.0; | 246 buffered_input_frames_ = 0.0; |
| 246 } | 247 } |
| 247 | 248 |
| 248 } // namespace media | 249 } // namespace media |
| OLD | NEW |