[FIX] ZM 1.24.2 "Error, failed to query crop"
Posted: Wed Feb 10, 2010 3:47 am
A USB camera that doesn't support cropping will produce an error message "Error, failed to query crop: /dev/video0: Invalid argument" from zmu -q -v.
Failures are exhibited in zmu, and other places that rely on LocalCamera::GetCurrentSettings.
The fault is in LocalCamera::GetCurrentSettings.
The error arises from the fact that ioctl VIDIOC_G_CROP returns -1 and errno = EINVAL to indicate that cropping is not supported. (See http://v4l2spec.bytesex.org/spec/r9994.htm). LocalCamera::GetCurrentSettings treats any negative rc from ioctl VIDIOC_G_CROP as grounds for abnormal termination.
The fix is straightforward and short. All changes are in zm_local_camera.cpp as follows:
Failures are exhibited in zmu, and other places that rely on LocalCamera::GetCurrentSettings.
The fault is in LocalCamera::GetCurrentSettings.
The error arises from the fact that ioctl VIDIOC_G_CROP returns -1 and errno = EINVAL to indicate that cropping is not supported. (See http://v4l2spec.bytesex.org/spec/r9994.htm). LocalCamera::GetCurrentSettings treats any negative rc from ioctl VIDIOC_G_CROP as grounds for abnormal termination.
The fix is straightforward and short. All changes are in zm_local_camera.cpp as follows:
Code: Select all
911,912c911
< int crop_rc = vidioctl( vid_fd, VIDIOC_G_CROP, &crop );
< if ((crop_rc < 0 ) && (errno != EINVAL))
---
> if ( vidioctl( vid_fd, VIDIOC_G_CROP, &crop ) < 0 )
921,928c920,921
< if ( verbose ) {
< if (crop_rc >= 0) {
< sprintf( output+strlen(output), " Current: %d x %d\n", crop.c.width, crop.c.height );
< }
< else {
< sprintf( output+strlen(output), " Current: Cropping is not supported\n");
< }
< }
---
> if ( verbose )
> sprintf( output+strlen(output), " Current: %d x %d\n", crop.c.width, crop.c.height );