diff options
author | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-09 20:54:03 +0000 |
---|---|---|
committer | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-09 20:54:03 +0000 |
commit | d0f650e53c2ed237187517d5abde490578234951 (patch) | |
tree | 1be1fba2db0ec440956190a8a5dd3f4a6e6191e0 /media | |
parent | 2e40e663fefd393809a865a5741a2b347252a5d1 (diff) | |
download | chromium_src-d0f650e53c2ed237187517d5abde490578234951.zip chromium_src-d0f650e53c2ed237187517d5abde490578234951.tar.gz chromium_src-d0f650e53c2ed237187517d5abde490578234951.tar.bz2 |
Fix usage of OmxInputBuffer in OpenMAX code since it's refcounted.
In last refactoring of OpenMAX code, OmxInputBuffer was changed
to refcounted but it wasn't probably used. This is now fixed.
Unittest is coming in another patch.
Review URL: http://codereview.chromium.org/596018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38498 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r-- | media/omx/omx_codec.cc | 22 | ||||
-rw-r--r-- | media/omx/omx_codec.h | 5 | ||||
-rw-r--r-- | media/tools/omx_test/omx_test.cc | 1 |
3 files changed, 15 insertions, 13 deletions
diff --git a/media/omx/omx_codec.cc b/media/omx/omx_codec.cc index 6b8d95e..b464af7 100644 --- a/media/omx/omx_codec.cc +++ b/media/omx/omx_codec.cc @@ -83,9 +83,11 @@ void OmxCodec::Read(ReadCallback* callback) { } void OmxCodec::Feed(OmxInputBuffer* buffer, FeedCallback* callback) { + scoped_refptr<OmxInputBuffer> buffer_ref = buffer; message_loop_->PostTask( FROM_HERE, - NewRunnableMethod(this, &OmxCodec::FeedTask, buffer, callback)); + NewRunnableMethod(this, &OmxCodec::FeedTask, buffer_ref, + callback)); } void OmxCodec::Flush(Callback* callback) { @@ -159,7 +161,7 @@ void OmxCodec::ReadTask(ReadCallback* callback) { FillBufferTask(); } -void OmxCodec::FeedTask(OmxInputBuffer* buffer, +void OmxCodec::FeedTask(scoped_refptr<OmxInputBuffer> buffer, FeedCallback* callback) { DCHECK_EQ(message_loop_, MessageLoop::current()); @@ -247,7 +249,7 @@ void OmxCodec::FreeInputQueue() { DCHECK_EQ(message_loop_, MessageLoop::current()); while (!input_queue_.empty()) { - OmxInputBuffer* buffer = input_queue_.front().first; + scoped_refptr<OmxInputBuffer> buffer = input_queue_.front().first; FeedCallback* callback = input_queue_.front().second; callback->Run(buffer); delete callback; @@ -965,7 +967,7 @@ void OmxCodec::EmptyBufferTask() { while (!input_queue_.empty() && !available_input_buffers_.empty() && !input_eos_) { - OmxInputBuffer* buffer = input_queue_.front().first; + scoped_refptr<OmxInputBuffer> buffer = input_queue_.front().first; FeedCallback* callback = input_queue_.front().second; OMX_BUFFERHEADERTYPE* omx_buffer = available_input_buffers_.front(); available_input_buffers_.pop(); @@ -1027,13 +1029,13 @@ void OmxCodec::FillBufferTask() { available_output_buffers_.pop(); // Give the output data to the callback but it doesn't own this buffer. - callback->RunWithParams( - MakeTuple(omx_buffer->pBuffer, - static_cast<int>(omx_buffer->nFilledLen))); - delete callback; - - if (omx_buffer->nFlags & OMX_BUFFERFLAG_EOS) + int filled = omx_buffer->nFilledLen; + if (omx_buffer->nFlags & OMX_BUFFERFLAG_EOS) { output_eos_ = true; + filled = 0; + } + callback->RunWithParams(MakeTuple(omx_buffer->pBuffer, filled)); + delete callback; omx_buffer->nOutputPortIndex = output_port_; omx_buffer->pAppPrivate = this; diff --git a/media/omx/omx_codec.h b/media/omx/omx_codec.h index 0eb94b8..9c82bd5 100644 --- a/media/omx/omx_codec.h +++ b/media/omx/omx_codec.h @@ -170,7 +170,8 @@ class OmxCodec : public base::RefCountedThreadSafe<OmxCodec> { void StartTask(); void StopTask(Callback* callback); void ReadTask(ReadCallback* callback); - void FeedTask(OmxInputBuffer* buffer, FeedCallback* callback); + void FeedTask(scoped_refptr<OmxInputBuffer> buffer, + FeedCallback* callback); // Helper method to perform tasks when this object is stopped. void DoneStop(); @@ -310,7 +311,7 @@ class OmxCodec : public base::RefCountedThreadSafe<OmxCodec> { scoped_ptr<Callback> error_callback_; // Input and output queue for encoded data and decoded frames. - typedef std::pair<OmxInputBuffer*, FeedCallback*> InputUnit; + typedef std::pair<scoped_refptr<OmxInputBuffer>, FeedCallback*> InputUnit; std::queue<InputUnit> input_queue_; std::queue<ReadCallback*> output_queue_; diff --git a/media/tools/omx_test/omx_test.cc b/media/tools/omx_test/omx_test.cc index ae13aa4..d7dc672 100644 --- a/media/tools/omx_test/omx_test.cc +++ b/media/tools/omx_test/omx_test.cc @@ -103,7 +103,6 @@ class TestApp { // the last buffer is an end-of-stream buffer, when we have stopped, and // when we have received an error. bool eos = buffer->IsEndOfStream(); - delete buffer; if (!eos && !stopped_ && !error_) FeedInputBuffer(); } |