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