From 27db785d781822af7376a9e65a48dc1b5956ff40 Mon Sep 17 00:00:00 2001 From: MarcKe Date: Sun, 1 Feb 2015 11:29:01 +0100 Subject: Fix crash when switching between cameras Conflicts: camera/exynos_camera.c Change-Id: I38b41feb4d0880b32fa847a907f50a7c2dc95cd6 --- camera/exynos_camera.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/camera/exynos_camera.c b/camera/exynos_camera.c index 8501bea..3021ff5 100644 --- a/camera/exynos_camera.c +++ b/camera/exynos_camera.c @@ -2364,10 +2364,14 @@ int exynos_camera_preview(struct exynos_camera *exynos_camera) } if (exynos_camera->preview_window != NULL && exynos_camera->gralloc != NULL) { - exynos_camera->preview_window->dequeue_buffer(exynos_camera->preview_window, &window_buffer, &window_stride); - exynos_camera->gralloc->lock(exynos_camera->gralloc, *window_buffer, GRALLOC_USAGE_SW_WRITE_OFTEN, 0, 0, width, height, &window_data); + int ret = exynos_camera->preview_window->dequeue_buffer(exynos_camera->preview_window, &window_buffer, &window_stride); + if (ret < 0) { + ALOGE("%s: Error in dequeueing buffer", __func__); + goto error; + } + ret = exynos_camera->gralloc->lock(exynos_camera->gralloc, *window_buffer, GRALLOC_USAGE_YUV_ADDR | GRALLOC_USAGE_SW_WRITE_OFTEN, 0, 0, width, height, &window_data); - if (window_data == NULL) { + if (window_data == NULL || ret == -EINVAL) { ALOGE("%s: Unable to lock gralloc", __func__); goto error; } -- cgit v1.1