diff options
author | Vladimir Chtchetkine <vchtchetkine@google.com> | 2011-09-14 06:55:16 -0700 |
---|---|---|
committer | Vladimir Chtchetkine <vchtchetkine@google.com> | 2011-09-14 07:00:22 -0700 |
commit | ce31fbc48a43ea4265be1d20f157e8749b3e11dd (patch) | |
tree | a711050ab6fc153ccbf60ae8af78a65ac50a3445 /android/camera | |
parent | ae0d8136ce0d3c39ca80c64763e633b86b0c5453 (diff) | |
download | external_qemu-ce31fbc48a43ea4265be1d20f157e8749b3e11dd.zip external_qemu-ce31fbc48a43ea4265be1d20f157e8749b3e11dd.tar.gz external_qemu-ce31fbc48a43ea4265be1d20f157e8749b3e11dd.tar.bz2 |
Fixes "stop device" issue on Linux
Apparently, video driver doesn't allow frame size change, once it has been
explicitly set. In order to get around this we need to reset the handle to the
camera device by closing, and then reopening it.
Change-Id: Icfd37b3c196d2643507218b965c5015884ed455b
Diffstat (limited to 'android/camera')
-rw-r--r-- | android/camera/camera-capture-linux.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/android/camera/camera-capture-linux.c b/android/camera/camera-capture-linux.c index 5c7e242..072d06e 100644 --- a/android/camera/camera-capture-linux.c +++ b/android/camera/camera-capture-linux.c @@ -808,6 +808,10 @@ camera_device_start_capturing(CameraDevice* ccd, return -1; } cd = (LinuxCameraDevice*)ccd->opaque; + if (cd->handle < 0) { + E("%s: Camera device is not opened", __FUNCTION__); + return -1; + } /* Try to set pixel format with the given dimensions. */ CLEAR(fmt); @@ -890,6 +894,10 @@ camera_device_stop_capturing(CameraDevice* ccd) return -1; } cd = (LinuxCameraDevice*)ccd->opaque; + if (cd->handle < 0) { + E("%s: Camera device is not opened", __FUNCTION__); + return -1; + } switch (cd->io_type) { case CAMERA_IO_DIRECT: @@ -916,6 +924,13 @@ camera_device_stop_capturing(CameraDevice* ccd) cd->framebuffers = NULL; cd->framebuffer_num = 0; } + + /* Reopen the device to reset its internal state. It seems that if we don't + * do that, an attempt to reinit the device with different frame dimensions + * would fail. */ + close(cd->handle); + cd->handle = open(cd->device_name, O_RDWR | O_NONBLOCK, 0); + return 0; } @@ -932,6 +947,10 @@ camera_device_read_frame(CameraDevice* ccd, return -1; } cd = (LinuxCameraDevice*)ccd->opaque; + if (cd->handle < 0) { + E("%s: Camera device is not opened", __FUNCTION__); + return -1; + } if (cd->io_type == CAMERA_IO_DIRECT) { /* Read directly from the device. */ |