summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--media/omx/omx_codec.cc22
-rw-r--r--media/omx/omx_codec.h5
-rw-r--r--media/tools/omx_test/omx_test.cc1
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();
}