Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: media/base/seekable_buffer.cc

Issue 10342005: media::SeekableBuffer should use kNoTimestamp() instead of zero. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/seekable_buffer.h" 5 #include "media/base/seekable_buffer.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/data_buffer.h" 10 #include "media/base/data_buffer.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 current_buffer_offset = 0; 54 current_buffer_offset = 0;
55 } 55 }
56 if (current_buffer == buffers_.end()) 56 if (current_buffer == buffers_.end())
57 return false; 57 return false;
58 *data = (*current_buffer)->GetData() + current_buffer_offset; 58 *data = (*current_buffer)->GetData() + current_buffer_offset;
59 *size = (*current_buffer)->GetDataSize() - current_buffer_offset; 59 *size = (*current_buffer)->GetDataSize() - current_buffer_offset;
60 return true; 60 return true;
61 } 61 }
62 62
63 bool SeekableBuffer::Append(Buffer* buffer_in) { 63 bool SeekableBuffer::Append(Buffer* buffer_in) {
64 if (buffers_.empty() && buffer_in->GetTimestamp().InMicroseconds() > 0) { 64 if (buffers_.empty() && buffer_in->GetTimestamp() != kNoTimestamp()) {
65 current_time_ = buffer_in->GetTimestamp(); 65 current_time_ = buffer_in->GetTimestamp();
66 } 66 }
67 67
68 // Since the forward capacity is only used to check the criteria for buffer 68 // Since the forward capacity is only used to check the criteria for buffer
69 // full, we always append data to the buffer. 69 // full, we always append data to the buffer.
70 buffers_.push_back(scoped_refptr<Buffer>(buffer_in)); 70 buffers_.push_back(scoped_refptr<Buffer>(buffer_in));
71 71
72 // After we have written the first buffer, update |current_buffer_| to point 72 // After we have written the first buffer, update |current_buffer_| to point
73 // to it. 73 // to it.
74 if (current_buffer_ == buffers_.end()) { 74 if (current_buffer_ == buffers_.end()) {
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 UpdateCurrentTime(current_buffer_, current_buffer_offset_); 260 UpdateCurrentTime(current_buffer_, current_buffer_offset_);
261 EvictBackwardBuffers(); 261 EvictBackwardBuffers();
262 } 262 }
263 263
264 return taken; 264 return taken;
265 } 265 }
266 266
267 void SeekableBuffer::UpdateCurrentTime(BufferQueue::iterator buffer, 267 void SeekableBuffer::UpdateCurrentTime(BufferQueue::iterator buffer,
268 int offset) { 268 int offset) {
269 // Garbage values are unavoidable, so this check will remain. 269 // Garbage values are unavoidable, so this check will remain.
270 if (buffer != buffers_.end() && 270 if (buffer != buffers_.end() && (*buffer)->GetTimestamp() != kNoTimestamp()) {
271 (*buffer)->GetTimestamp().InMicroseconds() > 0) {
272 int64 time_offset = ((*buffer)->GetDuration().InMicroseconds() * 271 int64 time_offset = ((*buffer)->GetDuration().InMicroseconds() *
273 offset) / (*buffer)->GetDataSize(); 272 offset) / (*buffer)->GetDataSize();
274 273
275 current_time_ = (*buffer)->GetTimestamp() + 274 current_time_ = (*buffer)->GetTimestamp() +
276 base::TimeDelta::FromMicroseconds(time_offset); 275 base::TimeDelta::FromMicroseconds(time_offset);
277 } 276 }
278 } 277 }
279 278
280 } // namespace media 279 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/base/seekable_buffer_unittest.cc » ('j') | media/base/seekable_buffer_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698