Monado OpenXR Runtime
android_instance_base.h
Go to the documentation of this file.
1// Copyright 2023, Qualcomm Innovation Center, Inc.
2// Copyright 2020-2024, Collabora, Ltd.
3// SPDX-License-Identifier: BSL-1.0
4/*!
5 * @file
6 * @brief Base implementation of the @ref xrt_instance_android interface.
7 * @author Jarvis Huang
8 * @author Rylie Pavlik <rylie.pavlik@collabora.com>
9 * @ingroup aux_android
10 */
11#pragma once
12
13#include "xrt/xrt_instance.h"
14#include "xrt/xrt_android.h"
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20struct _JavaVM;
22
23/*!
24 * @brief A basic implementation of the @ref xrt_instance_android interface,
25 * a platform-specific "aspect" of @ref xrt_instance.
26 *
27 * Store nested in your @ref xrt_instance implementation (by value, not separately allocated),
28 * and call @ref android_instance_base_init in your instance creation and
29 * @ref android_instance_base_cleanup in instance destruction.
30 *
31 */
33{
34 struct xrt_instance_android base;
35 struct _JavaVM *vm;
36 void *context;
37 struct android_lifecycle_callbacks *lifecycle_callbacks;
38};
39
40/*!
41 * @brief Initialize resources owned by @p android_instance_base and
42 * sets the @ref xrt_instance::android_instance pointer.
43 *
44 * @param aib The object to initialize.
45 * @param xinst The xrt_instance to update.
46 * @param vm The JavaVM pointer.
47 * @param activity The activity jobject, cast to a void pointer.
48 *
49 * @returns @ref XRT_SUCCESS on success, @ref XRT_ERROR_ALLOCATION if we could not allocate
50 * our required objects, and @ref XRT_ERROR_ANDROID if something goes very wrong with Java/JNI
51 * that should be impossible and likely indicates a logic error in the code.
52 *
53 * @public @memberof android_instance_base
54 */
57 struct xrt_instance *xinst,
58 const struct xrt_instance_info *ii);
59
60/*!
61 * @brief Release resources owned by @ref android_instance_base and unsets the aspect pointer
62 * - but does not free @p aib itself, since it is intended to be held by value.
63 *
64 * @param aib The object to de-initialize.
65 * @param xinst The xrt_instance to update.
66 *
67 * @public @memberof android_instance_base
68 */
69void
71
72#ifdef __cplusplus
73};
74#endif
enum xrt_result xrt_result_t
Result type used across Monado.
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
xrt_result_t android_instance_base_init(struct android_instance_base *aib, struct xrt_instance *xinst, const struct xrt_instance_info *ii)
Initialize resources owned by android_instance_base and sets the xrt_instance::android_instance point...
Definition: android_instance_base.c:91
An object handling a collection of callbacks for the Android lifecycle.
Definition: android_lifecycle_callbacks.cpp:30
Information provided by the application at instance create time.
Definition: xrt_instance.h:88
This interface acts as a root object for Monado.
Definition: xrt_instance.h:114
Header holding Android-specific details.
Header for xrt_instance object.