From 32b7f2804eb66a6677826833057ca93bef78b870 Mon Sep 17 00:00:00 2001 From: Iliyan Malchev Date: Wed, 10 Jun 2009 14:49:11 -0700 Subject: [PATCH] libcamera: avoid a race condition on starting and stopping a recording precondition: preview is running -- call startRecording() -- a preview frame arrives, causing the record callback to be called, and then blocks on mRecordWait.wait() -- call stopRecording(), which sets mReleasedRecordingFrame and signals mRecordWait; -- call startRecording(), which clears mReleasedRecordingFrame; -- receivePreviewFrame() wakes up, checks mReleasedRecordingFrame, and blocks again on mRecordWait.wait(), without having notified the client. Signed-off-by: Iliyan Malchev --- libcamera2/QualcommCameraHardware.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcamera2/QualcommCameraHardware.cpp b/libcamera2/QualcommCameraHardware.cpp index 80a8696..718f6bf 100755 --- a/libcamera2/QualcommCameraHardware.cpp +++ b/libcamera2/QualcommCameraHardware.cpp @@ -1547,7 +1547,7 @@ void QualcommCameraHardware::receivePreviewFrame(struct msm_frame *frame) if(rcb != NULL) { Mutex::Autolock rLock(&mRecordFrameLock); rcb(mPreviewHeap->mBuffers[mPreviewFrameOffset], rdata); - while(mReleasedRecordingFrame != true) { + if (mReleasedRecordingFrame != true) { LOGV("block for release frame request/command"); mRecordWait.wait(mRecordFrameLock); }