Monado OpenXR Runtime
u_session.h
Go to the documentation of this file.
1// Copyright 2023, Collabora, Ltd.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Helper to implement @ref xrt_session.
6 * @author Jakob Bornecrantz <jakob@collabora.com>
7 * @ingroup aux_util
8 */
9
10#include "xrt/xrt_session.h"
11#include "os/os_threading.h"
12
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18
19/*!
20 * Struct used by @ref u_session to queue up events.
21 *
22 * @ingroup aux_util
23 */
25{
26 union xrt_session_event xse;
27 struct u_session_event *next;
28};
29
30/*!
31 * This is a helper struct that fully implements @ref xrt_session object.
32 *
33 * The use of @ref u_system is optional, but if not used you will need to track
34 * the session and signal it's destruction yourself.
35 *
36 * @ingroup aux_util
37 * @implements xrt_session
38 */
40{
41 struct xrt_session base;
42
43 //! Pushes events to this session, used to share to other components.
45
46 //! Owning system, optional.
47 struct u_system *usys;
48
49 struct
50 {
51 struct os_mutex mutex;
52 struct u_session_event *ptr;
53 } events;
54};
55
56/*!
57 * Create a session, optionally pass in a @ref u_system. If @p usys is not NULL
58 * the call register this session on that system. This function is exposed so
59 * that code can reuse @ref u_session as a base class.
60 *
61 * @public @memberof u_session
62 * @ingroup aux_util
63 */
64struct u_session *
66
67/*!
68 * Push an event to this session. This function is exposed so that code can
69 * reuse @ref u_session as a base class.
70 *
71 *
72 * @public @memberof u_session
73 * @ingroup aux_util
74 */
75void
76u_session_event_push(struct u_session *us, const union xrt_session_event *xse);
77
78/*!
79 * Pop a single event from this session, if no event is available
80 * then the type of the event will be @ref XRT_SESSION_EVENT_NONE.
81 *
82 * @public @memberof u_session
83 * @ingroup aux_util
84 */
85void
86u_session_event_pop(struct u_session *us, union xrt_session_event *out_xse);
87
88
89#ifdef __cplusplus
90}
91#endif
void u_session_event_pop(struct u_session *us, union xrt_session_event *out_xse)
Pop a single event from this session, if no event is available then the type of the event will be XRT...
Definition: u_session.c:117
void u_session_event_push(struct u_session *us, const union xrt_session_event *xse)
Push an event to this session.
Definition: u_session.c:98
struct u_session * u_session_create(struct u_system *usys)
Create a session, optionally pass in a u_system.
Definition: u_session.c:73
Wrapper around OS threading native functions.
A wrapper around a native mutex.
Definition: os_threading.h:55
Struct used by u_session to queue up events.
Definition: u_session.h:25
This is a helper struct that fully implements xrt_session object.
Definition: u_session.h:40
struct xrt_session_event_sink sink
Pushes events to this session, used to share to other components.
Definition: u_session.h:44
struct u_system * usys
Owning system, optional.
Definition: u_session.h:47
A helper to implement a xrt_system, takes care of multiplexing events to sessions.
Definition: u_system.h:43
Used internally from producers of events to push events into session, some sinks might multiplex even...
Definition: xrt_session.h:206
The XRT representation of XrSession, this object does not have all of the functionality of a session,...
Definition: xrt_session.h:246
Union of all session events, used to return multiple events through one call.
Definition: xrt_session.h:186
Header for session object.