diff options
author | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-25 00:45:54 +0000 |
---|---|---|
committer | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-25 00:45:54 +0000 |
commit | 38b48040588028d3e949b077e5f756ff4985e287 (patch) | |
tree | f2c6bb6a7ece9d9ef0879c25d9955a0425089171 /media/omx | |
parent | 246f429937fda025fe76c9332015d7647fb33307 (diff) | |
download | chromium_src-38b48040588028d3e949b077e5f756ff4985e287.zip chromium_src-38b48040588028d3e949b077e5f756ff4985e287.tar.gz chromium_src-38b48040588028d3e949b077e5f756ff4985e287.tar.bz2 |
Minor cleanup to some OpenMAX code.
Renamed Eos() to IsEndOfStream() to be consistent with other buffer implementations.
BUG=n/a
TEST=n/a
Review URL: http://codereview.chromium.org/440007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33019 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/omx')
-rw-r--r-- | media/omx/input_buffer.cc | 13 | ||||
-rw-r--r-- | media/omx/input_buffer.h | 17 | ||||
-rw-r--r-- | media/omx/omx_test.cc | 2 | ||||
-rw-r--r-- | media/omx/omx_video_decoder.cc | 2 |
4 files changed, 20 insertions, 14 deletions
diff --git a/media/omx/input_buffer.cc b/media/omx/input_buffer.cc index 97e2022..c26b9f7 100644 --- a/media/omx/input_buffer.cc +++ b/media/omx/input_buffer.cc @@ -2,16 +2,16 @@ // source code is governed by a BSD-style license that can be found in the // LICENSE file. +#include "media/omx/input_buffer.h" + #include <algorithm> #include "base/logging.h" -#include "media/omx/input_buffer.h" namespace media { InputBuffer::InputBuffer() - : data_(NULL), - size_(0), + : size_(0), used_(0) { } @@ -23,12 +23,11 @@ InputBuffer::InputBuffer(uint8* data, int size) } InputBuffer::~InputBuffer() { - delete [] data_; } int InputBuffer::Read(uint8* output_data, int output_size) { int copy = std::min(output_size, size_ - used_); - memcpy(output_data, data_ + used_, copy); + memcpy(output_data, data_.get() + used_, copy); used_ += copy; return copy; } @@ -37,8 +36,8 @@ bool InputBuffer::Used() { return used_ == size_; } -bool InputBuffer::Eos() { - return data_ == NULL || size_ == 0; +bool InputBuffer::IsEndOfStream() { + return data_.get() == NULL || size_ == 0; } } // namespace media diff --git a/media/omx/input_buffer.h b/media/omx/input_buffer.h index a15d1a1..9c6f442 100644 --- a/media/omx/input_buffer.h +++ b/media/omx/input_buffer.h @@ -7,10 +7,15 @@ // // This object is implemened using system memory. +#ifndef MEDIA_OMX_INPUT_BUFFER_H_ +#define MEDIA_OMX_INPUT_BUFFER_H_ + #include "base/basictypes.h" +#include "base/scoped_ptr.h" namespace media { +// TODO(hclam): consolidate our buffer implementations http://crbug.com/28654 class InputBuffer { public: // Creates an empty input buffer. @@ -20,24 +25,26 @@ class InputBuffer { // After construction, this object will be given the ownership of // |data| and is responsible for deleting it. InputBuffer(uint8* data, int size); - virtual ~InputBuffer(); + ~InputBuffer(); // Read from the this buffer into |data| with the maximum |size| bytes. // Returns number of bytes read. If a read is successful, the number // of used bytes will advances accordingly. // Returns a negative number on error. - virtual int Read(uint8* data, int size); + int Read(uint8* data, int size); // Returns true if this buffer is used. - virtual bool Used(); + bool Used(); // Returns true if this is an end-of-stream buffer. - virtual bool Eos(); + bool IsEndOfStream(); private: - uint8* data_; + scoped_array<uint8> data_; int size_; int used_; }; } // namespace media + +#endif // MEDIA_OMX_INPUT_BUFFER_H_ diff --git a/media/omx/omx_test.cc b/media/omx/omx_test.cc index bb4ffd2..54ff63c 100644 --- a/media/omx/omx_test.cc +++ b/media/omx/omx_test.cc @@ -57,7 +57,7 @@ class TestApp { // There are some conditions we don't want to enqueue, for example when // the last buffer is an end-of-stream buffer, when we have stopped, and // when we have received an error. - bool eos = buffer->Eos(); + bool eos = buffer->IsEndOfStream(); delete buffer; if (!eos && !stopped_ && !error_) FeedDecoder(); diff --git a/media/omx/omx_video_decoder.cc b/media/omx/omx_video_decoder.cc index cdf0d5d..7506511 100644 --- a/media/omx/omx_video_decoder.cc +++ b/media/omx/omx_video_decoder.cc @@ -899,7 +899,7 @@ void OmxVideoDecoder::EmptyBufferTask() { available_input_buffers_.pop(); // Read into |omx_buffer|. - input_eos_ = buffer->Eos(); + input_eos_ = buffer->IsEndOfStream(); int filled = buffer->Read(omx_buffer->pBuffer, input_buffer_size_); if (buffer->Used()) { input_queue_.pop(); |