From 68e939ffa64c34bef2272cfe6346f43ee84d1611 Mon Sep 17 00:00:00 2001 From: Tianmi Chen Date: Thu, 16 Jul 2015 20:52:29 +0800 Subject: surface ID initialization When decoder ran into some corner case that the actual buffer count is less than given buffer count, some buffers are destoryed illegally. Bug: 22299730 Change-Id: I13a383dfb7c2c03c950618317cb7afed64369b70 Signed-off-by: Tianmi Chen --- videodecoder/VideoDecoderBase.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'videodecoder') diff --git a/videodecoder/VideoDecoderBase.cpp b/videodecoder/VideoDecoderBase.cpp index 581b8ac..399bc6c 100644 --- a/videodecoder/VideoDecoderBase.cpp +++ b/videodecoder/VideoDecoderBase.cpp @@ -880,6 +880,9 @@ Decode_Status VideoDecoderBase::setupVA(uint32_t numSurface, VAProfile profile, mNumExtraSurfaces = numExtraSurface; mSurfaces = new VASurfaceID [mNumSurfaces + mNumExtraSurfaces]; mExtraSurfaces = mSurfaces + mNumSurfaces; + for (int i = 0; i < mNumSurfaces + mNumExtraSurfaces; ++i) { + mSurfaces[i] = VA_INVALID_SURFACE; + } if (mSurfaces == NULL) { return DECODE_MEMORY_FAIL; } @@ -1086,9 +1089,8 @@ Decode_Status VideoDecoderBase::terminateVA(void) { mSurfaceUserPtr = NULL; } - if (mSurfaces) - { - vaDestroySurfaces(mVADisplay, mSurfaces, mNumSurfaces + mNumExtraSurfaces); + if (mSurfaces) { + vaDestroySurfaces(mVADisplay, mSurfaces, mStoreMetaData ? mMetaDataBuffersNum : (mNumSurfaces + mNumExtraSurfaces)); delete [] mSurfaces; mSurfaces = NULL; } -- cgit v1.2.3