diff options
author | Eino-Ville Talvala <etalvala@google.com> | 2014-09-29 13:51:17 -0700 |
---|---|---|
committer | Eino-Ville Talvala <etalvala@google.com> | 2014-09-29 14:12:30 -0700 |
commit | 2d077d0acdbb26eeb1357489c999ec875f6ce297 (patch) | |
tree | 2ed54476026da514f70e2184a9ac3bb79605459e /services/camera | |
parent | dc2e6ddc933e40632e79a866d9ece870db1a975e (diff) | |
download | frameworks_av-2d077d0acdbb26eeb1357489c999ec875f6ce297.zip frameworks_av-2d077d0acdbb26eeb1357489c999ec875f6ce297.tar.gz frameworks_av-2d077d0acdbb26eeb1357489c999ec875f6ce297.tar.bz2 |
CameraService: API1: Reallocate JPEG ashmem heap if size changes
Bug: 17682603
Change-Id: I7cba3365d00c33cf4267b1b59a94bd7d0bba08df
Diffstat (limited to 'services/camera')
-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 |