Monado OpenXR Runtime
oxr_frame_sync.h
Go to the documentation of this file.
1// Copyright 2024, Collabora, Ltd.
2// Copyright 2024, QUALCOMM CORPORATION.
3// Copyright 2025, NVIDIA CORPORATION.
4// SPDX-License-Identifier: BSL-1.0
5/*!
6 * @file
7 * @brief The objects that handle session running status and blocking of xrWaitFrame.
8 * @author Jakob Bornecrantz <jakob@collabora.com>
9 * @author Rylie Pavlik <rylie.pavlik@collabora.com>
10 * @author Yulou Liu <quic_yuloliu@quicinc.com>
11 * @ingroup oxr_main
12 */
13
14#pragma once
15
16#include "xrt/xrt_compiler.h"
17#include "xrt/xrt_config_os.h"
19
20#include <stdbool.h>
21
22#if defined(XRT_OS_LINUX) || defined(XRT_OS_WINDOWS) || defined(XRT_OS_OSX)
23#include <pthread.h>
24#include <assert.h>
25#else
26#error "OS not supported"
27#endif
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33/*!
34 * Helper that handles synchronizing the xr{Wait,Begin,End}Frame calls.
35 */
37{
38 pthread_mutex_t mutex;
39 pthread_cond_t cond;
40
41 bool canWaitFrameReturn;
42 bool initialized;
43 bool running;
44};
45
46/*!
47 * Initialize the frame sync helper.
48 *
49 * @public @memberof oxr_frame_sync
50 */
51int
53
54/*!
55 * Handle mutual exclusion in xrWaitFrame w.r.t. xrBeginFrame
56 *
57 * @public @memberof oxr_frame_sync
58 */
59XRT_CHECK_RESULT XrResult
61
62/*!
63 * Release at most one blocked xrWaitFrame to run, e.g. from xrBeginFrame.
64 *
65 * @public @memberof oxr_frame_sync
66 */
67XRT_CHECK_RESULT XrResult
69
70/*!
71 * Begin the session, resetting state accordingly.
72 *
73 * @public @memberof oxr_frame_sync
74 */
75XRT_CHECK_RESULT XrResult
77
78/*!
79 * End the session
80 *
81 * @public @memberof oxr_frame_sync
82 */
83XRT_CHECK_RESULT XrResult
85
86/*!
87 * Is the session running?.
88 *
89 * @public @memberof oxr_frame_sync
90 */
91XRT_CHECK_RESULT bool
93
94/*!
95 * Clean up.
96 *
97 * @public @memberof oxr_frame_sync
98 */
99void
101
102#ifdef __cplusplus
103} // extern "C"
104#endif
Helper that handles synchronizing the xr{Wait,Begin,End}Frame calls.
Definition: oxr_frame_sync.h:37
XRT_CHECK_RESULT bool oxr_frame_sync_is_session_running(struct oxr_frame_sync *ofs)
Is the session running?.
Definition: oxr_frame_sync.c:112
XRT_CHECK_RESULT XrResult oxr_frame_sync_wait_frame(struct oxr_frame_sync *ofs)
Handle mutual exclusion in xrWaitFrame w.r.t.
Definition: oxr_frame_sync.c:40
int oxr_frame_sync_init(struct oxr_frame_sync *ofs)
Initialize the frame sync helper.
Definition: oxr_frame_sync.c:18
XRT_CHECK_RESULT XrResult oxr_frame_sync_end_session(struct oxr_frame_sync *ofs)
End the session.
Definition: oxr_frame_sync.c:98
XRT_CHECK_RESULT XrResult oxr_frame_sync_begin_session(struct oxr_frame_sync *ofs)
Begin the session, resetting state accordingly.
Definition: oxr_frame_sync.c:83
XRT_CHECK_RESULT XrResult oxr_frame_sync_release(struct oxr_frame_sync *ofs)
Release at most one blocked xrWaitFrame to run, e.g.
Definition: oxr_frame_sync.c:67
void oxr_frame_sync_fini(struct oxr_frame_sync *ofs)
Clean up.
Definition: oxr_frame_sync.c:121
Header holding common defines.
Auto detect OS and certain features.
Include all of the openxr headers in one place.