Change v4l2_wrapper set control to accept null.
User does not need to pass a result pointer if they
don't care about the result.
BUG: 30140438
Change-Id: Ia98870f24df82464a3f00aad63a599063b98f03a
diff --git a/modules/camera/3_4/v4l2_wrapper.cpp b/modules/camera/3_4/v4l2_wrapper.cpp
index bce3200..d331a77 100644
--- a/modules/camera/3_4/v4l2_wrapper.cpp
+++ b/modules/camera/3_4/v4l2_wrapper.cpp
@@ -231,12 +231,19 @@
int32_t* result) {
HAL_LOG_ENTER();
+ // TODO(b/29334616): When async, this may need to check if the stream
+ // is on, and if so, lock it off while setting format. Need to look
+ // into if V4L2 supports adjusting controls while the stream is on.
+
v4l2_control control{control_id, desired};
if (IoctlLocked(VIDIOC_S_CTRL, &control) < 0) {
HAL_LOGE("S_CTRL fails: %s", strerror(errno));
return -ENODEV;
}
- *result = control.value;
+ // If the caller wants to know the result, pass it back.
+ if (result != nullptr) {
+ *result = control.value;
+ }
return 0;
}
diff --git a/modules/camera/3_4/v4l2_wrapper.h b/modules/camera/3_4/v4l2_wrapper.h
index d67b36e..113499a 100644
--- a/modules/camera/3_4/v4l2_wrapper.h
+++ b/modules/camera/3_4/v4l2_wrapper.h
@@ -45,7 +45,8 @@
// Manage controls.
int QueryControl(uint32_t control_id, v4l2_query_ext_ctrl* result);
int GetControl(uint32_t control_id, int32_t* value);
- int SetControl(uint32_t control_id, int32_t desired, int32_t* result);
+ int SetControl(uint32_t control_id, int32_t desired,
+ int32_t* result = nullptr);
// Manage format.
int SetFormat(const default_camera_hal::Stream& stream,
uint32_t* result_max_buffers);