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

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

Issue 8989041: Revert 115214 (caused media_unittests failure in FFmpegGlueTest, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « media/base/byte_queue.h ('k') | media/filters/chunk_demuxer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/byte_queue.h" 5 #include "media/base/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 // Default starting size for the queue. 11 // Default starting size for the queue.
12 enum { kDefaultQueueSize = 1024 }; 12 enum { kDefaultQueueSize = 1024 };
13 13
14 ByteQueue::ByteQueue() 14 ByteQueue::ByteQueue()
15 : buffer_(new uint8[kDefaultQueueSize]), 15 : buffer_(new uint8[kDefaultQueueSize]),
16 size_(kDefaultQueueSize), 16 size_(kDefaultQueueSize),
17 offset_(0), 17 offset_(0),
18 used_(0) { 18 used_(0) {
19 } 19 }
20 20
21 ByteQueue::~ByteQueue() {} 21 ByteQueue::~ByteQueue() {}
22 22
23 void ByteQueue::Reset() {
24 offset_ = 0;
25 used_ = 0;
26 }
27
28 void ByteQueue::Push(const uint8* data, int size) { 23 void ByteQueue::Push(const uint8* data, int size) {
29 DCHECK(data); 24 DCHECK(data);
30 DCHECK_GT(size, 0); 25 DCHECK_GT(size, 0);
31 26
32 size_t size_needed = used_ + size; 27 size_t size_needed = used_ + size;
33 28
34 // Check to see if we need a bigger buffer. 29 // Check to see if we need a bigger buffer.
35 if (size_needed > size_) { 30 if (size_needed > size_) {
36 size_t new_size = 2 * size_; 31 size_t new_size = 2 * size_;
37 while (size_needed > new_size && new_size > size_) 32 while (size_needed > new_size && new_size > size_)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 // Move the offset back to 0 if we have reached the end of the buffer. 70 // Move the offset back to 0 if we have reached the end of the buffer.
76 if (offset_ == size_) { 71 if (offset_ == size_) {
77 DCHECK_EQ(used_, 0); 72 DCHECK_EQ(used_, 0);
78 offset_ = 0; 73 offset_ = 0;
79 } 74 }
80 } 75 }
81 76
82 uint8* ByteQueue::front() const { return buffer_.get() + offset_; } 77 uint8* ByteQueue::front() const { return buffer_.get() + offset_; }
83 78
84 } // namespace media 79 } // namespace media
OLDNEW
« no previous file with comments | « media/base/byte_queue.h ('k') | media/filters/chunk_demuxer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698