summaryrefslogtreecommitdiffstats
path: root/camera
diff options
context:
space:
mode:
authorTyler Luu <tluu@ti.com>2011-10-26 12:22:00 -0500
committerIliyan Malchev <malchev@google.com>2011-11-07 12:08:22 -0800
commitfe3c9139602c77b4890370307b63e1ab9990a75b (patch)
tree05df0c2581a48f5efc8c5fabfbffc3feb13f553b /camera
parentfc8ab094473901857ee382396eebc5d52ac4c6c6 (diff)
downloadhardware_ti_omap4xxx-fe3c9139602c77b4890370307b63e1ab9990a75b.zip
hardware_ti_omap4xxx-fe3c9139602c77b4890370307b63e1ab9990a75b.tar.gz
hardware_ti_omap4xxx-fe3c9139602c77b4890370307b63e1ab9990a75b.tar.bz2
CameraHal: Wait for frame before stopping preview
Fix 3/3 for b/5472396. We should wait for the first frame to come before trying to stopPreview. If not, we might put OMXCamera in a bad state i.e (IDLE->LOADED timeout). Seeing this a lot after a capture Change-Id: I4ac6cc4f12bdc0d4d73e065b7c53caf8a440a43c Signed-off-by: Tyler Luu <tluu@ti.com>
Diffstat (limited to 'camera')
-rwxr-xr-xcamera/OMXCameraAdapter/OMXCameraAdapter.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/camera/OMXCameraAdapter/OMXCameraAdapter.cpp b/camera/OMXCameraAdapter/OMXCameraAdapter.cpp
index 15fceec..8389bf0 100755
--- a/camera/OMXCameraAdapter/OMXCameraAdapter.cpp
+++ b/camera/OMXCameraAdapter/OMXCameraAdapter.cpp
@@ -1942,6 +1942,20 @@ status_t OMXCameraAdapter::stopPreview()
{
Mutex::Autolock lock(mFrameCountMutex);
+ // we should wait for the first frame to come before trying to stopPreview...if not
+ // we might put OMXCamera in a bad state (IDLE->LOADED timeout). Seeing this a lot
+ // after a capture
+ if (mFrameCount < 1) {
+ // I want to wait for at least two frames....
+ mFrameCount = -1;
+
+ // first frame may time some time to come...so wait for an adequate amount of time
+ // which 2 * OMX_CAPTURE_TIMEOUT * 1000 will cover.
+ ret = mFirstFrameCondition.waitRelative(mFrameCountMutex,
+ (nsecs_t) 2 * OMX_CAPTURE_TIMEOUT * 1000);
+ }
+ // even if we timeout waiting for the first frame...go ahead with trying to stop preview
+ // signal anybody that might be waiting
mFrameCount = 0;
mFirstFrameCondition.broadcast();
}