maru-camera: Fixed an issue that crash or slow down the emulator
authorjinhyung.jo <jinhyung.jo@samsung.com>
Fri, 26 Jun 2015 09:46:55 +0000 (18:46 +0900)
committerJinhyung Jo <jinhyung.jo@samsung.com>
Mon, 29 Jun 2015 05:24:41 +0000 (14:24 +0900)
Removed access to the garbage value that has not been initialized.

Change-Id: Ib71f05656bc59b135fae523f450ae5102e258023
Signed-off-by: Jinhyung Jo <jinhyung.jo@samsung.com>
tizen/src/hw/pci/maru_camera_linux_pci.c

index 406478b..fc32798 100644 (file)
@@ -80,7 +80,7 @@ static int previous_frame_index = -1;
 static struct marucam_framebuffer *framebuffer;
 
 static const char *dev_name = "/dev/video0";
-static int v4l2_fd;
+static int v4l2_fd = -1;
 static int convert_trial;
 static int ready_count;
 static int timeout_n;
@@ -818,6 +818,8 @@ int marucam_device_check(int log_flag)
 void marucam_device_init(MaruCamState *state)
 {
     state->destroying = false;
+    memset(&saved_frame, 0x00, sizeof(saved_frame));
+
     qemu_thread_create(&state->thread_id,
                        MARUCAM_THREAD_NAME,
                        marucam_worker_thread,
@@ -1385,7 +1387,9 @@ void marucam_device_close(MaruCamState *state)
     }
     memset(&saved_frame, 0x00, sizeof(saved_frame));
 
-    v4l2_close(v4l2_fd);
-    v4l2_fd = 0;
+    if (v4l2_fd >= 0) {
+        v4l2_close(v4l2_fd);
+        v4l2_fd = -1;
+    }
     INFO("Closed\n");
 }