xrt: make get_visibility_mask return xrt_return_t

This commit is contained in:
Simon Zeni 2023-11-14 21:17:00 -05:00 committed by Jakob Bornecrantz
parent 9d2fd53e24
commit 818e519f50
5 changed files with 19 additions and 11 deletions

View file

@ -405,10 +405,10 @@ struct xrt_device
* @param[in] view_index The index of the view to get the mask for.
* @param[out] out_mask Output mask, caller must free.
*/
void (*get_visibility_mask)(struct xrt_device *xdev,
enum xrt_visibility_mask_type type,
uint32_t view_index,
struct xrt_visibility_mask **out_mask);
xrt_result_t (*get_visibility_mask)(struct xrt_device *xdev,
enum xrt_visibility_mask_type type,
uint32_t view_index,
struct xrt_visibility_mask **out_mask);
/*!
* Destroy device.
@ -527,13 +527,13 @@ xrt_device_compute_distortion(
*
* @public @memberof xrt_device
*/
static inline void
static inline xrt_result_t
xrt_device_get_visibility_mask(struct xrt_device *xdev,
enum xrt_visibility_mask_type type,
uint32_t view_index,
struct xrt_visibility_mask **out_mask)
{
xdev->get_visibility_mask(xdev, type, view_index, out_mask);
return xdev->get_visibility_mask(xdev, type, view_index, out_mask);
}
/*!

View file

@ -139,13 +139,14 @@ ipc_client_device_set_output(struct xrt_device *xdev, enum xrt_output_name name,
IPC_CHK_ONLY_PRINT(icd->ipc_c, xret, "ipc_call_device_set_output");
}
static void
static xrt_result_t
ipc_client_device_get_visibility_mask(struct xrt_device *xdev,
enum xrt_visibility_mask_type type,
uint32_t view_index,
struct xrt_visibility_mask **out_mask)
{
assert(false);
return XRT_ERROR_IPC_FAILURE;
}
/*!

View file

@ -252,7 +252,7 @@ ipc_client_hmd_is_form_factor_available(struct xrt_device *xdev, enum xrt_form_f
return available;
}
static void
static xrt_result_t
ipc_client_hmd_get_visibility_mask(struct xrt_device *xdev,
enum xrt_visibility_mask_type type,
uint32_t view_index,
@ -284,12 +284,13 @@ ipc_client_hmd_get_visibility_mask(struct xrt_device *xdev,
*out_mask = mask;
ipc_client_connection_unlock(ipc_c);
return;
return XRT_SUCCESS;
err_mask_free:
free(mask);
err_mask_unlock:
ipc_client_connection_unlock(ipc_c);
return XRT_ERROR_IPC_FAILURE;
}
/*!

View file

@ -1574,7 +1574,11 @@ ipc_handle_device_get_visibility_mask(volatile struct ipc_client_state *ics,
struct xrt_device *xdev = get_xdev(ics, device_id);
struct xrt_visibility_mask *mask = NULL;
if (xdev->get_visibility_mask) {
xrt_device_get_visibility_mask(xdev, type, view_index, &mask);
xret = xrt_device_get_visibility_mask(xdev, type, view_index, &mask);
if (xret != XRT_SUCCESS) {
IPC_ERROR(s, "Failed to get visibility mask");
return xret;
}
} else {
struct xrt_fov fov = xdev->hmd->distortion.fov[view_index];
u_visibility_mask_get_default(type, &fov, &mask);

View file

@ -1183,6 +1183,7 @@ oxr_session_get_visibility_mask(struct oxr_logger *log,
struct oxr_system *sys = sess->sys;
struct xrt_device *xdev = GET_XDEV_BY_ROLE(sess->sys, head);
enum xrt_visibility_mask_type type = convert_mask_type(visibilityMaskType);
xrt_result_t xret;
assert(viewIndex < ARRAY_SIZE(sys->visibility_mask));
@ -1197,7 +1198,8 @@ oxr_session_get_visibility_mask(struct oxr_logger *log,
// If we didn't have any cached mask get it.
if (mask == NULL) {
xrt_device_get_visibility_mask(xdev, type, viewIndex, &mask);
xret = xrt_device_get_visibility_mask(xdev, type, viewIndex, &mask);
OXR_CHECK_XRET(log, sess, xret, get_visibility_mask);
sys->visibility_mask[viewIndex] = mask;
}