summaryrefslogtreecommitdiffstats
path: root/libcamera
diff options
context:
space:
mode:
authorJeong-Seok Yang <jseok.yang@samsung.com>2010-11-03 01:23:38 -0700
committerMaarten Hooft <mthooft@google.com>2010-11-03 22:55:25 -0700
commitb1a586852b13fe603c87d8bca3a5509fc1bb7a65 (patch)
treeadc5b169e41c3b806d3a37cdca76872accc2479c /libcamera
parent7e4e2689b809727d7ac84b732bb9b1bec8145f01 (diff)
downloaddevice_samsung_crespo-b1a586852b13fe603c87d8bca3a5509fc1bb7a65.zip
device_samsung_crespo-b1a586852b13fe603c87d8bca3a5509fc1bb7a65.tar.gz
device_samsung_crespo-b1a586852b13fe603c87d8bca3a5509fc1bb7a65.tar.bz2
libcamera: for reliability
1. Adding checking preview status in CameraHardwareSec::stopPreview(). So if its status is not previewing, It doesn't call SecCamera::stopPreview. Thus, buffers what be used by picture thread will not be cleared. 2. Adding killing thread and clear buffers in CameraHardwareSec::cancelPicture() 3. CameraHardwareSec::SplitFrame was modified to remove potential problem about memory access. fix : bug 3093595 Change-Id: Iefa85df297a6abdbb5fb7772b58e0c949aeda0de Signed-off-by: Jeong-Seok Yang <jseok.yang@samsung.com>
Diffstat (limited to 'libcamera')
-rw-r--r--libcamera/SecCamera.cpp4
-rw-r--r--libcamera/SecCamera.h1
-rw-r--r--libcamera/SecCameraHWInterface.cpp31
3 files changed, 28 insertions, 8 deletions
diff --git a/libcamera/SecCamera.cpp b/libcamera/SecCamera.cpp
index 28cd65a..b71a2ce 100644
--- a/libcamera/SecCamera.cpp
+++ b/libcamera/SecCamera.cpp
@@ -1845,6 +1845,10 @@ int SecCamera::getSnapshotPixelFormat(void)
return m_snapshot_v4lformat;
}
+int SecCamera::cancelPicture(void)
+{
+ return close_buffers(m_buffers_c);
+}
// ======================================================================
// Settings
diff --git a/libcamera/SecCamera.h b/libcamera/SecCamera.h
index 700b653..e1460b9 100644
--- a/libcamera/SecCamera.h
+++ b/libcamera/SecCamera.h
@@ -328,6 +328,7 @@ public:
unsigned int getRecPhyAddrY(int);
unsigned int getRecPhyAddrC(int);
#endif
+ int cancelPicture(void);
int flagPreviewStart(void);
int getPreview(void);
int setPreviewSize(int width, int height, int pixel_format);
diff --git a/libcamera/SecCameraHWInterface.cpp b/libcamera/SecCameraHWInterface.cpp
index a5b86d8..9d5c775 100644
--- a/libcamera/SecCameraHWInterface.cpp
+++ b/libcamera/SecCameraHWInterface.cpp
@@ -727,6 +727,9 @@ void CameraHardwareSec::stopPreview()
{
LOGV("%s :", __func__);
+ if (!previewEnabled())
+ return;
+
/* request that the preview thread exit. we can wait because we're
* called by CameraServices with a lock but it has disabled all preview
* related callbacks so previewThread should not invoke any callbacks.
@@ -1124,11 +1127,12 @@ int CameraHardwareSec::pictureThread()
if(isLSISensor) {
LOGI("== Camera Sensor Detect %s - Samsung LSI SOC 5M ==\n", mCameraSensorName);
// LSI 5M SOC
- SplitFrame(jpeg_data, SecCamera::getInterleaveDataSize(),
+ if (!SplitFrame(jpeg_data, SecCamera::getInterleaveDataSize(),
SecCamera::getJpegLineLength(),
mPostViewWidth * 2, mPostViewWidth,
JpegHeap->base(), &JpegImageSize,
- PostviewHeap->base(), &mPostViewSize);
+ PostviewHeap->base(), &mPostViewSize))
+ return UNKNOWN_ERROR;
} else {
LOGI("== Camera Sensor Detect %s Sony SOC 5M ==\n", mCameraSensorName);
decodeInterleaveData(jpeg_data, SecCamera::getInterleaveDataSize(), mPostViewWidth, mPostViewHeight,
@@ -1260,6 +1264,10 @@ status_t CameraHardwareSec::takePicture()
status_t CameraHardwareSec::cancelPicture()
{
+ mPictureThread->requestExitAndWait();
+
+ mSecCamera->cancelPicture();
+
LOGW("%s : not supported, just returning NO_ERROR", __func__);
return NO_ERROR;
}
@@ -1342,14 +1350,22 @@ bool CameraHardwareSec::SplitFrame(unsigned char *pFrame, int dwSize,
while (pSrc < pSrcEnd) {
// Check video start marker
if (CheckVideoStartMarker(pSrc)) {
+ int copyLength;
+
+ if (pSrc + dwVideoLineLength <= pSrcEnd)
+ copyLength = dwVideoLineLength;
+ else
+ copyLength = pSrcEnd - pSrc - VIDEO_COMMENT_MARKER_LENGTH;
+
// Copy video data
if (pV) {
- memcpy(pV, pSrc + VIDEO_COMMENT_MARKER_LENGTH, dwVideoLineLength);
- pV += dwVideoLineLength;
- dwVSize += dwVideoLineLength;
+ memcpy(pV, pSrc + VIDEO_COMMENT_MARKER_LENGTH, copyLength);
+ pV += copyLength;
+ dwVSize += copyLength;
}
- pSrc += dwVideoLineLength + VIDEO_COMMENT_MARKER_LENGTH;
- } else {
+
+ pSrc += copyLength + VIDEO_COMMENT_MARKER_LENGTH;
+ } else {
// Copy pure JPEG data
int size = 0;
int dwCopyBufLen = dwJPEGLineLength <= pSrcEnd-pSrc ? dwJPEGLineLength : pSrcEnd - pSrc;
@@ -1374,7 +1390,6 @@ bool CameraHardwareSec::SplitFrame(unsigned char *pFrame, int dwSize,
pJ += dwCopyBufLen;
pSrc += dwCopyBufLen;
}
-
if (isFinishJpeg)
break;
}