43#define IPC_TRACE(d, ...) U_LOG_IFL_T(d->log_level, __VA_ARGS__)
44#define IPC_DEBUG(d, ...) U_LOG_IFL_D(d->log_level, __VA_ARGS__)
45#define IPC_INFO(d, ...) U_LOG_IFL_I(d->log_level, __VA_ARGS__)
46#define IPC_WARN(d, ...) U_LOG_IFL_W(d->log_level, __VA_ARGS__)
47#define IPC_ERROR(d, ...) U_LOG_IFL_E(d->log_level, __VA_ARGS__)
49#define IPC_CHK_AND_RET(S, ...) U_LOG_CHK_AND_RET((S)->log_level, __VA_ARGS__)
50#define IPC_CHK_WITH_GOTO(S, ...) U_LOG_CHK_WITH_GOTO((S)->log_level, __VA_ARGS__)
51#define IPC_CHK_WITH_RET(S, ...) U_LOG_CHK_WITH_RET((S)->log_level, __VA_ARGS__)
52#define IPC_CHK_ONLY_PRINT(S, ...) U_LOG_CHK_ONLY_PRINT((S)->log_level, __VA_ARGS__)
53#define IPC_CHK_ALWAYS_RET(S, ...) U_LOG_CHK_ALWAYS_RET((S)->log_level, __VA_ARGS__)
62#define IPC_MAX_CLIENT_BODY_TRACKERS 16
63#define IPC_MAX_CLIENT_HAND_TRACKERS 16
64#define IPC_MAX_CLIENT_APP_INSTANCES 4
65#define IPC_MAX_CLIENT_APP_SYSTEMS (IPC_MAX_CLIENT_APP_INSTANCES * 4)
66#define IPC_MAX_CLIENT_IO_CACHES 16
67#define IPC_MAX_CLIENT_SEMAPHORES 8
68#define IPC_MAX_CLIENT_SWAPCHAINS (XRT_MAX_LAYERS * 2)
69#define IPC_MAX_CLIENT_SPACES 128
70#define IPC_MAX_CLIENT_FUTURES 128
213 uint64_t plane_detection_size;
214 uint64_t plane_detection_count;
222 int server_thread_index;
238 volatile enum ipc_thread_state state;
255#if defined(XRT_OS_ANDROID) || defined(XRT_OS_LINUX) || defined(XRT_DOXYGEN)
260#if defined(XRT_OS_ANDROID) || defined(XRT_DOXYGEN)
319#define XRT_IPC_GOT_IMPL
322#if (defined(XRT_OS_LINUX) && !defined(XRT_OS_ANDROID)) || defined(XRT_DOXYGEN)
339#define XRT_IPC_GOT_IMPL
342#if defined(XRT_OS_WINDOWS) || defined(XRT_DOXYGEN)
356#define XRT_IPC_GOT_IMPL
359#ifndef XRT_IPC_GOT_IMPL
381ipc_server_mainloop_init(
struct ipc_server_mainloop *ml,
const char *socket_filename,
bool no_stdin);
404 struct u_debug_gui *debug_gui;
423 volatile bool running;
426 bool exit_on_disconnect;
432 uint64_t last_client_disconnect_ns;
435 uint64_t exit_when_idle_delay_ns;
454 volatile uint32_t current_slot_index;
461 int active_client_index;
462 int last_active_client_index;
465 uint32_t connected_client_count;
498 bool *out_available);
627ipc_server_handle_failure(
struct ipc_server *vs);
636ipc_server_handle_shutdown_signal(
struct ipc_server *vs);
654 return ics->
server->isms[ics->server_thread_index];
663 return ics->ism_handle;
Generic typedef for platform-specific shared memory handle.
u_logging_level
Logging level enum.
Definition u_logging.h:45
xrt_result_t ipc_server_set_client_recommended_view_config(struct ipc_server *s, uint32_t client_id, enum xrt_view_type view_type, const struct xrt_recommended_view_config *recommended_view_config)
Set the recommended view configuration for this client.
Definition ipc_server_process.c:953
xrt_result_t ipc_server_set_client_io_blocks(struct ipc_server *s, uint32_t client_id, const struct ipc_client_io_blocks *blocks)
Block certain types of IO for this client.
Definition ipc_server_process.c:916
xrt_result_t ipc_server_get_client_app_state(struct ipc_server *s, uint32_t client_id, struct ipc_app_state *out_ias)
Get the current state of a client.
Definition ipc_server_process.c:886
void ipc_server_deactivate_session(volatile struct ipc_client_state *ics)
Called by client threads to set a session to deactivate.
Definition ipc_server_process.c:997
void ipc_server_activate_session(volatile struct ipc_client_state *ics)
Called by client threads to set a session to active.
Definition ipc_server_process.c:966
void * ipc_server_client_thread(void *_ics)
Thread function for the client side dispatching.
Definition ipc_server_per_client_thread.c:490
void ipc_server_update_state(struct ipc_server *s)
Called by client threads to recalculate active client.
Definition ipc_server_process.c:1012
xrt_result_t ipc_server_get_client_session_running_state(struct ipc_server *s, uint32_t client_id, struct xrt_compositor_session_running_state *out_running_state)
Get the session running state for this client.
Definition ipc_server_process.c:926
xrt_result_t ipc_server_set_active_client(struct ipc_server *s, uint32_t client_id)
Set the new active client.
Definition ipc_server_process.c:896
xrt_result_t ipc_server_toggle_io_client(struct ipc_server *s, uint32_t client_id)
Toggle the io for this client.
Definition ipc_server_process.c:906
xrt_result_t ipc_server_get_client_view_config(struct ipc_server *s, uint32_t client_id, enum xrt_view_type view_type, struct xrt_view_config *out_default_view_config, struct xrt_recommended_view_config *out_recommended_view_config)
Get the view configuration for this client.
Definition ipc_server_process.c:938
xrt_result_t ipc_server_init_system_if_available_locked(struct ipc_server *s, volatile struct ipc_client_state *ics, bool *out_available)
Finish setting up the server by creating the system, compositor and devices.
Definition ipc_server_process.c:850
#define XRT_SYSTEM_MAX_DEVICES
Maximum number of devices simultaneously usable by an implementation of xrt_system_devices.
Definition xrt_limits.h:26
#define XRT_SPACE_REFERENCE_TYPE_COUNT
The number of enumerations in xrt_reference_space_type.
Definition xrt_defines.h:668
enum xrt_result xrt_result_t
Result type used across Monado.
IPC message channel functions.
Common protocol definition.
void ipc_server_client_destroy_session_and_compositor(volatile struct ipc_client_state *ics)
This destroys the native compositor for this client and any extra objects created from it,...
Definition ipc_server_per_client_thread.c:453
static struct ipc_shared_memory * get_ism(volatile struct ipc_client_state *ics)
Get the data in the shared memory of the given client.
Definition ipc_server.h:652
static xrt_shmem_handle_t get_ism_handle(volatile struct ipc_client_state *ics)
Get the handle for the shared memory of the given client.
Definition ipc_server.h:661
Interface for IPC server code.
void ipc_server_mainloop_deinit(struct ipc_server_mainloop *ml)
Definition ipc_server_mainloop_android.c:163
Wrapper around OS threading native functions.
State for a connected application.
Definition ipc_protocol.h:356
Which types of IO to block for a client.
Definition ipc_protocol.h:343
Holds the state for a single client.
Definition ipc_server.h:102
uint32_t swapchain_count
Number of swapchains in use by client.
Definition ipc_server.h:162
struct xrt_app_instance * xainsts[4]
Array of app instances owned by this client.
Definition ipc_server.h:142
struct xrt_swapchain * xscs[(XRT_MAX_LAYERS *2)]
Ptrs to the swapchains.
Definition ipc_server.h:165
struct xrt_session * xs
Session for this client.
Definition ipc_server.h:156
struct ipc_message_channel imc
Socket fd used for client comms.
Definition ipc_server.h:208
bool has_init_shm_system
Has the system part of the shm initialized.
Definition ipc_server.h:107
struct xrt_device ** plane_detection_xdev
Array of xrt_devices with plane_detection_size entries.
Definition ipc_server.h:220
struct ipc_server * server
Link back to the main server.
Definition ipc_server.h:104
uint32_t local_floor_space_index
Index of localfloorspace in ipc client.
Definition ipc_server.h:194
struct xrt_body_tracker * xbts[16]
Body trackers owned by this client.
Definition ipc_server.h:132
struct ipc_swapchain_data swapchain_data[(XRT_MAX_LAYERS *2)]
Data for the swapchains.
Definition ipc_server.h:168
uint32_t compositor_semaphore_count
Number of compositor semaphores in use by client.
Definition ipc_server.h:171
struct xrt_tracking_origin * xtracks[XRT_SYSTEM_MAX_DEVICES]
Array of tracking origins.
Definition ipc_server.h:118
uint32_t local_space_overseer_index
Index of localspace in space overseer.
Definition ipc_server.h:192
struct xrt_space * xspcs[128]
Ptrs to the spaces.
Definition ipc_server.h:199
uint32_t local_space_index
Index of localspace in ipc client.
Definition ipc_server.h:190
struct xrt_app_system * xasys[(4 *4)]
Array of app systems owned by this client.
Definition ipc_server.h:147
bool ref_space_used[XRT_SPACE_REFERENCE_TYPE_COUNT]
Which of the references spaces is the client using.
Definition ipc_server.h:202
struct xrt_compositor_semaphore * xcsems[8]
Ptrs to the semaphores.
Definition ipc_server.h:174
uint32_t space_count
Number of spaces.
Definition ipc_server.h:188
bool device_feature_used[XRT_DEVICE_FEATURE_MAX_ENUM]
Which of the device features is the client using.
Definition ipc_server.h:205
uint64_t * plane_detection_ids
Array of plane detection ids with plane_detection_size entries.
Definition ipc_server.h:217
uint32_t local_floor_space_overseer_index
Index of localfloorspace in space overseer.
Definition ipc_server.h:196
struct xrt_device * xdevs[XRT_SYSTEM_MAX_DEVICES]
Array of devices.
Definition ipc_server.h:127
struct xrt_compositor * xc
Compositor for this client.
Definition ipc_server.h:159
struct xrt_hand_tracker * xhts[16]
Hand trackers owned by this client.
Definition ipc_server.h:137
struct xrt_future * xfts[128]
Ptrs to the futures.
Definition ipc_server.h:177
struct xrt_io_cache * xics[16]
Input/output caches owned by this client.
Definition ipc_server.h:152
Wrapper for a socket and flags.
Definition ipc_message_channel.h:30
Definition ipc_server_interface.h:67
Platform-specific mainloop object for the IPC server.
Definition ipc_server.h:253
bool launched_by_socket
Were we launched by socket activation, instead of explicitly?
Definition ipc_server.h:332
pthread_cond_t accept_cond
Condition variable for accepting clients.
Definition ipc_server.h:304
char * pipe_name
Name of the Pipe that we accept connections on.
Definition ipc_server.h:352
int last_accepted_fd
The last client fd we accepted, to acknowledge client acceptance.
Definition ipc_server.h:295
int epoll_fd
For waiting on various events in the main thread.
Definition ipc_server.h:257
pthread_mutex_t accept_mutex
Mutex for accepting clients.
Definition ipc_server.h:315
int pipe_read
File descriptor for the read end of our pipe for submitting new clients.
Definition ipc_server.h:267
int listen_socket
Socket that we accept connections on.
Definition ipc_server.h:329
int pipe_write
File descriptor for the write end of our pipe for submitting new clients.
Definition ipc_server.h:274
char * socket_filename
The socket filename we bound to, if any.
Definition ipc_server.h:335
pthread_mutex_t client_push_mutex
Mutex for being able to register oneself as a new client.
Definition ipc_server.h:285
HANDLE pipe_handle
Named Pipe that we accept connections on.
Definition ipc_server.h:349
Main IPC object for the server.
Definition ipc_server.h:398
void * callback_data
User data passed to callbacks.
Definition ipc_server.h:484
struct u_process * process
Handle for the current process, e.g. pidfile on linux.
Definition ipc_server.h:402
const struct ipc_server_callbacks * callbacks
Callbacks for server events.
Definition ipc_server.h:479
struct xrt_system_compositor * xsysc
System compositor.
Definition ipc_server.h:416
struct xrt_space_overseer * xso
Space overseer.
Definition ipc_server.h:413
struct os_mutex lock
Never hold this across client socket I/O (ipc_send, ipc_receive and the handle variants).
Definition ipc_server.h:473
uint32_t id_generator
Generator for IDs.
Definition ipc_server.h:457
struct xrt_system * xsys
The XRT interfaces level system.
Definition ipc_server.h:407
struct xrt_system_devices * xsysd
System devices.
Definition ipc_server.h:410
int64_t start_of_time_timestamp_ns
Global start of time timestamp.
Definition ipc_server.h:448
bool no_stdin
Disable listening on stdin for server stop.
Definition ipc_server.h:487
A big struct that contains all data that is shared to a client, no pointers allowed in this.
Definition ipc_protocol.h:234
Information about a single swapchain.
Definition ipc_server.h:86
Definition ipc_server.h:236
A wrapper around a native mutex.
Definition os_threading.h:69
A wrapper around a native thread.
Definition os_threading.h:298
Definition u_process.c:43
This interface acts as a way to store per-application policy for xrt_instance.
Definition xrt_app_policy.h:36
This interface acts as a way to store per-application policy for xrt_system.
Definition xrt_app_policy.h:194
A body tracker, owns the policy for selecting which device and body-tracking source back a single Ope...
Definition xrt_body_tracker.h:102
Main compositor server interface.
Definition xrt_compositor.h:2226
Compositor semaphore used for synchronization, needs to be as capable as a Vulkan pipeline semaphore.
Definition xrt_compositor.h:853
Details about the currently running session of an xrt_compositor.
Definition xrt_compositor.h:2386
Common compositor client interface/base.
Definition xrt_compositor.h:1054
A single HMD or input device.
Definition xrt_device.h:328
A future is a concurrency primitive that provides a mechanism to access results of asynchronous opera...
Definition xrt_future.h:75
A hand tracker that owns device/source selection policy.
Definition xrt_hand_tracker.h:76
This interface acts as a root object for Monado.
Definition xrt_instance.h:124
A cache of flattened device inputs and outputs.
Definition xrt_io_cache.h:116
A recommended view configuration.
Definition xrt_app_policy.h:174
The XRT representation of XrSession, this object does not have all of the functionality of a session,...
Definition xrt_session.h:264
Object that oversees and manages spaces, one created for each XR system.
Definition xrt_space.h:97
A space very similar to a OpenXR XrSpace but not a full one-to-one mapping, but used to power XrSpace...
Definition xrt_space.h:32
Common swapchain interface/base.
Definition xrt_compositor.h:601
The system compositor handles composition for a system.
Definition xrt_compositor.h:2487
A collection of xrt_device, and an interface for identifying the roles they have been assigned.
Definition xrt_system.h:218
Properties provided by the system.
Definition xrt_system.h:48
A system is a collection of devices, policies and optionally a compositor that is organised into a ch...
Definition xrt_system.h:67
A tracking system or device origin.
Definition xrt_tracking.h:87
Definition xrt_compositor.h:2306
Hashmap for integer values header.
Basic logging functionality.
Header holding common defines.
xrt_view_type
View type to be rendered to by the compositor.
Definition xrt_defines.h:2453
int xrt_ipc_handle_t
The type for an IPC handle.
Definition xrt_handles.h:75
Header for limits of the XRT interfaces.
Header defining xrt space and space overseer.
Header for system objects.