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// SPDX-License-Identifier: BSL-1.0
4/*!
5 * @file
6 * @brief The objects that handle session running status and blocking of xrWaitFrame.
7 * @author Jakob Bornecrantz <jakob@collabora.com>
8 * @author Rylie Pavlik <rylie.pavlik@collabora.com>
9 * @author Yulou Liu <quic_yuloliu@quicinc.com>
10 * @ingroup oxr_main
11 */
12
13#pragma once
14
15#include "xrt/xrt_compiler.h"
16#include "xrt/xrt_config_os.h"
18
19#include <stdbool.h>
20
21#if defined(XRT_OS_LINUX) || defined(XRT_OS_WINDOWS)
22#include <pthread.h>
23#include <assert.h>
24#else
25#error "OS not supported"
26#endif
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32/*!
33 * Helper that handles synchronizing the xr{Wait,Begin,End}Frame calls.
34 */
36{
37 pthread_mutex_t mutex;
38 pthread_cond_t cond;
39
40 bool canWaitFrameReturn;
41 bool initialized;
42 bool running;
43};
44
45/*!
46 * Initialize the frame sync helper.
47 *
48 * @public @memberof oxr_frame_sync
49 */
50int
52
53/*!
54 * Handle mutual exclusion in xrWaitFrame w.r.t. xrBeginFrame
55 *
56 * @public @memberof oxr_frame_sync
57 */
58XRT_CHECK_RESULT XrResult
60
61/*!
62 * Release at most one blocked xrWaitFrame to run, e.g. from xrBeginFrame.
63 *
64 * @public @memberof oxr_frame_sync
65 */
66XRT_CHECK_RESULT XrResult
68
69/*!
70 * Begin the session, resetting state accordingly.
71 *
72 * @public @memberof oxr_frame_sync
73 */
74XRT_CHECK_RESULT XrResult
76
77/*!
78 * End the session
79 *
80 * @public @memberof oxr_frame_sync
81 */
82XRT_CHECK_RESULT XrResult
84
85/*!
86 * Is the session running?.
87 *
88 * @public @memberof oxr_frame_sync
89 */
90XRT_CHECK_RESULT bool
92
93/*!
94 * Clean up.
95 *
96 * @public @memberof oxr_frame_sync
97 */
98void
100
101#ifdef __cplusplus
102} // extern "C"
103#endif
Helper that handles synchronizing the xr{Wait,Begin,End}Frame calls.
Definition: oxr_frame_sync.h:36
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.