summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Zhang <chz@google.com>2014-02-14 15:26:00 -0800
committerChong Zhang <chz@google.com>2014-02-14 17:42:40 -0800
commitb63d2433350d56bda9f3477549086c90bb6d535e (patch)
tree0abcc0700389ee9cb6704350c6da4a47d76cd44d
parent2cf312c2294f128423491a6cc6ba1b1afda5967b (diff)
downloadframeworks_av-b63d2433350d56bda9f3477549086c90bb6d535e.zip
frameworks_av-b63d2433350d56bda9f3477549086c90bb6d535e.tar.gz
frameworks_av-b63d2433350d56bda9f3477549086c90bb6d535e.tar.bz2
fix codec buffer leak in error handling when timestamp goes backward
don't touch codec buffer if we decided to drop a frame with bad pts Bug: 11971963 Change-Id: I9b4c56210f64258f1be257b14184381a1133e0d6
-rw-r--r--media/libstagefright/omx/GraphicBufferSource.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/media/libstagefright/omx/GraphicBufferSource.cpp b/media/libstagefright/omx/GraphicBufferSource.cpp
index 1e6de55..8d65a1f 100644
--- a/media/libstagefright/omx/GraphicBufferSource.cpp
+++ b/media/libstagefright/omx/GraphicBufferSource.cpp
@@ -574,7 +574,7 @@ int64_t GraphicBufferSource::getTimestamp(const BufferQueue::BufferItem &item) {
if (originalTimeUs < mPrevOriginalTimeUs) {
// Drop the frame if it's going backward in time. Bad timestamp
// could disrupt encoder's rate control completely.
- ALOGV("Dropping frame that's going backward in time");
+ ALOGW("Dropping frame that's going backward in time");
return -1;
}
int64_t timestampGapUs = originalTimeUs - mPrevOriginalTimeUs;
@@ -593,6 +593,12 @@ int64_t GraphicBufferSource::getTimestamp(const BufferQueue::BufferItem &item) {
status_t GraphicBufferSource::submitBuffer_l(
const BufferQueue::BufferItem &item, int cbi) {
ALOGV("submitBuffer_l cbi=%d", cbi);
+
+ int64_t timeUs = getTimestamp(item);
+ if (timeUs < 0ll) {
+ return UNKNOWN_ERROR;
+ }
+
CodecBuffer& codecBuffer(mCodecBuffers.editItemAt(cbi));
codecBuffer.mGraphicBuffer = mBufferSlot[item.mBuf];
codecBuffer.mBuf = item.mBuf;
@@ -606,12 +612,6 @@ status_t GraphicBufferSource::submitBuffer_l(
memcpy(data, &type, 4);
memcpy(data + 4, &handle, sizeof(buffer_handle_t));
- int64_t timeUs = getTimestamp(item);
- if (timeUs < 0ll) {
- ALOGE("Dropping frame with bad timestamp");
- return UNKNOWN_ERROR;
- }
-
status_t err = mNodeInstance->emptyDirectBuffer(header, 0,
4 + sizeof(buffer_handle_t), OMX_BUFFERFLAG_ENDOFFRAME,
timeUs);