summaryrefslogtreecommitdiff
authorjiyu.yang <jiyu.yang@amlogic.com>2013-12-11 07:30:35 (GMT)
committer Sandy lUo <sandy.luo@amlogic.com>2013-12-11 09:29:07 (GMT)
commit3272967c49f26125e776b2f820c20bbcff7177aa (patch)
tree9bcabfc2e76639ef93db1e6c02f0984d1f91c3b7
parente15de89845b71388aba35d8e4600abeedbfcb2fa (diff)
downloadcamera-3272967c49f26125e776b2f820c20bbcff7177aa.zip
camera-3272967c49f26125e776b2f820c20bbcff7177aa.tar.gz
camera-3272967c49f26125e776b2f820c20bbcff7177aa.tar.bz2
PD #83779 fix the racing condition for event lock
commit 499746ce09ea9502ede4ec7126e4ec22aaed38d1 Author: jiyu.yang <jiyu.yang@amlogic.com> Date: Tue Dec 10 16:07:31 2013 +0800 add read func in the CameraHal only for eng-debug commit b1097c51b6ffcf95d3d4b1950ebed4d7ce307ac1 Author: jiyu.yang <jiyu.yang@amlogic.com> Date: Tue Dec 10 14:50:43 2013 +0800 fix the racing condition for event lock 1.fix the racing condition for event lock 2.add DBG_LOG 3.pixelformat print in %c
Diffstat
-rwxr-xr-xAppCallbackNotifier.cpp22
-rwxr-xr-xV4LCameraAdapter/V4LCameraAdapter.cpp38
-rwxr-xr-xutils/DebugUtils.h2
-rwxr-xr-xutils/MessageQueue.h2
4 files changed, 57 insertions, 7 deletions
diff --git a/AppCallbackNotifier.cpp b/AppCallbackNotifier.cpp
index 491d696..724cb60 100755
--- a/AppCallbackNotifier.cpp
+++ b/AppCallbackNotifier.cpp
@@ -322,8 +322,12 @@ void AppCallbackNotifier::notifyEvent()
MSGUTILS::Message msg;
LOG_FUNCTION_NAME;
{
- Mutex::Autolock lock(mLock);
- mEventQ.get(&msg);
+ Mutex::Autolock lock(mLock);
+ if(!mEventQ.isEmpty()){
+ mEventQ.get(&msg);
+ }else{
+ return ;
+ }
}
bool ret = true;
CameraHalEvent *evt = NULL;
@@ -449,6 +453,7 @@ void AppCallbackNotifier::notifyEvent()
if ( NULL != evt )
{
delete evt;
+ evt = NULL;
}
@@ -1289,9 +1294,20 @@ void AppCallbackNotifier::eventCallback(CameraHalEvent* chEvt)
void AppCallbackNotifier::flushEventQueue()
{
+ MSGUTILS::Message msg;
+ CameraHalEvent *evt = NULL;
{
Mutex::Autolock lock(mLock);
- mEventQ.clear();
+ while (!mEventQ.isEmpty()){
+ mEventQ.get(&msg);
+ evt = (CameraHalEvent *)msg.arg1;
+ if (NULL != evt){
+ delete evt;
+ evt = NULL;
+ }
+ }
+
+ //mEventQ.clear();
}
}
diff --git a/V4LCameraAdapter/V4LCameraAdapter.cpp b/V4LCameraAdapter/V4LCameraAdapter.cpp
index 4343e12..487638c 100755
--- a/V4LCameraAdapter/V4LCameraAdapter.cpp
+++ b/V4LCameraAdapter/V4LCameraAdapter.cpp
@@ -133,6 +133,35 @@ static int writefile(char* path,char* content)
}
return 1;
}
+#ifndef CAMHAL_USER_MODE
+//
+//usage
+//+ char property1[80];
+//+
+//+ readfile((char*)SYSFILE_CAMERA_SET_MIRROR, property1);
+//+ CAMHAL_LOGDB("mirror =%s\n", property1);
+//
+static int readfile(char *path,char *content)
+{
+ char *tmp=content;
+
+ FILE *fp = fopen(path,"r");
+
+ if(fp == NULL) {
+ CAMHAL_LOGDA("readfile open fail");
+ return -1;
+ }
+ int ch;
+ while ((ch=fgetc(fp)) != EOF ) {
+ *content = (char)ch;
+ content++;
+ }
+ fclose(fp);
+ *content='\0';
+
+ return 0;
+}
+#endif
#endif
/*--------------------Camera Adapter Class STARTS here-----------------------------*/
status_t V4LCameraAdapter::sendCommand(CameraCommands operation, int value1, int value2, int value3) {
@@ -678,7 +707,8 @@ status_t V4LCameraAdapter::useBuffers(CameraMode mode, void* bufArr, int num, si
status_t V4LCameraAdapter::setBuffersFormat(int width, int height, int pixelformat)
{
int ret = NO_ERROR;
- CAMHAL_LOGDB("Width * Height %d x %d format 0x%x", width, height, pixelformat);
+ CAMHAL_LOGIB("Width * Height %d x %d pixelformat:%c%c%c%c",
+ width, height, pixelformat&0xff, (pixelformat>>8)&0xFF, (pixelformat>>16)&0xFF,(pixelformat>>24)&0xFF);
mVideoInfo->width = width;
mVideoInfo->height = height;
@@ -720,6 +750,7 @@ status_t V4LCameraAdapter::getBuffersFormat(int &width, int &height, int &pixelf
status_t V4LCameraAdapter::setCrop(int width, int height)
{
int ret = NO_ERROR;
+#ifndef AMLOGIC_USB_CAMERA_SUPPORT
struct v4l2_crop crop;
memset (&crop, 0, sizeof(crop));
@@ -727,11 +758,10 @@ status_t V4LCameraAdapter::setCrop(int width, int height)
crop.c.height = height;
ret = ioctl(mCameraHandle, VIDIOC_S_CROP, &crop);
if (ret < 0) {
- CAMHAL_LOGEB("VIDIOC_S_CROP Failed: %s, ret=%d\n", strerror(errno), ret);
+ CAMHAL_LOGVB("VIDIOC_S_CROP Failed: %s, ret=%d\n", strerror(errno), ret);
}
- CAMHAL_LOGIB("crop w=%d, h=%d\n", width, height);
-
+#endif
return ret;
}
diff --git a/utils/DebugUtils.h b/utils/DebugUtils.h
index f203eaa..56afc00 100755
--- a/utils/DebugUtils.h
+++ b/utils/DebugUtils.h
@@ -67,6 +67,8 @@ extern volatile int32_t gCamHal_LogLevel;
#define LOG_FUNCTION_NAME CAMHAL_LOGVA("ENTER");
#define LOG_FUNCTION_NAME_EXIT CAMHAL_LOGVA("EXIT");
+#define DBG_LOGA(str) ALOGI_IF(gCamHal_LogLevel >=4,"%5d %s - " str, __LINE__,__FUNCTION__);
+#define DBG_LOGB(str, ...) ALOGI_IF(gCamHal_LogLevel >=4,"%5d %s - " str, __LINE__,__FUNCTION__, __VA_ARGS__);
#endif
diff --git a/utils/MessageQueue.h b/utils/MessageQueue.h
index ff2c9e3..ebdf584 100755
--- a/utils/MessageQueue.h
+++ b/utils/MessageQueue.h
@@ -35,6 +35,8 @@
#else
+#define MSGQ_LOGVA CAMHAL_LOGVA
+#define MSGQ_LOGVB CAMHAL_LOGVB
#define MSGQ_LOGDA CAMHAL_LOGDA
#define MSGQ_LOGDB CAMHAL_LOGDB