| 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_discard_helper.h" | 5 #include "media/base/audio_discard_helper.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 64 |
| 65 // If this is the first buffer seen, setup the timestamp helper. | 65 // If this is the first buffer seen, setup the timestamp helper. |
| 66 const bool first_buffer = !initialized(); | 66 const bool first_buffer = !initialized(); |
| 67 if (first_buffer) { | 67 if (first_buffer) { |
| 68 // Clamp the base timestamp to zero. | 68 // Clamp the base timestamp to zero. |
| 69 timestamp_helper_.SetBaseTimestamp( | 69 timestamp_helper_.SetBaseTimestamp( |
| 70 std::max(base::TimeDelta(), encoded_buffer->timestamp())); | 70 std::max(base::TimeDelta(), encoded_buffer->timestamp())); |
| 71 } | 71 } |
| 72 DCHECK(initialized()); | 72 DCHECK(initialized()); |
| 73 | 73 |
| 74 if (!decoded_buffer) { | 74 if (!decoded_buffer.get()) { |
| 75 // If there's a one buffer delay for decoding, we need to save it so it can | 75 // If there's a one buffer delay for decoding, we need to save it so it can |
| 76 // be processed with the next decoder buffer. | 76 // be processed with the next decoder buffer. |
| 77 if (first_buffer) { | 77 if (first_buffer) { |
| 78 delayed_discard_ = true; | 78 delayed_discard_ = true; |
| 79 delayed_discard_padding_ = encoded_buffer->discard_padding(); | 79 delayed_discard_padding_ = encoded_buffer->discard_padding(); |
| 80 } | 80 } |
| 81 return false; | 81 return false; |
| 82 } | 82 } |
| 83 | 83 |
| 84 const size_t original_frame_count = decoded_buffer->frame_count(); | 84 const size_t original_frame_count = decoded_buffer->frame_count(); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 DCHECK(current_discard_padding.second == base::TimeDelta()); | 233 DCHECK(current_discard_padding.second == base::TimeDelta()); |
| 234 } | 234 } |
| 235 | 235 |
| 236 // Assign timestamp to the buffer. | 236 // Assign timestamp to the buffer. |
| 237 decoded_buffer->set_timestamp(timestamp_helper_.GetTimestamp()); | 237 decoded_buffer->set_timestamp(timestamp_helper_.GetTimestamp()); |
| 238 timestamp_helper_.AddFrames(decoded_buffer->frame_count()); | 238 timestamp_helper_.AddFrames(decoded_buffer->frame_count()); |
| 239 return true; | 239 return true; |
| 240 } | 240 } |
| 241 | 241 |
| 242 } // namespace media | 242 } // namespace media |
| OLD | NEW |