summaryrefslogtreecommitdiff
authorbrian.zhu <brian.zhu@amlogic.com>2012-10-29 15:17:38 (GMT)
committer brian.zhu <brian.zhu@amlogic.com>2012-10-29 15:17:38 (GMT)
commit39cb2e112341904aebc6a18f101c287ff6272a12 (patch)
tree609621fdae3758e7d5cbeee8322387e9675553e1
parentdfb21ee31f975eb20f0fba6998afcc49c6e86d89 (diff)
downloadcamera-39cb2e112341904aebc6a18f101c287ff6272a12.zip
camera-39cb2e112341904aebc6a18f101c287ff6272a12.tar.gz
camera-39cb2e112341904aebc6a18f101c287ff6272a12.tar.bz2
fix crash when recording size is different with preview size
Diffstat
-rwxr-xr-xCameraHal_Module.cpp2
-rwxr-xr-xV4LCameraAdapter/V4LCameraAdapter.cpp42
-rwxr-xr-xinc/CameraHal.h4
-rwxr-xr-xinc/V4LCameraAdapter/V4LCameraAdapter.h9
4 files changed, 44 insertions, 13 deletions
diff --git a/CameraHal_Module.cpp b/CameraHal_Module.cpp
index fee9db3..92c4b49 100755
--- a/CameraHal_Module.cpp
+++ b/CameraHal_Module.cpp
@@ -634,7 +634,7 @@ int camera_get_camera_info(int camera_id, struct camera_info *info)
if(gCameraProperties.initialize() != android::NO_ERROR)
{
CAMHAL_LOGEA("Unable to create or initialize CameraProperties");
- return NULL;
+ return -EINVAL;
}
//Get camera properties for camera index
diff --git a/V4LCameraAdapter/V4LCameraAdapter.cpp b/V4LCameraAdapter/V4LCameraAdapter.cpp
index 4840ac6..684f15b 100755
--- a/V4LCameraAdapter/V4LCameraAdapter.cpp
+++ b/V4LCameraAdapter/V4LCameraAdapter.cpp
@@ -256,6 +256,11 @@ status_t V4LCameraAdapter::initialize(CameraProperties::Properties* caps)
mFlashMode = FLASHLIGHT_OFF;
mPixelFormat = 0;
+ mPreviewWidth = 0 ;
+ mPreviewHeight = 0;
+ mCaptureWidth = 0;
+ mCaptureHeight = 0;
+
#ifdef AMLOGIC_USB_CAMERA_SUPPORT
mIsDequeuedEIOError = false;
mUsbCameraStatus = USBCAMERA_INITED;
@@ -765,6 +770,8 @@ status_t V4LCameraAdapter::UseBuffersPreview(void* bufArr, int num)
int width, height;
mParams.getPreviewSize(&width, &height);
+ mPreviewWidth = width;
+ mPreviewHeight = height;
const char *pixfmtchar;
int pixfmt = V4L2_PIX_FMT_NV21;
@@ -911,10 +918,12 @@ status_t V4LCameraAdapter::UseBuffersCapture(void* bufArr, int num)
LOGD("UseBuffersCapture setBuffersFormat..");
int width, height;
mParams.getPictureSize(&width, &height);
+ mCaptureWidth = width;
+ mCaptureHeight = height;
#ifdef AMLOGIC_USB_CAMERA_SUPPORT
setBuffersFormat(width, height, V4L2_PIX_FMT_YUYV);
#else
- if(mIoctlSupport & IOCTL_MASK_ROTATE){
+ if(mIoctlSupport & IOCTL_MASK_ROTATE){
int temp = 0;
mRotateValue = mParams.getInt(CameraParameters::KEY_ROTATION);
if((mRotateValue!=0)&&(mRotateValue!=90)&&(mRotateValue!=180)&&(mRotateValue!=270))
@@ -1506,7 +1515,13 @@ int V4LCameraAdapter::previewThread()
#endif
int width, height;
uint8_t* src = (uint8_t*) fp;
- mParams.getPreviewSize(&width, &height);
+ if((mPreviewWidth <= 0)||(mPreviewHeight <= 0)){
+ mParams.getPreviewSize(&width, &height);
+ }else{
+ width = mPreviewWidth;
+ height = mPreviewHeight;
+ }
+
if(DEFAULT_PREVIEW_PIXEL_FORMAT == V4L2_PIX_FMT_YUYV){ // 422I
frame.mLength = width*height*2;
memcpy(dest,src,frame.mLength);
@@ -1539,8 +1554,8 @@ int V4LCameraAdapter::previewThread()
frame.mBuffer = ptr; //dest
frame.mAlignment = width;
frame.mOffset = 0;
- frame.mYuv[0] = NULL;
- frame.mYuv[1] = NULL;
+ frame.mYuv[0] = 0;
+ frame.mYuv[1] = 0;
frame.mWidth = width;
frame.mHeight = height;
frame.mTimestamp = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -1583,7 +1598,13 @@ int V4LCameraAdapter::GenExif(ExifElementsTable* exiftable)
//Image width,height
int width,height;
- mParams.getPictureSize(&width,&height);
+ if((mCaptureWidth <= 0)||(mCaptureHeight <= 0)){
+ mParams.getPictureSize(&width, &height);
+ }else{
+ width = mCaptureWidth;
+ height = mCaptureHeight;
+ }
+
#ifndef AMLOGIC_USB_CAMERA_SUPPORT
if(mIoctlSupport & IOCTL_MASK_ROTATE){
orientation = 1;
@@ -1833,7 +1854,12 @@ int V4LCameraAdapter::pictureThread()
int width, height;
uint8_t* dest = (uint8_t*)mCaptureBuf->data;
uint8_t* src = (uint8_t*) fp;
- mParams.getPictureSize(&width, &height);
+ if((mCaptureWidth <= 0)||(mCaptureHeight <= 0)){
+ mParams.getPictureSize(&width, &height);
+ }else{
+ width = mCaptureWidth;
+ height = mCaptureHeight;
+ }
#ifndef AMLOGIC_USB_CAMERA_SUPPORT
if((mRotateValue==90)||(mRotateValue==270)){
@@ -1890,8 +1916,8 @@ int V4LCameraAdapter::pictureThread()
frame.mCookie2 = (void*)exiftable;
frame.mAlignment = width;
frame.mOffset = 0;
- frame.mYuv[0] = NULL;
- frame.mYuv[1] = NULL;
+ frame.mYuv[0] = 0;
+ frame.mYuv[1] = 0;
frame.mWidth = width;
frame.mHeight = height;
frame.mTimestamp = systemTime(SYSTEM_TIME_MONOTONIC);
diff --git a/inc/CameraHal.h b/inc/CameraHal.h
index effe37b..f4825d3 100755
--- a/inc/CameraHal.h
+++ b/inc/CameraHal.h
@@ -289,8 +289,8 @@ class CameraFrame
mQuirks(0),
mPixelFmt(0) {
- mYuv[0] = NULL;
- mYuv[1] = NULL;
+ mYuv[0] = 0;
+ mYuv[1] = 0;
}
//copy constructor
diff --git a/inc/V4LCameraAdapter/V4LCameraAdapter.h b/inc/V4LCameraAdapter/V4LCameraAdapter.h
index 5cdcefc..7ac728d 100755
--- a/inc/V4LCameraAdapter/V4LCameraAdapter.h
+++ b/inc/V4LCameraAdapter/V4LCameraAdapter.h
@@ -317,7 +317,7 @@ public:
private:
int mPreviewBufferCount;
KeyedVector<int, int> mPreviewBufs;
- KeyedVector<int, int> mPreviewIdxs;
+ KeyedVector<int, int> mPreviewIdxs;
mutable Mutex mPreviewBufsLock;
//TODO use members from BaseCameraAdapter
@@ -325,6 +325,11 @@ private:
CameraParameters mParams;
+ int mPreviewWidth;
+ int mPreviewHeight;
+ int mCaptureWidth;
+ int mCaptureHeight;
+
bool mPreviewing;
bool mCapturing;
Mutex mLock;
@@ -339,7 +344,7 @@ private:
int mSensorIndex;
bool mbFrontCamera;
- bool mbDisableMirror;
+ bool mbDisableMirror;
// protected by mLock
sp<PreviewThread> mPreviewThread;