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, | |
146 buffer->sample_rate(), | 145 buffer->sample_rate(), |
147 input_params_.bits_per_sample(), | 146 input_params_.bits_per_sample(), |
148 // If resampling is needed and the FIFO disabled, the AudioConverter will | 147 // If resampling is needed and the FIFO disabled, the AudioConverter will |
149 // always request SincResampler::kDefaultRequestSize frames. Otherwise it | 148 // always request SincResampler::kDefaultRequestSize frames. Otherwise it |
150 // will use the output frame size. | 149 // will use the output frame size. |
151 buffer->sample_rate() == output_params_.sample_rate() | 150 buffer->sample_rate() == output_params_.sample_rate() |
152 ? output_params_.frames_per_buffer() | 151 ? output_params_.frames_per_buffer() |
153 : SincResampler::kDefaultRequestSize); | 152 : SincResampler::kDefaultRequestSize); |
154 | 153 |
155 io_sample_rate_ratio_ = static_cast<double>(input_params_.sample_rate()) / | 154 io_sample_rate_ratio_ = static_cast<double>(input_params_.sample_rate()) / |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 is_flushing_ = false; | 239 is_flushing_ = false; |
241 audio_converter_->Reset(); | 240 audio_converter_->Reset(); |
242 DCHECK_EQ(input_frames_, 0); | 241 DCHECK_EQ(input_frames_, 0); |
243 DCHECK_EQ(last_input_buffer_offset_, 0); | 242 DCHECK_EQ(last_input_buffer_offset_, 0); |
244 DCHECK_LT(buffered_input_frames_, 1.0); | 243 DCHECK_LT(buffered_input_frames_, 1.0); |
245 DCHECK(queued_inputs_.empty()); | 244 DCHECK(queued_inputs_.empty()); |
246 buffered_input_frames_ = 0.0; | 245 buffered_input_frames_ = 0.0; |
247 } | 246 } |
248 | 247 |
249 } // namespace media | 248 } // namespace media |
OLD | NEW |