diff options
author | Mike J. Chen <mjchen@sta.samsung.com> | 2010-10-26 15:16:00 -0700 |
---|---|---|
committer | Maarten Hooft <mthooft@google.com> | 2010-10-28 19:14:14 -0700 |
commit | 802890e7ab775d71f9ff11a1b259778cd6b90917 (patch) | |
tree | 21a103dca5932c65f470a8625837ed29f17dbe1f /libcamera/SecCameraHWInterface.h | |
parent | 256aeac7371b52c1914fac874e4d2f303068ed93 (diff) | |
download | device_samsung_crespo-802890e7ab775d71f9ff11a1b259778cd6b90917.tar.gz device_samsung_crespo-802890e7ab775d71f9ff11a1b259778cd6b90917.tar.bz2 device_samsung_crespo-802890e7ab775d71f9ff11a1b259778cd6b90917.zip |
S5PC11X: libcamera: threading and error cleanup
Cleanup the way the camera HAL manages its threads so that
the exit path should no longer fail in a race condition.
The destructor waits for all threads to exit and heaps
are destroyed before closing the fd to driver.
Remove deadlock case (a HAL interface should not call a callback,
because the callback would try to grab a lock that is already
being held).
Removed mutex usage that wasn't needed (CameraServices already
has a mutex).
Add checks that could mess up the state of the sensor driver
(setting parameters or starting preview when a capture was still in
progress). We return errors in these cases instead.
Change-Id: I30d832de582a002dad1c087bd7cc7de43237eb19
Signed-off-by: Mike J. Chen <mjchen@sta.samsung.com>
Diffstat (limited to 'libcamera/SecCameraHWInterface.h')
-rw-r--r-- | libcamera/SecCameraHWInterface.h | 49 |
1 files changed, 38 insertions, 11 deletions
diff --git a/libcamera/SecCameraHWInterface.h b/libcamera/SecCameraHWInterface.h index 5ac3e91..b3f90ac 100644 --- a/libcamera/SecCameraHWInterface.h +++ b/libcamera/SecCameraHWInterface.h @@ -32,7 +32,6 @@ public: virtual sp<IMemoryHeap> getPreviewHeap() const; virtual sp<IMemoryHeap> getRawHeap() const; -//Kamat --eclair virtual void setCallbacks(notify_callback notify_cb, data_callback data_cb, data_callback_timestamp data_cb_timestamp, @@ -89,9 +88,6 @@ private: Thread(false), #endif mHardware(hw) { } - virtual void onFirstRef() { - run("CameraPreviewThread", PRIORITY_URGENT_DISPLAY); - } virtual bool threadLoop() { int ret = mHardware->previewThread(); // loop until we need to quit @@ -102,16 +98,45 @@ private: } }; + class PictureThread : public Thread { + CameraHardwareSec *mHardware; + public: + PictureThread(CameraHardwareSec *hw): + Thread(false), + mHardware(hw) { } + virtual bool threadLoop() { + mHardware->pictureThread(); + return false; + } + }; + + class AutoFocusThread : public Thread { + CameraHardwareSec *mHardware; + public: + AutoFocusThread(CameraHardwareSec *hw): Thread(false), mHardware(hw) { } + virtual void onFirstRef() { + run("CameraAutoFocusThread", PRIORITY_DEFAULT); + } + virtual bool threadLoop() { + mHardware->autoFocusThread(); + return true; + } + }; + void initDefaultParameters(int cameraId); void initHeapLocked(); + sp<PreviewThread> mPreviewThread; int previewThread(); + bool mPreviewRunning; - static int beginAutoFocusThread(void *cookie); + sp<AutoFocusThread> mAutoFocusThread; int autoFocusThread(); - static int beginPictureThread(void *cookie); + sp<PictureThread> mPictureThread; int pictureThread(); + bool mCaptureInProgress; + int save_jpeg(unsigned char *real_jpeg, int jpeg_size); void save_postview(const char *fname, uint8_t *buf, uint32_t size); @@ -137,7 +162,13 @@ private: int *pdwJPEGSize, void *pVideo, int *pdwVideoSize); - mutable Mutex mLock; + /* used by auto focus thread to block until it's told to run */ + mutable Mutex mFocusLock; + mutable Condition mCondition; + bool mExitAutoFocusThread; + + /* used to guard threading state */ + mutable Mutex mStateLock; CameraParameters mParameters; CameraParameters mInternalParameters; @@ -150,7 +181,6 @@ private: sp<MemoryBase> mRecordBuffers[kBufferCountForRecord]; SecCamera *mSecCamera; - bool mPreviewRunning; int mPreviewFrameSize; int mRawFrameSize; int mPreviewFrameRateMicrosec; @@ -162,8 +192,6 @@ private: int mOverlayBufferIdx; #endif - // protected by mLock - sp<PreviewThread> mPreviewThread; notify_callback mNotifyCb; data_callback mDataCb; data_callback_timestamp mDataCbTimestamp; @@ -182,7 +210,6 @@ private: int mPostViewSize; #endif - int mNoHwHandle; struct timeval mTimeStart; struct timeval mTimeStop; |