| 1 | // Copyright 2024, Collabora, Ltd.cxx . . $ `<file>/src/xrt/state_trackers/oxr/oxr_frame_sync.h`/ |
| 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 <[email protected]> |
| 8 | * @author Rylie Pavlik <[email protected]> |
| 9 | * @author Yulou Liu <[email protected]> |
| 10 | * @ingroup oxr_main |
| 11 | */ |
| 12 | |
| 13 | #pragma once |
| 14 | |
| 15 | #include "xrt/xrt_compiler.h"cxx . . $ `<file>/src/xrt/include/xrt/xrt_compiler.h`/ |
| 16 | #include "xrt/xrt_config_os.h"cxx . . $ `<file>/src/xrt/include/xrt/xrt_config_os.h`/ |
| 17 | #include "xrt/xrt_openxr_includes.h"cxx . . $ `<file>/src/xrt/include/xrt/xrt_openxr_includes.h`/ |
| 18 | |
| 19 | #include <stdbool.h> |
| 20 | |
| 21 | #if defined(XRT_OS_LINUXcxx . . $ `src/xrt/include/xrt/xrt_config_os.h:31:9`!) || 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 |
| 29 | extern "C" { |
| 30 | #endif |
| 31 | |
| 32 | /*! |
| 33 | * Helper that handles synchronizing the xr{Wait,Begin,End}Frame calls. |
| 34 | */ |
| 35 | struct oxr_frame_synccxx . . $ oxr_frame_sync# |
| 36 | { |
| 37 | pthread_mutex_tcxx . . $ pthread_mutex_t# mutexcxx . . $ oxr_frame_sync#mutex.; |
| 38 | pthread_cond_tcxx . . $ pthread_cond_t# condcxx . . $ oxr_frame_sync#cond.; |
| 39 | |
| 40 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! canWaitFrameReturncxx . . $ oxr_frame_sync#canWaitFrameReturn.; |
| 41 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! initializedcxx . . $ oxr_frame_sync#initialized.; |
| 42 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! runningcxx . . $ oxr_frame_sync#running.; |
| 43 | }; |
| 44 | |
| 45 | /*! |
| 46 | * Initialize the frame sync helper. |
| 47 | * |
| 48 | * @public @memberof oxr_frame_sync |
| 49 | */ |
| 50 | int |
| 51 | oxr_frame_sync_initcxx . . $ oxr_frame_sync_init(e475838360fe89e9).(struct oxr_frame_synccxx . . $ oxr_frame_sync# *ofs); |
| 52 | |
| 53 | /*! |
| 54 | * Handle mutual exclusion in xrWaitFrame w.r.t. xrBeginFrame |
| 55 | * |
| 56 | * @public @memberof oxr_frame_sync |
| 57 | */ |
| 58 | XRT_CHECK_RESULTcxx . . $ `src/xrt/include/xrt/xrt_compiler.h:65:9`! XrResultcxx . . $ XrResult# |
| 59 | oxr_frame_sync_wait_framecxx . . $ oxr_frame_sync_wait_frame(8b5218ec641f639a).(struct oxr_frame_synccxx . . $ oxr_frame_sync# *ofs); |
| 60 | |
| 61 | /*! |
| 62 | * Release at most one blocked xrWaitFrame to run, e.g. from xrBeginFrame. |
| 63 | * |
| 64 | * @public @memberof oxr_frame_sync |
| 65 | */ |
| 66 | XRT_CHECK_RESULTcxx . . $ `src/xrt/include/xrt/xrt_compiler.h:65:9`! XrResultcxx . . $ XrResult# |
| 67 | oxr_frame_sync_releasecxx . . $ oxr_frame_sync_release(8b5218ec641f639a).(struct oxr_frame_synccxx . . $ oxr_frame_sync# *ofs); |
| 68 | |
| 69 | /*! |
| 70 | * Begin the session, resetting state accordingly. |
| 71 | * |
| 72 | * @public @memberof oxr_frame_sync |
| 73 | */ |
| 74 | XRT_CHECK_RESULTcxx . . $ `src/xrt/include/xrt/xrt_compiler.h:65:9`! XrResultcxx . . $ XrResult# |
| 75 | oxr_frame_sync_begin_sessioncxx . . $ oxr_frame_sync_begin_session(8b5218ec641f639a).(struct oxr_frame_synccxx . . $ oxr_frame_sync# *ofs); |
| 76 | |
| 77 | /*! |
| 78 | * End the session |
| 79 | * |
| 80 | * @public @memberof oxr_frame_sync |
| 81 | */ |
| 82 | XRT_CHECK_RESULTcxx . . $ `src/xrt/include/xrt/xrt_compiler.h:65:9`! XrResultcxx . . $ XrResult# |
| 83 | oxr_frame_sync_end_sessioncxx . . $ oxr_frame_sync_end_session(8b5218ec641f639a).(struct oxr_frame_synccxx . . $ oxr_frame_sync# *ofs); |
| 84 | |
| 85 | /*! |
| 86 | * Is the session running?. |
| 87 | * |
| 88 | * @public @memberof oxr_frame_sync |
| 89 | */ |
| 90 | XRT_CHECK_RESULTcxx . . $ `src/xrt/include/xrt/xrt_compiler.h:65:9`! boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! |
| 91 | oxr_frame_sync_is_session_runningcxx . . $ oxr_frame_sync_is_session_running(4d892923231a012a).(struct oxr_frame_synccxx . . $ oxr_frame_sync# *ofs); |
| 92 | |
| 93 | /*! |
| 94 | * Clean up. |
| 95 | * |
| 96 | * @public @memberof oxr_frame_sync |
| 97 | */ |
| 98 | void |
| 99 | oxr_frame_sync_finicxx . . $ oxr_frame_sync_fini(2c32981b159fdd2d).(struct oxr_frame_synccxx . . $ oxr_frame_sync# *ofs); |
| 100 | |
| 101 | #ifdef __cplusplus |
| 102 | } // extern "C" |
| 103 | #endif |