| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 buffered_input_frames_ = 0.0; | 84 buffered_input_frames_ = 0.0; |
| 85 last_input_buffer_offset_ = 0; | 85 last_input_buffer_offset_ = 0; |
| 86 } | 86 } |
| 87 | 87 |
| 88 void AudioBufferConverter::ResetTimestampState() { | 88 void AudioBufferConverter::ResetTimestampState() { |
| 89 Flush(); | 89 Flush(); |
| 90 timestamp_helper_.SetBaseTimestamp(kNoTimestamp()); | 90 timestamp_helper_.SetBaseTimestamp(kNoTimestamp()); |
| 91 } | 91 } |
| 92 | 92 |
| 93 double AudioBufferConverter::ProvideInput(AudioBus* audio_bus, | 93 double AudioBufferConverter::ProvideInput(AudioBus* audio_bus, |
| 94 base::TimeDelta buffer_delay) { | 94 uint32_t frames_delayed) { |
| 95 DCHECK(is_flushing_ || input_frames_ >= audio_bus->frames()); | 95 DCHECK(is_flushing_ || input_frames_ >= audio_bus->frames()); |
| 96 | 96 |
| 97 int requested_frames_left = audio_bus->frames(); | 97 int requested_frames_left = audio_bus->frames(); |
| 98 int dest_index = 0; | 98 int dest_index = 0; |
| 99 | 99 |
| 100 while (requested_frames_left > 0 && !queued_inputs_.empty()) { | 100 while (requested_frames_left > 0 && !queued_inputs_.empty()) { |
| 101 scoped_refptr<AudioBuffer> input_buffer = queued_inputs_.front(); | 101 scoped_refptr<AudioBuffer> input_buffer = queued_inputs_.front(); |
| 102 | 102 |
| 103 int frames_to_read = | 103 int frames_to_read = |
| 104 std::min(requested_frames_left, | 104 std::min(requested_frames_left, |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 is_flushing_ = false; | 240 is_flushing_ = false; |
| 241 audio_converter_->Reset(); | 241 audio_converter_->Reset(); |
| 242 DCHECK_EQ(input_frames_, 0); | 242 DCHECK_EQ(input_frames_, 0); |
| 243 DCHECK_EQ(last_input_buffer_offset_, 0); | 243 DCHECK_EQ(last_input_buffer_offset_, 0); |
| 244 DCHECK_LT(buffered_input_frames_, 1.0); | 244 DCHECK_LT(buffered_input_frames_, 1.0); |
| 245 DCHECK(queued_inputs_.empty()); | 245 DCHECK(queued_inputs_.empty()); |
| 246 buffered_input_frames_ = 0.0; | 246 buffered_input_frames_ = 0.0; |
| 247 } | 247 } |
| 248 | 248 |
| 249 } // namespace media | 249 } // namespace media |
| OLD | NEW |