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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 return 1.0; | 134 return 1.0; |
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(), | |
145 buffer->sample_rate(), | 144 buffer->sample_rate(), |
146 input_params_.bits_per_sample(), | 145 input_params_.bits_per_sample(), |
147 // If resampling is needed and the FIFO disabled, the AudioConverter will | 146 // If resampling is needed and the FIFO disabled, the AudioConverter will |
148 // always request SincResampler::kDefaultRequestSize frames. Otherwise it | 147 // always request SincResampler::kDefaultRequestSize frames. Otherwise it |
149 // will use the output frame size. | 148 // will use the output frame size. |
150 buffer->sample_rate() == output_params_.sample_rate() | 149 buffer->sample_rate() == output_params_.sample_rate() |
151 ? output_params_.frames_per_buffer() | 150 ? output_params_.frames_per_buffer() |
152 : SincResampler::kDefaultRequestSize); | 151 : SincResampler::kDefaultRequestSize); |
| 152 input_params_.set_channels_for_discrete(buffer->channel_count()); |
153 | 153 |
154 io_sample_rate_ratio_ = static_cast<double>(input_params_.sample_rate()) / | 154 io_sample_rate_ratio_ = static_cast<double>(input_params_.sample_rate()) / |
155 output_params_.sample_rate(); | 155 output_params_.sample_rate(); |
156 | 156 |
157 // If |buffer| matches |output_params_| we don't need an AudioConverter at | 157 // If |buffer| matches |output_params_| we don't need an AudioConverter at |
158 // all, and can early-out here. | 158 // all, and can early-out here. |
159 if (!IsConfigChange(output_params_, buffer)) | 159 if (!IsConfigChange(output_params_, buffer)) |
160 return; | 160 return; |
161 | 161 |
162 // Note: The FIFO is disabled to avoid extraneous memcpy(). | 162 // Note: The FIFO is disabled to avoid extraneous memcpy(). |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 is_flushing_ = false; | 239 is_flushing_ = false; |
240 audio_converter_->Reset(); | 240 audio_converter_->Reset(); |
241 DCHECK_EQ(input_frames_, 0); | 241 DCHECK_EQ(input_frames_, 0); |
242 DCHECK_EQ(last_input_buffer_offset_, 0); | 242 DCHECK_EQ(last_input_buffer_offset_, 0); |
243 DCHECK_LT(buffered_input_frames_, 1.0); | 243 DCHECK_LT(buffered_input_frames_, 1.0); |
244 DCHECK(queued_inputs_.empty()); | 244 DCHECK(queued_inputs_.empty()); |
245 buffered_input_frames_ = 0.0; | 245 buffered_input_frames_ = 0.0; |
246 } | 246 } |
247 | 247 |
248 } // namespace media | 248 } // namespace media |
OLD | NEW |