From 7eeb4f61f989b3aa0da6f77a579d6e4de1b5e885 Mon Sep 17 00:00:00 2001 From: Tyler Luu Date: Thu, 21 Jun 2012 09:55:44 -0500 Subject: CameraHal: Init capture reference count logic to derived adapters - Moving initializing for capture reference count to derived adapters since useBuffers call for capture is going to called queuing shots as well. - This patch needs to include V4L adapter before merging on mainline. Change-Id: Ifc4986a68173234ec636ef943b62009f7df1e041 Signed-off-by: Tyler Luu Signed-off-by: Vladimir Petrov --- camera/BaseCameraAdapter.cpp | 11 ----------- camera/OMXCameraAdapter/OMXCapture.cpp | 11 +++++++++++ camera/V4LCameraAdapter/V4LCameraAdapter.cpp | 11 +++++++++++ 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/camera/BaseCameraAdapter.cpp b/camera/BaseCameraAdapter.cpp index d40ef61..5301c6d 100644 --- a/camera/BaseCameraAdapter.cpp +++ b/camera/BaseCameraAdapter.cpp @@ -541,17 +541,6 @@ status_t BaseCameraAdapter::sendCommand(CameraCommands operation, int value1, in android::AutoMutex lock(mCaptureBufferLock); mCaptureBuffers = desc->mBuffers; mCaptureBuffersLength = desc->mLength; - mCaptureBuffersAvailable.clear(); - for ( uint32_t i = 0 ; i < desc->mMaxQueueable ; i++ ) - { - mCaptureBuffersAvailable.add(&mCaptureBuffers[i], 0); - } - // initial ref count for undeqeueued buffers is 1 since buffer provider - // is still holding on to it - for ( uint32_t i = desc->mMaxQueueable ; i < desc->mCount ; i++ ) - { - mCaptureBuffersAvailable.add(&mCaptureBuffers[i], 1); - } } if ( NULL != desc ) diff --git a/camera/OMXCameraAdapter/OMXCapture.cpp b/camera/OMXCameraAdapter/OMXCapture.cpp index e5de0c5..5231960 100644 --- a/camera/OMXCameraAdapter/OMXCapture.cpp +++ b/camera/OMXCameraAdapter/OMXCapture.cpp @@ -1877,6 +1877,17 @@ status_t OMXCameraAdapter::UseBuffersCapture(CameraBuffer * bufArr, int num) // CPCam mode only supports vector shot // Regular capture is not supported if (mCapMode == CP_CAM) initVectorShot(); + + mCaptureBuffersAvailable.clear(); + for (unsigned int i = 0; i < imgCaptureData->mMaxQueueable; i++ ) { + mCaptureBuffersAvailable.add(&mCaptureBuffers[i], 0); + } + + // initial ref count for undeqeueued buffers is 1 since buffer provider + // is still holding on to it + for (unsigned int i = imgCaptureData->mMaxQueueable; i < imgCaptureData->mNumBufs; i++ ) { + mCaptureBuffersAvailable.add(&mCaptureBuffers[i], 1); + } } if ( NO_ERROR == ret ) diff --git a/camera/V4LCameraAdapter/V4LCameraAdapter.cpp b/camera/V4LCameraAdapter/V4LCameraAdapter.cpp index d87a72a..799221d 100755 --- a/camera/V4LCameraAdapter/V4LCameraAdapter.cpp +++ b/camera/V4LCameraAdapter/V4LCameraAdapter.cpp @@ -506,6 +506,17 @@ status_t V4LCameraAdapter::UseBuffersCapture(CameraBuffer *bufArr, int num) { CAMHAL_LOGDB("capture- buff [%d] = 0x%x ",i, mCaptureBufs.keyAt(i)); } + mCaptureBuffersAvailable.clear(); + for (int i = 0; i < mCaptureBufferCountQueueable; i++ ) { + mCaptureBuffersAvailable.add(&mCaptureBuffers[i], 0); + } + + // initial ref count for undeqeueued buffers is 1 since buffer provider + // is still holding on to it + for (int i = mCaptureBufferCountQueueable; i < num; i++ ) { + mCaptureBuffersAvailable.add(&mCaptureBuffers[i], 1); + } + // Update the preview buffer count mCaptureBufferCount = num; EXIT: -- cgit v1.1