| 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 } | 220 } |
| 221 | 221 |
| 222 // Do the actual conversion. | 222 // Do the actual conversion. |
| 223 audio_converter_->Convert(output_bus.get()); | 223 audio_converter_->Convert(output_bus.get()); |
| 224 frames_remaining -= frames_this_iteration; | 224 frames_remaining -= frames_this_iteration; |
| 225 buffered_input_frames_ -= frames_this_iteration * io_sample_rate_ratio_; | 225 buffered_input_frames_ -= frames_this_iteration * io_sample_rate_ratio_; |
| 226 } | 226 } |
| 227 | 227 |
| 228 // Compute the timestamp. | 228 // Compute the timestamp. |
| 229 output_buffer->set_timestamp(timestamp_helper_.GetTimestamp()); | 229 output_buffer->set_timestamp(timestamp_helper_.GetTimestamp()); |
| 230 output_buffer->set_duration( |
| 231 timestamp_helper_.GetFrameDuration(request_frames)); |
| 230 timestamp_helper_.AddFrames(request_frames); | 232 timestamp_helper_.AddFrames(request_frames); |
| 231 | 233 |
| 232 queued_outputs_.push_back(output_buffer); | 234 queued_outputs_.push_back(output_buffer); |
| 233 } | 235 } |
| 234 | 236 |
| 235 void AudioBufferConverter::Flush() { | 237 void AudioBufferConverter::Flush() { |
| 236 if (!audio_converter_) | 238 if (!audio_converter_) |
| 237 return; | 239 return; |
| 238 is_flushing_ = true; | 240 is_flushing_ = true; |
| 239 ConvertIfPossible(); | 241 ConvertIfPossible(); |
| 240 is_flushing_ = false; | 242 is_flushing_ = false; |
| 241 audio_converter_->Reset(); | 243 audio_converter_->Reset(); |
| 242 DCHECK_EQ(input_frames_, 0); | 244 DCHECK_EQ(input_frames_, 0); |
| 243 DCHECK_EQ(last_input_buffer_offset_, 0); | 245 DCHECK_EQ(last_input_buffer_offset_, 0); |
| 244 DCHECK_LT(buffered_input_frames_, 1.0); | 246 DCHECK_LT(buffered_input_frames_, 1.0); |
| 245 DCHECK(queued_inputs_.empty()); | 247 DCHECK(queued_inputs_.empty()); |
| 246 buffered_input_frames_ = 0.0; | 248 buffered_input_frames_ = 0.0; |
| 247 } | 249 } |
| 248 | 250 |
| 249 } // namespace media | 251 } // namespace media |
| OLD | NEW |