diff options
author | Eino-Ville Talvala <etalvala@google.com> | 2014-09-30 07:03:35 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-09-30 07:03:35 +0000 |
commit | 1f25ce3c3c4d34826cddbd1907e2b09f1cd735f6 (patch) | |
tree | 47489fceb7c47339b74b62068dd094d5fdc0dab0 /services | |
parent | 04afc0a753c449994ad844d1f5713d28569df645 (diff) | |
parent | c8c05d6a5821dd56209e160066314a03d2f2ca06 (diff) | |
download | frameworks_av-1f25ce3c3c4d34826cddbd1907e2b09f1cd735f6.zip frameworks_av-1f25ce3c3c4d34826cddbd1907e2b09f1cd735f6.tar.gz frameworks_av-1f25ce3c3c4d34826cddbd1907e2b09f1cd735f6.tar.bz2 |
am c8c05d6a: Merge "CameraService: API1: Reallocate JPEG ashmem heap if size changes" into lmp-dev
* commit 'c8c05d6a5821dd56209e160066314a03d2f2ca06':
CameraService: API1: Reallocate JPEG ashmem heap if size changes
Diffstat (limited to 'services')
-rw-r--r-- | services/camera/libcameraservice/api1/client2/JpegProcessor.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/services/camera/libcameraservice/api1/client2/JpegProcessor.cpp b/services/camera/libcameraservice/api1/client2/JpegProcessor.cpp index cda98be..b433781 100644 --- a/services/camera/libcameraservice/api1/client2/JpegProcessor.cpp +++ b/services/camera/libcameraservice/api1/client2/JpegProcessor.cpp @@ -89,14 +89,27 @@ status_t JpegProcessor::updateStream(const Parameters ¶ms) { mCaptureConsumer->setFrameAvailableListener(this); mCaptureConsumer->setName(String8("Camera2Client::CaptureConsumer")); mCaptureWindow = new Surface(producer); + } + + // Since ashmem heaps are rounded up to page size, don't reallocate if + // the capture heap isn't exactly the same size as the required JPEG buffer + const size_t HEAP_SLACK_FACTOR = 2; + if (mCaptureHeap == 0 || + (mCaptureHeap->getSize() < static_cast<size_t>(maxJpegSize)) || + (mCaptureHeap->getSize() > + static_cast<size_t>(maxJpegSize) * HEAP_SLACK_FACTOR) ) { // Create memory for API consumption - mCaptureHeap = new MemoryHeapBase(maxJpegSize, 0, "Camera2Client::CaptureHeap"); + mCaptureHeap.clear(); + mCaptureHeap = + new MemoryHeapBase(maxJpegSize, 0, "Camera2Client::CaptureHeap"); if (mCaptureHeap->getSize() == 0) { ALOGE("%s: Camera %d: Unable to allocate memory for capture", __FUNCTION__, mId); return NO_MEMORY; } } + ALOGV("%s: Camera %d: JPEG capture heap now %d bytes; requested %d bytes", + __FUNCTION__, mId, mCaptureHeap->getSize(), maxJpegSize); if (mCaptureStreamId != NO_STREAM) { // Check if stream parameters have to change |