From 1430b1b22c96c75cdd4dff17c482d37df53955ac Mon Sep 17 00:00:00 2001 From: Lubosz Sarnecki Date: Wed, 25 Nov 2020 14:10:39 +0100 Subject: [PATCH] ipc/server: Add Android main entry point which receives fd. --- src/xrt/ipc/server/ipc_server.h | 10 ++++++++++ src/xrt/ipc/server/ipc_server_process.c | 26 +++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/xrt/ipc/server/ipc_server.h b/src/xrt/ipc/server/ipc_server.h index 1426c2dca..390b3a487 100644 --- a/src/xrt/ipc/server/ipc_server.h +++ b/src/xrt/ipc/server/ipc_server.h @@ -202,6 +202,16 @@ struct ipc_server int ipc_server_main(int argc, char **argv); +/*! + * Android entry point to the IPC server process. + * + * @ingroup ipc_server + */ +#ifdef XRT_OS_ANDROID +int +ipc_server_main_android(int fd); +#endif + /*! * Called by client threads to manage global state * diff --git a/src/xrt/ipc/server/ipc_server_process.c b/src/xrt/ipc/server/ipc_server_process.c index b12a0e1ac..27e266a8b 100644 --- a/src/xrt/ipc/server/ipc_server_process.c +++ b/src/xrt/ipc/server/ipc_server_process.c @@ -1230,3 +1230,29 @@ ipc_server_main(int argc, char **argv) return ret; } + +#ifdef XRT_OS_ANDROID +int +ipc_server_main_android(int fd) +{ + struct ipc_server *s = U_TYPED_CALLOC(struct ipc_server); + U_LOG_D("Created IPC server on fd %d", fd); + + int ret = init_all(s); + if (ret < 0) { + free(s); + return ret; + } + + init_server_state(s); + start_client_listener_thread(s, fd); + ret = main_loop(s); + + teardown_all(s); + free(s); + + U_LOG_E("Server exiting! '%i'", ret); + + return ret; +} +#endif