author | jiyu.yang <jiyu.yang@amlogic.com> | 2013-08-28 03:43:38 (GMT) |
---|---|---|
committer | brian.zhu <brian.zhu@amlogic.com> | 2013-09-19 04:30:08 (GMT) |
commit | 5a1705de4661742fbf7aa57fdbaed9591cc5ab5a (patch) | |
tree | 928b4a52893413824fd852b7b7e2c8c7d11b1fb9 | |
parent | 5f91521693b2c0dc3bae6097c7f8d19546fbd68d (diff) | |
download | camera-5a1705de4661742fbf7aa57fdbaed9591cc5ab5a.zip camera-5a1705de4661742fbf7aa57fdbaed9591cc5ab5a.tar.gz camera-5a1705de4661742fbf7aa57fdbaed9591cc5ab5a.tar.bz2 |
PD #78456 fix camera unexpectedly exit bug
-rwxr-xr-x | AppCallbackNotifier.cpp | 2 | ||||
-rwxr-xr-x | V4LCameraAdapter/V4LCameraAdapter.cpp | 35 | ||||
-rwxr-xr-x | inc/V4LCameraAdapter/V4LCameraAdapter.h | 6 |
3 files changed, 38 insertions, 5 deletions
diff --git a/AppCallbackNotifier.cpp b/AppCallbackNotifier.cpp index 71282a0..3f3b959 100755 --- a/AppCallbackNotifier.cpp +++ b/AppCallbackNotifier.cpp @@ -144,8 +144,10 @@ void AppCallbackNotifier::EncoderDoneCb(void* main_jpeg, void* thumb_jpeg, Camer if (thumb_jpeg) { if (((Encoder_libjpeg::params *) thumb_jpeg)->dst) { free(((Encoder_libjpeg::params *) thumb_jpeg)->dst); + ((Encoder_libjpeg::params *) thumb_jpeg)->dst = NULL; } free(thumb_jpeg); + thumb_jpeg = NULL; } if (encoded_mem) { diff --git a/V4LCameraAdapter/V4LCameraAdapter.cpp b/V4LCameraAdapter/V4LCameraAdapter.cpp index a35f9ca..d1472d0 100755 --- a/V4LCameraAdapter/V4LCameraAdapter.cpp +++ b/V4LCameraAdapter/V4LCameraAdapter.cpp @@ -269,6 +269,7 @@ status_t V4LCameraAdapter::initialize(CameraProperties::Properties* caps) } mLimitedFrameRate = 0; // no limited + mExpectedFrameInv = (unsigned) (1000000)/15; #ifndef AMLOGIC_USB_CAMERA_SUPPORT writefile((char*)SYSFILE_CAMERA_SET_PARA, (char*)"1"); @@ -607,6 +608,13 @@ status_t V4LCameraAdapter::setParameters(const CameraParameters ¶ms) set_focus_area( mCameraHandle, focusarea); } + min_fps = mParams.getPreviewFrameRate(); + if( min_fps ){ + mExpectedFrameInv = (unsigned) (1000000)/min_fps; + }else{ + mExpectedFrameInv = (unsigned) (1000000)/15; + } + mParams.getPreviewFpsRange(&min_fps, &max_fps); if((min_fps<0)||(max_fps<0)||(max_fps<min_fps)){ rtn = INVALID_OPERATION; @@ -1075,6 +1083,10 @@ status_t V4LCameraAdapter::startPreview() CAMHAL_LOGDA("Created preview thread"); //Update the flag to indicate we are previewing mPreviewing = true; +#ifdef PREVIEW_TIME_DEBUG + preTimer.start(); + precount = 0; +#endif #ifdef AMLOGIC_CAMERA_NONBLOCK_SUPPORT mFirstBuff = true; mFrameInvAdjust = 0; @@ -1321,10 +1333,13 @@ int V4LCameraAdapter::previewThread() if (mPreviewing){ int index = -1; - if((mLimitedFrameRate!=0)&&(mLimitedFrameRate<mParams.getPreviewFrameRate())) - previewframeduration = (unsigned)(1000000.0f / float(mLimitedFrameRate)); - else - previewframeduration = (unsigned)(1000000.0f / float(mParams.getPreviewFrameRate())); + + previewframeduration = mExpectedFrameInv; + if(mLimitedFrameRate!=0){ + if(mExpectedFrameInv < (unsigned)(1000000.0f / float(mLimitedFrameRate))){ + previewframeduration = (unsigned)(1000000.0f / float(mLimitedFrameRate)); + } + } #ifdef AMLOGIC_CAMERA_NONBLOCK_SUPPORT delay = previewframeduration>>2; #else @@ -1388,7 +1403,7 @@ int V4LCameraAdapter::previewThread() memcpy( &previewTime1, &previewTime2, sizeof( struct timeval)); active_duration = mFrameInv - mFrameInvAdjust; - if((mFrameInv + 20000 > mParams.getPreviewFrameRate()) //kTestSlopMargin = 20ms from CameraGLTest + if((mFrameInv + 20000 > mExpectedFrameInv) //kTestSlopMargin = 20ms from CameraGLTest &&((active_duration>previewframeduration)||((active_duration + 5000)>previewframeduration))){ // more preview duration -5000 us if(noFrame == false){ //current catch a picture,use it and release tmp buf; if( mCache.index != -1){ @@ -1442,6 +1457,16 @@ int V4LCameraAdapter::previewThread() height = mPreviewHeight; } +#ifdef PREVIEW_TIME_DEBUG + precount ++; + if(100 == precount ){ + precount = 0; + preTimer.stop(); + CAMHAL_LOGIB("100frame=%lld\n", preTimer.durationUsecs()); + CAMHAL_LOGIB("preview frame limit=%d\n", mLimitedFrameRate); + preTimer.start(); + } +#endif if(mSensorFormat == V4L2_PIX_FMT_MJPEG){ //enable mjpeg if(jpeg_decode(&dest,src,width,height, ( CameraFrame::PIXEL_FMT_NV21 == mPixelFormat)?V4L2_PIX_FMT_NV21:V4L2_PIX_FMT_YVU420) != 0){ // output format is nv21 fillThisBuffer((uint8_t*) mPreviewBufs.keyAt(mPreviewIdxs.valueFor(index)), CameraFrame::PREVIEW_FRAME_SYNC); diff --git a/inc/V4LCameraAdapter/V4LCameraAdapter.h b/inc/V4LCameraAdapter/V4LCameraAdapter.h index 5f686c8..5deecaf 100755 --- a/inc/V4LCameraAdapter/V4LCameraAdapter.h +++ b/inc/V4LCameraAdapter/V4LCameraAdapter.h @@ -27,6 +27,7 @@ namespace android { #ifdef AMLOGIC_USB_CAMERA_SUPPORT + #define DEFAULT_PREVIEW_PIXEL_FORMAT V4L2_PIX_FMT_NV21 //#define DEFAULT_PREVIEW_PIXEL_FORMAT V4L2_PIX_FMT_YUYV #define DEFAULT_IMAGE_CAPTURE_PIXEL_FORMAT V4L2_PIX_FMT_RGB24 @@ -430,7 +431,12 @@ private: int mRotateValue; #endif LimitedRate_t LimitedRate; +#ifdef PREVIEW_TIME_DEBUG + DurationTimer preTimer; + int precount; +#endif int mLimitedFrameRate; + unsigned mExpectedFrameInv; bool mUseMJPEG; bool mSupportMJPEG; }; |