ipc: Use check helpers in other client code as well

This commit is contained in:
Jakob Bornecrantz 2023-11-13 18:02:03 +00:00
parent bfaf615d4f
commit 83b77285bd
3 changed files with 70 additions and 74 deletions

View file

@ -77,10 +77,8 @@ ipc_client_device_update_inputs(struct xrt_device *xdev)
{ {
ipc_client_device_t *icd = ipc_client_device(xdev); ipc_client_device_t *icd = ipc_client_device(xdev);
xrt_result_t r = ipc_call_device_update_input(icd->ipc_c, icd->device_id); xrt_result_t xret = ipc_call_device_update_input(icd->ipc_c, icd->device_id);
if (r != XRT_SUCCESS) { IPC_CHK_ONLY_PRINT(icd->ipc_c, xret, "ipc_call_device_update_input");
IPC_ERROR(icd->ipc_c, "Error sending input update!");
}
} }
static void static void
@ -91,14 +89,16 @@ ipc_client_device_get_tracked_pose(struct xrt_device *xdev,
{ {
ipc_client_device_t *icd = ipc_client_device(xdev); ipc_client_device_t *icd = ipc_client_device(xdev);
xrt_result_t r = xrt_result_t xret = ipc_call_device_get_tracked_pose( //
ipc_call_device_get_tracked_pose(icd->ipc_c, icd->device_id, name, at_timestamp_ns, out_relation); icd->ipc_c, //
if (r != XRT_SUCCESS) { icd->device_id, //
IPC_ERROR(icd->ipc_c, "Error sending input update!"); name, //
} at_timestamp_ns, //
out_relation); //
IPC_CHK_ONLY_PRINT(icd->ipc_c, xret, "ipc_call_device_get_tracked_pose");
} }
void static void
ipc_client_device_get_hand_tracking(struct xrt_device *xdev, ipc_client_device_get_hand_tracking(struct xrt_device *xdev,
enum xrt_input_name name, enum xrt_input_name name,
uint64_t at_timestamp_ns, uint64_t at_timestamp_ns,
@ -107,11 +107,14 @@ ipc_client_device_get_hand_tracking(struct xrt_device *xdev,
{ {
ipc_client_device_t *icd = ipc_client_device(xdev); ipc_client_device_t *icd = ipc_client_device(xdev);
xrt_result_t r = ipc_call_device_get_hand_tracking(icd->ipc_c, icd->device_id, name, at_timestamp_ns, out_value, xrt_result_t xret = ipc_call_device_get_hand_tracking( //
out_timestamp_ns); icd->ipc_c, //
if (r != XRT_SUCCESS) { icd->device_id, //
IPC_ERROR(icd->ipc_c, "Error sending input update!"); name, //
} at_timestamp_ns, //
out_value, //
out_timestamp_ns); //
IPC_CHK_ONLY_PRINT(icd->ipc_c, xret, "ipc_call_device_get_hand_tracking");
} }
static void static void
@ -132,10 +135,8 @@ ipc_client_device_set_output(struct xrt_device *xdev, enum xrt_output_name name,
{ {
ipc_client_device_t *icd = ipc_client_device(xdev); ipc_client_device_t *icd = ipc_client_device(xdev);
xrt_result_t r = ipc_call_device_set_output(icd->ipc_c, icd->device_id, name, value); xrt_result_t xret = ipc_call_device_set_output(icd->ipc_c, icd->device_id, name, value);
if (r != XRT_SUCCESS) { IPC_CHK_ONLY_PRINT(icd->ipc_c, xret, "ipc_call_device_set_output");
IPC_ERROR(icd->ipc_c, "Error sending set output!");
}
} }
/*! /*!

View file

@ -69,7 +69,7 @@ call_get_view_poses_raw(ipc_client_hmd_t *ich,
struct xrt_pose *out_poses) struct xrt_pose *out_poses)
{ {
struct ipc_connection *ipc_c = ich->ipc_c; struct ipc_connection *ipc_c = ich->ipc_c;
xrt_result_t xret = XRT_SUCCESS; xrt_result_t xret;
ipc_client_connection_lock(ipc_c); ipc_client_connection_lock(ipc_c);
@ -80,9 +80,7 @@ call_get_view_poses_raw(ipc_client_hmd_t *ich,
default_eye_relation, // default_eye_relation, //
at_timestamp_ns, // at_timestamp_ns, //
view_count); // view_count); //
if (xret != XRT_SUCCESS) { IPC_CHK_WITH_GOTO(ich->ipc_c, xret, "ipc_send_device_get_view_poses_locked", out);
goto out;
}
// This is the data we get back in the provided reply. // This is the data we get back in the provided reply.
uint32_t returned_view_count = 0; uint32_t returned_view_count = 0;
@ -93,9 +91,7 @@ call_get_view_poses_raw(ipc_client_hmd_t *ich,
ipc_c, // ipc_c, //
&head_relation, // &head_relation, //
&returned_view_count); // &returned_view_count); //
if (xret != XRT_SUCCESS) { IPC_CHK_WITH_GOTO(ich->ipc_c, xret, "ipc_receive_device_get_view_poses_locked", out);
goto out;
}
if (view_count != returned_view_count) { if (view_count != returned_view_count) {
IPC_ERROR(ich->ipc_c, "Wrong view counts (sent: %u != got: %u)", view_count, returned_view_count); IPC_ERROR(ich->ipc_c, "Wrong view counts (sent: %u != got: %u)", view_count, returned_view_count);
@ -104,15 +100,11 @@ call_get_view_poses_raw(ipc_client_hmd_t *ich,
// We can read directly to the output variables. // We can read directly to the output variables.
xret = ipc_receive(&ipc_c->imc, out_fovs, sizeof(struct xrt_fov) * view_count); xret = ipc_receive(&ipc_c->imc, out_fovs, sizeof(struct xrt_fov) * view_count);
if (xret != XRT_SUCCESS) { IPC_CHK_WITH_GOTO(ich->ipc_c, xret, "ipc_receive(1)", out);
goto out;
}
// We can read directly to the output variables. // We can read directly to the output variables.
xret = ipc_receive(&ipc_c->imc, out_poses, sizeof(struct xrt_pose) * view_count); xret = ipc_receive(&ipc_c->imc, out_poses, sizeof(struct xrt_pose) * view_count);
if (xret != XRT_SUCCESS) { IPC_CHK_WITH_GOTO(ich->ipc_c, xret, "ipc_receive(2)", out);
goto out;
}
/* /*
* Finally set the head_relation that we got in the reply, mostly to * Finally set the head_relation that we got in the reply, mostly to
@ -152,10 +144,8 @@ ipc_client_hmd_update_inputs(struct xrt_device *xdev)
{ {
ipc_client_hmd_t *ich = ipc_client_hmd(xdev); ipc_client_hmd_t *ich = ipc_client_hmd(xdev);
xrt_result_t r = ipc_call_device_update_input(ich->ipc_c, ich->device_id); xrt_result_t xret = ipc_call_device_update_input(ich->ipc_c, ich->device_id);
if (r != XRT_SUCCESS) { IPC_CHK_ONLY_PRINT(ich->ipc_c, xret, "ipc_call_device_update_input");
IPC_ERROR(ich->ipc_c, "Error calling input update!");
}
} }
static void static void
@ -165,12 +155,15 @@ ipc_client_hmd_get_tracked_pose(struct xrt_device *xdev,
struct xrt_space_relation *out_relation) struct xrt_space_relation *out_relation)
{ {
ipc_client_hmd_t *ich = ipc_client_hmd(xdev); ipc_client_hmd_t *ich = ipc_client_hmd(xdev);
xrt_result_t xret;
xrt_result_t r = xret = ipc_call_device_get_tracked_pose( //
ipc_call_device_get_tracked_pose(ich->ipc_c, ich->device_id, name, at_timestamp_ns, out_relation); ich->ipc_c, //
if (r != XRT_SUCCESS) { ich->device_id, //
IPC_ERROR(ich->ipc_c, "Error calling tracked pose!"); name, //
} at_timestamp_ns, //
out_relation); //
IPC_CHK_ONLY_PRINT(ich->ipc_c, xret, "ipc_call_device_get_tracked_pose");
} }
static void static void
@ -183,20 +176,19 @@ ipc_client_hmd_get_view_poses(struct xrt_device *xdev,
struct xrt_pose *out_poses) struct xrt_pose *out_poses)
{ {
ipc_client_hmd_t *ich = ipc_client_hmd(xdev); ipc_client_hmd_t *ich = ipc_client_hmd(xdev);
xrt_result_t xret;
struct ipc_info_get_view_poses_2 info = {0}; struct ipc_info_get_view_poses_2 info = {0};
if (view_count == 2) { if (view_count == 2) {
// Fast path. // Fast path.
xrt_result_t r = ipc_call_device_get_view_poses_2( // xret = ipc_call_device_get_view_poses_2( //
ich->ipc_c, // ich->ipc_c, //
ich->device_id, // ich->device_id, //
default_eye_relation, // default_eye_relation, //
at_timestamp_ns, // at_timestamp_ns, //
&info); // &info); //
if (r != XRT_SUCCESS) { IPC_CHK_ONLY_PRINT(ich->ipc_c, xret, "ipc_call_device_get_view_poses_2");
IPC_ERROR(ich->ipc_c, "Error calling view poses!");
}
*out_head_relation = info.head_relation; *out_head_relation = info.head_relation;
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
@ -227,20 +219,18 @@ ipc_client_hmd_compute_distortion(
struct xrt_device *xdev, uint32_t view, float u, float v, struct xrt_uv_triplet *out_result) struct xrt_device *xdev, uint32_t view, float u, float v, struct xrt_uv_triplet *out_result)
{ {
ipc_client_hmd_t *ich = ipc_client_hmd(xdev); ipc_client_hmd_t *ich = ipc_client_hmd(xdev);
xrt_result_t xret;
bool ret; bool ret;
xrt_result_t xret = ipc_call_device_compute_distortion( // xret = ipc_call_device_compute_distortion( //
ich->ipc_c, // ich->ipc_c, //
ich->device_id, // ich->device_id, //
view, // view, //
u, // u, //
v, // v, //
&ret, // &ret, //
out_result); // out_result); //
if (xret != XRT_SUCCESS) { IPC_CHK_WITH_RET(ich->ipc_c, xret, "ipc_call_device_compute_distortion", false);
IPC_ERROR(ich->ipc_c, "Error calling compute distortion!");
return false;
}
return ret; return ret;
} }
@ -249,11 +239,16 @@ static bool
ipc_client_hmd_is_form_factor_available(struct xrt_device *xdev, enum xrt_form_factor form_factor) ipc_client_hmd_is_form_factor_available(struct xrt_device *xdev, enum xrt_form_factor form_factor)
{ {
ipc_client_hmd_t *ich = ipc_client_hmd(xdev); ipc_client_hmd_t *ich = ipc_client_hmd(xdev);
xrt_result_t xret;
bool available = false; bool available = false;
xrt_result_t r = ipc_call_device_is_form_factor_available(ich->ipc_c, ich->device_id, form_factor, &available); xret = ipc_call_device_is_form_factor_available( //
if (r != XRT_SUCCESS) { ich->ipc_c, //
IPC_ERROR(ich->ipc_c, "Error calling is available!"); ich->device_id, //
} form_factor, //
&available); //
IPC_CHK_ONLY_PRINT(ich->ipc_c, xret, "ipc_call_device_is_form_factor_available");
return available; return available;
} }

View file

@ -95,9 +95,7 @@ create_offset_space(struct xrt_space_overseer *xso,
uint32_t id = 0; uint32_t id = 0;
xret = ipc_call_space_create_offset(icspo->ipc_c, parent_id, offset, &id); xret = ipc_call_space_create_offset(icspo->ipc_c, parent_id, offset, &id);
if (xret != XRT_SUCCESS) { IPC_CHK_AND_RET(icspo->ipc_c, xret, "ipc_call_space_create_offset");
return xret;
}
alloc_space_with_id(icspo, id, out_space); alloc_space_with_id(icspo, id, out_space);
@ -116,9 +114,7 @@ create_pose_space(struct xrt_space_overseer *xso,
uint32_t id = 0; uint32_t id = 0;
xret = ipc_call_space_create_pose(icspo->ipc_c, xdev_id, name, &id); xret = ipc_call_space_create_pose(icspo->ipc_c, xdev_id, name, &id);
if (xret != XRT_SUCCESS) { IPC_CHK_AND_RET(icspo->ipc_c, xret, "ipc_call_space_create_pose");
return xret;
}
alloc_space_with_id(icspo, id, out_space); alloc_space_with_id(icspo, id, out_space);
@ -135,11 +131,12 @@ locate_space(struct xrt_space_overseer *xso,
struct xrt_space_relation *out_relation) struct xrt_space_relation *out_relation)
{ {
struct ipc_client_space_overseer *icspo = ipc_client_space_overseer(xso); struct ipc_client_space_overseer *icspo = ipc_client_space_overseer(xso);
xrt_result_t xret;
struct ipc_client_space *icsp_base_space = ipc_client_space(base_space); struct ipc_client_space *icsp_base_space = ipc_client_space(base_space);
struct ipc_client_space *icsp_space = ipc_client_space(space); struct ipc_client_space *icsp_space = ipc_client_space(space);
return ipc_call_space_locate_space( // xret = ipc_call_space_locate_space( //
icspo->ipc_c, // icspo->ipc_c, //
icsp_base_space->id, // icsp_base_space->id, //
base_offset, // base_offset, //
@ -147,6 +144,7 @@ locate_space(struct xrt_space_overseer *xso,
icsp_space->id, // icsp_space->id, //
offset, // offset, //
out_relation); // out_relation); //
IPC_CHK_ALWAYS_RET(icspo->ipc_c, xret, "ipc_call_space_locate_space");
} }
static xrt_result_t static xrt_result_t
@ -158,17 +156,19 @@ locate_device(struct xrt_space_overseer *xso,
struct xrt_space_relation *out_relation) struct xrt_space_relation *out_relation)
{ {
struct ipc_client_space_overseer *icspo = ipc_client_space_overseer(xso); struct ipc_client_space_overseer *icspo = ipc_client_space_overseer(xso);
xrt_result_t xret;
struct ipc_client_space *icsp_base_space = ipc_client_space(base_space); struct ipc_client_space *icsp_base_space = ipc_client_space(base_space);
uint32_t xdev_id = ipc_client_xdev(xdev)->device_id; uint32_t xdev_id = ipc_client_xdev(xdev)->device_id;
return ipc_call_space_locate_device( // xret = ipc_call_space_locate_device( //
icspo->ipc_c, // icspo->ipc_c, //
icsp_base_space->id, // icsp_base_space->id, //
base_offset, // base_offset, //
at_timestamp_ns, // at_timestamp_ns, //
xdev_id, // xdev_id, //
out_relation); // out_relation); //
IPC_CHK_ALWAYS_RET(icspo->ipc_c, xret, "ipc_call_space_locate_device");
} }
static void static void