Monado OpenXR Runtime
target_instance_parts.h
Go to the documentation of this file.
1// Copyright 2020-2024, Collabora, Ltd.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Shared default implementation of the instance: pieces that are used
6 * whether or not there's a compositor.
7 * @author Jakob Bornecrantz <jakob@collabora.com>
8 * @author Rylie Pavlik <rylie.pavlik@collabora.com>
9 */
10#pragma once
11
12#include "target_lists.h"
13
14#include "xrt/xrt_prober.h"
15#include "xrt/xrt_instance.h"
16#include "xrt/xrt_config_os.h"
17#ifdef XRT_OS_ANDROID
18#include "xrt/xrt_android.h"
19#endif // XRT_OS_ANDROID
20
21#include "util/u_misc.h"
22#include "util/u_trace_marker.h"
23
24#ifdef XRT_OS_ANDROID
26#endif
27
28/*
29 *
30 * Struct and helpers.
31 *
32 */
33
34/*!
35 * Main "real" instance implementation.
36 *
37 * Used in instances both with and without compositor usage.
38 *
39 * @implements xrt_instance
40 */
42{
43 struct xrt_instance base;
44 struct xrt_prober *xp;
45#ifdef XRT_OS_ANDROID
46 struct android_instance_base android;
47#endif
48};
49
50static inline struct t_instance *
51t_instance(struct xrt_instance *xinst)
52{
53 return (struct t_instance *)xinst;
54}
55
56
57/*
58 *
59 * Member functions.
60 *
61 */
62
63static xrt_result_t
64t_instance_get_prober(struct xrt_instance *xinst, struct xrt_prober **out_xp)
65{
66 XRT_TRACE_MARKER();
67
68 struct t_instance *tinst = t_instance(xinst);
69
70 if (tinst->xp == NULL) {
72 }
73
74 *out_xp = tinst->xp;
75
76 return XRT_SUCCESS;
77}
78
79static void
80t_instance_destroy(struct xrt_instance *xinst)
81{
82 XRT_TRACE_MARKER();
83
84 struct t_instance *tinst = t_instance(xinst);
85
86 xrt_prober_destroy(&tinst->xp);
87
88#ifdef XRT_OS_ANDROID
89 android_instance_base_cleanup(&tinst->android, xinst);
90#endif // XRT_OS_ANDROID
91
92 free(tinst);
93}
Base implementation of the xrt_instance_android interface.
enum xrt_result xrt_result_t
Result type used across Monado.
@ XRT_ERROR_PROBER_NOT_SUPPORTED
The prober list has not been locked before this call.
Definition: xrt_results.h:133
@ XRT_SUCCESS
The operation succeeded.
Definition: xrt_results.h:26
A basic implementation of the xrt_instance_android interface, a platform-specific "aspect" of xrt_ins...
Definition: android_instance_base.h:33
void android_instance_base_cleanup(struct android_instance_base *aib, struct xrt_instance *xinst)
Release resources owned by android_instance_base and unsets the aspect pointer.
Definition: android_instance_base.c:150
Main "real" instance implementation.
Definition: target_instance_parts.h:42
This interface acts as a root object for Monado.
Definition: xrt_instance.h:114
The main prober that probes and manages found but not opened HMD devices that are connected to the sy...
Definition: xrt_prober.h:132
static void xrt_prober_destroy(struct xrt_prober **xp_ptr)
Destroy the prober and set the pointer to null.
Definition: xrt_prober.h:505
Common things to pull into a target.
Very small misc utils.
Tracing support code, see Tracing support.
Header holding Android-specific details.
Auto detect OS and certain features.
Header for xrt_instance object.
Common interface to probe for devices.