From 3de99b63d99d3a041a2dffb31b805c47b23f004b Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Mon, 31 Jul 2023 17:24:30 +0100 Subject: [PATCH] ipc: Add a interface header for ipc_server_main[_android] --- src/xrt/ipc/server/ipc_server.h | 25 --------- src/xrt/ipc/server/ipc_server_interface.h | 54 +++++++++++++++++++ src/xrt/ipc/server/ipc_server_process.c | 1 + .../targets/service-lib/service_target.cpp | 1 + src/xrt/targets/service/main.c | 5 +- 5 files changed, 58 insertions(+), 28 deletions(-) create mode 100644 src/xrt/ipc/server/ipc_server_interface.h diff --git a/src/xrt/ipc/server/ipc_server.h b/src/xrt/ipc/server/ipc_server.h index 0ee4f3702..8433d4c69 100644 --- a/src/xrt/ipc/server/ipc_server.h +++ b/src/xrt/ipc/server/ipc_server.h @@ -355,31 +355,6 @@ struct ipc_server }; -#ifndef XRT_OS_ANDROID -/*! - * Main entrypoint to the compositor process. - * - * @ingroup ipc_server - */ -int -ipc_server_main(int argc, char **argv); -#endif - -#ifdef XRT_OS_ANDROID -/*! - * Main entrypoint to the server process. - * - * @param ps Pointer to populate with the server struct. - * @param startup_complete_callback Function to call upon completing startup and populating *ps, but before entering the - * mainloop. - * @param data user data to pass to your callback. - * - * @ingroup ipc_server - */ -int -ipc_server_main_android(struct ipc_server **ps, void (*startup_complete_callback)(void *data), void *data); -#endif - /*! * Get the current state of a client. * diff --git a/src/xrt/ipc/server/ipc_server_interface.h b/src/xrt/ipc/server/ipc_server_interface.h new file mode 100644 index 000000000..7f24ab78c --- /dev/null +++ b/src/xrt/ipc/server/ipc_server_interface.h @@ -0,0 +1,54 @@ +// Copyright 2020-2023, Collabora, Ltd. +// SPDX-License-Identifier: BSL-1.0 +/*! + * @file + * @brief Interface for IPC server code. + * @author Pete Black + * @author Jakob Bornecrantz + * @author Ryan Pavlik + * @ingroup ipc_server + */ + +#include "xrt/xrt_compiler.h" +#include "xrt/xrt_config_os.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifndef XRT_OS_ANDROID + +/*! + * Main entrypoint to the compositor process. + * + * @ingroup ipc_server + */ +int +ipc_server_main(int argc, char **argv); + +#endif + + +#ifdef XRT_OS_ANDROID + +/*! + * Main entrypoint to the server process. + * + * @param ps Pointer to populate with the server struct. + * @param startup_complete_callback Function to call upon completing startup + * and populating *ps, but before entering + * the mainloop. + * @param data user data to pass to your callback. + * + * @ingroup ipc_server + */ +int +ipc_server_main_android(struct ipc_server **ps, void (*startup_complete_callback)(void *data), void *data); + +#endif + + +#ifdef __cplusplus +} +#endif diff --git a/src/xrt/ipc/server/ipc_server_process.c b/src/xrt/ipc/server/ipc_server_process.c index 66f3a4056..a0064d692 100644 --- a/src/xrt/ipc/server/ipc_server_process.c +++ b/src/xrt/ipc/server/ipc_server_process.c @@ -29,6 +29,7 @@ #include "shared/ipc_shmem.h" #include "server/ipc_server.h" +#include "server/ipc_server_interface.h" #include #include diff --git a/src/xrt/targets/service-lib/service_target.cpp b/src/xrt/targets/service-lib/service_target.cpp index 9b2cd5209..d03ac4150 100644 --- a/src/xrt/targets/service-lib/service_target.cpp +++ b/src/xrt/targets/service-lib/service_target.cpp @@ -13,6 +13,7 @@ #include "wrap/android.view.h" #include "server/ipc_server.h" +#include "server/ipc_server_interface.h" #include "server/ipc_server_mainloop_android.h" #include "util/u_logging.h" diff --git a/src/xrt/targets/service/main.c b/src/xrt/targets/service/main.c index 78e46c032..f014f4f58 100644 --- a/src/xrt/targets/service/main.c +++ b/src/xrt/targets/service/main.c @@ -18,15 +18,14 @@ #include "util/u_windows.h" #endif +#include "server/ipc_server_interface.h" + #include "target_lists.h" // Insert the on load constructor to init trace marker. U_TRACE_TARGET_SETUP(U_TRACE_WHICH_SERVICE) -int -ipc_server_main(int argc, char *argv[]); - int main(int argc, char *argv[])