android: cameraDevice: Factorize the code of validating camera3_capture_request

CameraDevice::processCaptureRequest() checks the validity of a
provided camera3_capture_request. This factorizes the code in
order to add more validation to the request later.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Hirokazu Honda 2021-04-03 22:37:40 +09:00 committed by Laurent Pinchart
parent d13462f3d0
commit 7633a2d24d

View file

@ -256,6 +256,21 @@ void sortCamera3StreamConfigs(std::vector<Camera3StreamConfig> &unsortedConfigs,
unsortedConfigs = sortedConfigs; unsortedConfigs = sortedConfigs;
} }
bool isValidRequest(camera3_capture_request_t *camera3Request)
{
if (!camera3Request) {
LOG(HAL, Error) << "No capture request provided";
return false;
}
if (!camera3Request->num_output_buffers) {
LOG(HAL, Error) << "No output buffers provided";
return false;
}
return true;
}
} /* namespace */ } /* namespace */
/* /*
@ -1790,15 +1805,8 @@ int CameraDevice::processControls(Camera3RequestDescriptor *descriptor)
int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Request) int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Request)
{ {
if (!camera3Request) { if (!isValidRequest(camera3Request))
LOG(HAL, Error) << "No capture request provided";
return -EINVAL; return -EINVAL;
}
if (!camera3Request->num_output_buffers) {
LOG(HAL, Error) << "No output buffers provided";
return -EINVAL;
}
/* Start the camera if that's the first request we handle. */ /* Start the camera if that's the first request we handle. */
if (!running_) { if (!running_) {