Monado OpenXR Runtime
Loading...
Searching...
No Matches
oxr_xret.h
Go to the documentation of this file.
1// Copyright 2019-2023, Collabora, Ltd.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief File holding helper for @ref xrt_result_t results.
6 * @author Jakob Bornecrantz <jakob@collabora.com>
7 * @ingroup oxr_main
8 */
9
10#pragma once
11
12#include "xrt/xrt_results.h"
13#include "oxr_objects.h"
14
15
16/*!
17 * Helper define to check results from 'xrt_` functions (@ref xrt_result_t) and
18 * also set any needed state.
19 *
20 * @todo We probably want to invalidate all sessions, not the current.
21 *
22 * @ingroup oxr_main
23 */
24#define OXR_CHECK_XRET(LOG, SESS, RESULTS, FUNCTION) \
25 do { \
26 xrt_result_t check_ret = (RESULTS); \
27 if (check_ret == XRT_ERROR_IPC_FAILURE && (SESS)) { \
28 (SESS)->has_lost = true; \
29 return oxr_error((LOG), XR_ERROR_INSTANCE_LOST, "Call to " #FUNCTION " failed"); \
30 } \
31 if (check_ret != XRT_SUCCESS) { \
32 return oxr_error((LOG), XR_ERROR_RUNTIME_FAILURE, "Call to " #FUNCTION " failed"); \
33 } \
34 } while (false)
35
36#define OXR_CHECK_XRET_ALWAYS_RET(LOG, SESS, RESULTS, FUNCTION) \
37 do { \
38 OXR_CHECK_XRET(LOG, SESS, RESULTS, FUNCTION); \
39 return XR_SUCCESS; \
40 } while (false)
41
42#define OXR_CHECK_XRET_GOTO(LOG, SESS, RESULTS, FUNCTION, XR_RES, GOTO_LABEL) \
43 do { \
44 xrt_result_t check_ret = (RESULTS); \
45 if (check_ret == XRT_ERROR_IPC_FAILURE) { \
46 (SESS)->has_lost = true; \
47 XR_RES = oxr_error(LOG, XR_ERROR_INSTANCE_LOST, "Call to " #FUNCTION " failed"); \
48 goto GOTO_LABEL; \
49 } \
50 if (check_ret != XRT_SUCCESS) { \
51 XR_RES = oxr_error(LOG, XR_ERROR_RUNTIME_FAILURE, "Call to " #FUNCTION " failed"); \
52 goto GOTO_LABEL; \
53 } \
54 } while (false)
The objects representing OpenXR handles, and prototypes for internal functions used in the state trac...
Internal result type for XRT.