From e2c67b7446e5fe43e6ba10e868c09309493d3308 Mon Sep 17 00:00:00 2001 From: Dave Sparks Date: Thu, 25 Jun 2009 19:27:59 -0700 Subject: [PATCH] Fix crash in PMEM heap destructor due to sequencing issue. Bug 1919195. --- android/android_surface_output.cpp | 22 +++++++++++----------- android/android_surface_output.h | 1 - 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/android/android_surface_output.cpp b/android/android_surface_output.cpp index 78797a99..570d68a9 100644 --- a/android/android_surface_output.cpp +++ b/android/android_surface_output.cpp @@ -68,7 +68,7 @@ status_t AndroidSurfaceOutput::setVideoSurface(const sp& surface) } mSurface = surface; // register buffers for the new surface - if ((mSurface != NULL) && (mFrameHeap != NULL)) { + if ((mSurface != NULL) && (mBufferHeap.heap != NULL)) { LOGV("registerBuffers from old surface"); mSurface->registerBuffers(mBufferHeap); } @@ -329,7 +329,7 @@ PVMFCommandId AndroidSurfaceOutput::Start(const OsclAny* aContext) void AndroidSurfaceOutput::postLastFrame() { // ignore if no surface or heap - if ((mSurface == NULL) || (mFrameHeap == NULL)) return; + if ((mSurface == NULL) || (mBufferHeap.heap == NULL)) return; mSurface->postBuffer(mFrameBuffers[mFrameBufferIndex]); } @@ -970,14 +970,14 @@ OSCL_EXPORT_REF bool AndroidSurfaceOutput::initCheck() frameSize = frameWidth * frameHeight * 2; // create frame buffer heap and register with surfaceflinger - mFrameHeap = new MemoryHeapBase(frameSize * kBufferCount); - if (mFrameHeap->heapID() < 0) { - LOGE("Error creating frame buffer heap"); - return false; + sp heap = new MemoryHeapBase(frameSize * kBufferCount); + if (heap->heapID() < 0) { + LOGE("Error creating frame buffer heap"); + return false; } mBufferHeap = ISurface::BufferHeap(displayWidth, displayHeight, - frameWidth, frameHeight, PIXEL_FORMAT_RGB_565, mFrameHeap); + frameWidth, frameHeight, PIXEL_FORMAT_RGB_565, heap); mSurface->registerBuffers(mBufferHeap); // create frame buffers @@ -1006,9 +1006,9 @@ OSCL_EXPORT_REF bool AndroidSurfaceOutput::initCheck() OSCL_EXPORT_REF PVMFStatus AndroidSurfaceOutput::writeFrameBuf(uint8* aData, uint32 aDataLen, const PvmiMediaXferHeader& data_header_info) { // post to SurfaceFlinger - if ((mSurface != NULL) && (mFrameHeap != NULL)) { + if ((mSurface != NULL) && (mBufferHeap.heap != NULL)) { if (++mFrameBufferIndex == kBufferCount) mFrameBufferIndex = 0; - iColorConverter->Convert(aData, static_cast(mFrameHeap->base()) + mFrameBuffers[mFrameBufferIndex]); + iColorConverter->Convert(aData, static_cast(mBufferHeap.heap->base()) + mFrameBuffers[mFrameBufferIndex]); mSurface->postBuffer(mFrameBuffers[mFrameBufferIndex]); } return PVMFSuccess; @@ -1032,8 +1032,8 @@ OSCL_EXPORT_REF void AndroidSurfaceOutput::closeFrameBuf() } // free heaps - LOGV("free mFrameHeap"); - mFrameHeap.clear(); + LOGV("free frame heap"); + mBufferHeap.heap.clear(); // free color converter if (iColorConverter != 0) diff --git a/android/android_surface_output.h b/android/android_surface_output.h index 2604425d..86eca96d 100644 --- a/android/android_surface_output.h +++ b/android/android_surface_output.h @@ -307,7 +307,6 @@ protected: // frame buffer support static const int kBufferCount = 2; int mFrameBufferIndex; - sp mFrameHeap; ISurface::BufferHeap mBufferHeap; size_t mFrameBuffers[kBufferCount]; -- 2.11.0