diff options
author | Dave Sparks <davidsparks@android.com> | 2009-10-07 19:18:20 -0700 |
---|---|---|
committer | Dave Sparks <davidsparks@android.com> | 2009-10-07 19:22:02 -0700 |
commit | 2133640028ef53b33a93ecfb593d30c95fed84c6 (patch) | |
tree | c938899c65206b0633d4fd7fe0e3e4f7380c60ec /camera | |
parent | 4625758d0b909ccfc9f40b707666b1b21e9e8ffd (diff) | |
download | frameworks_base-2133640028ef53b33a93ecfb593d30c95fed84c6.zip frameworks_base-2133640028ef53b33a93ecfb593d30c95fed84c6.tar.gz frameworks_base-2133640028ef53b33a93ecfb593d30c95fed84c6.tar.bz2 |
Retry overlay create if it fails. Bug 2153980.
Occasionally we see references to the overlay hanging around long
enough to cause problems in applications when they tried to destroy
the overlay and re-create it. This patch causes the camera HAL to
retry the overlay creation call if it fails every 20ms up to 50
times before it gives up.
Diffstat (limited to 'camera')
-rw-r--r-- | camera/libcameraservice/CameraService.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/camera/libcameraservice/CameraService.cpp b/camera/libcameraservice/CameraService.cpp index 8279914..b63e97f 100644 --- a/camera/libcameraservice/CameraService.cpp +++ b/camera/libcameraservice/CameraService.cpp @@ -563,7 +563,19 @@ status_t CameraService::Client::setOverlay() status_t ret = NO_ERROR; if (mSurface != 0) { if (mOverlayRef.get() == NULL) { - mOverlayRef = mSurface->createOverlay(w, h, OVERLAY_FORMAT_DEFAULT); + + // FIXME: + // Surfaceflinger may hold onto the previous overlay reference for some + // time after we try to destroy it. retry a few times. In the future, we + // should make the destroy call block, or possibly specify that we can + // wait in the createOverlay call if the previous overlay is in the + // process of being destroyed. + for (int retry = 0; retry < 50; ++retry) { + mOverlayRef = mSurface->createOverlay(w, h, OVERLAY_FORMAT_DEFAULT); + if (mOverlayRef != NULL) break; + LOGD("Overlay create failed - retrying"); + usleep(20000); + } if ( mOverlayRef.get() == NULL ) { LOGE("Overlay Creation Failed!"); |