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

Side by Side Diff: media/formats/common/offset_byte_queue.cc

Issue 1534273002: Switch to standard integer types in media/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more Created 5 years 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
OLDNEW
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/formats/common/offset_byte_queue.h" 5 #include "media/formats/common/offset_byte_queue.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace media { 9 namespace media {
10 10
11 OffsetByteQueue::OffsetByteQueue() : buf_(NULL), size_(0), head_(0) {} 11 OffsetByteQueue::OffsetByteQueue() : buf_(NULL), size_(0), head_(0) {}
12 OffsetByteQueue::~OffsetByteQueue() {} 12 OffsetByteQueue::~OffsetByteQueue() {}
13 13
14 void OffsetByteQueue::Reset() { 14 void OffsetByteQueue::Reset() {
15 queue_.Reset(); 15 queue_.Reset();
16 buf_ = NULL; 16 buf_ = NULL;
17 size_ = 0; 17 size_ = 0;
18 head_ = 0; 18 head_ = 0;
19 } 19 }
20 20
21 void OffsetByteQueue::Push(const uint8* buf, int size) { 21 void OffsetByteQueue::Push(const uint8_t* buf, int size) {
22 queue_.Push(buf, size); 22 queue_.Push(buf, size);
23 Sync(); 23 Sync();
24 DVLOG(4) << "Buffer pushed. head=" << head() << " tail=" << tail(); 24 DVLOG(4) << "Buffer pushed. head=" << head() << " tail=" << tail();
25 } 25 }
26 26
27 void OffsetByteQueue::Peek(const uint8** buf, int* size) { 27 void OffsetByteQueue::Peek(const uint8_t** buf, int* size) {
28 *buf = size_ > 0 ? buf_ : NULL; 28 *buf = size_ > 0 ? buf_ : NULL;
29 *size = size_; 29 *size = size_;
30 } 30 }
31 31
32 void OffsetByteQueue::Pop(int count) { 32 void OffsetByteQueue::Pop(int count) {
33 queue_.Pop(count); 33 queue_.Pop(count);
34 head_ += count; 34 head_ += count;
35 Sync(); 35 Sync();
36 } 36 }
37 37
38 void OffsetByteQueue::PeekAt(int64 offset, const uint8** buf, int* size) { 38 void OffsetByteQueue::PeekAt(int64_t offset, const uint8_t** buf, int* size) {
39 DCHECK(offset >= head()); 39 DCHECK(offset >= head());
40 if (offset < head() || offset >= tail()) { 40 if (offset < head() || offset >= tail()) {
41 *buf = NULL; 41 *buf = NULL;
42 *size = 0; 42 *size = 0;
43 return; 43 return;
44 } 44 }
45 *buf = &buf_[offset - head()]; 45 *buf = &buf_[offset - head()];
46 *size = tail() - offset; 46 *size = tail() - offset;
47 } 47 }
48 48
49 bool OffsetByteQueue::Trim(int64 max_offset) { 49 bool OffsetByteQueue::Trim(int64_t max_offset) {
50 if (max_offset < head_) return true; 50 if (max_offset < head_) return true;
51 if (max_offset > tail()) { 51 if (max_offset > tail()) {
52 Pop(size_); 52 Pop(size_);
53 return false; 53 return false;
54 } 54 }
55 Pop(max_offset - head_); 55 Pop(max_offset - head_);
56 return true; 56 return true;
57 } 57 }
58 58
59 void OffsetByteQueue::Sync() { 59 void OffsetByteQueue::Sync() {
60 queue_.Peek(&buf_, &size_); 60 queue_.Peek(&buf_, &size_);
61 } 61 }
62 62
63 } // namespace media 63 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698