diff options
author | James Dong <jdong@google.com> | 2010-11-11 14:06:30 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-11-11 14:06:30 -0800 |
commit | 798a9d2eb1d2421f904ab61f05e4b70a5095d31a (patch) | |
tree | 7b8d64e293c2fd187e63d33a7ef2a22de69425df /media | |
parent | 449bb119c954e6beacdfc7074c4d4a8254a07a13 (diff) | |
parent | 31b9375f45e19c1408f45af497286b795604c9ec (diff) | |
download | frameworks_base-798a9d2eb1d2421f904ab61f05e4b70a5095d31a.zip frameworks_base-798a9d2eb1d2421f904ab61f05e4b70a5095d31a.tar.gz frameworks_base-798a9d2eb1d2421f904ab61f05e4b70a5095d31a.tar.bz2 |
Merge "Fix memory leak when 0-memcpy quirk is used"
Diffstat (limited to 'media')
-rw-r--r-- | media/libstagefright/OMXCodec.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp index 9f9c83a..3a5d6af 100644 --- a/media/libstagefright/OMXCodec.cpp +++ b/media/libstagefright/OMXCodec.cpp @@ -1913,6 +1913,13 @@ void OMXCodec::on_message(const omx_message &msg) { // Buffer could not be released until empty buffer done is called. if (info->mMediaBuffer != NULL) { + if (mIsEncoder && + (mQuirks & kAvoidMemcopyInputRecordingFrames)) { + // If zero-copy mode is enabled this will send the + // input buffer back to the upstream source. + restorePatchedDataPointer(info); + } + info->mMediaBuffer->release(); info->mMediaBuffer = NULL; } @@ -2462,6 +2469,7 @@ status_t OMXCodec::freeBuffer(OMX_U32 portIndex, size_t bufIndex) { status_t err = mOMX->freeBuffer(mNode, portIndex, info->mBuffer); if (err == OK && info->mMediaBuffer != NULL) { + CHECK_EQ(portIndex, kPortIndexOutput); info->mMediaBuffer->setObserver(NULL); // Make sure nobody but us owns this buffer at this point. @@ -2474,6 +2482,7 @@ status_t OMXCodec::freeBuffer(OMX_U32 portIndex, size_t bufIndex) { } info->mMediaBuffer->release(); + info->mMediaBuffer = NULL; } if (err == OK) { @@ -2714,10 +2723,10 @@ void OMXCodec::drainInputBuffer(BufferInfo *info) { if (mIsEncoder && (mQuirks & kAvoidMemcopyInputRecordingFrames)) { CHECK(mOMXLivesLocally && offset == 0); OMX_BUFFERHEADERTYPE *header = (OMX_BUFFERHEADERTYPE *) info->mBuffer; + CHECK(header->pBuffer == info->mData); header->pBuffer = (OMX_U8 *) srcBuffer->data() + srcBuffer->range_offset(); releaseBuffer = false; info->mMediaBuffer = srcBuffer; - // FIXME: we are leaking memory } else { if (mIsMetaDataStoredInVideoBuffers) { releaseBuffer = false; @@ -4001,4 +4010,12 @@ status_t QueryCodecs( } } +void OMXCodec::restorePatchedDataPointer(BufferInfo *info) { + CHECK(mIsEncoder && (mQuirks & kAvoidMemcopyInputRecordingFrames)); + CHECK(mOMXLivesLocally); + + OMX_BUFFERHEADERTYPE *header = (OMX_BUFFERHEADERTYPE *)info->mBuffer; + header->pBuffer = (OMX_U8 *)info->mData; +} + } // namespace android |