The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

ipc: Add session_destroy to handle session destruction

authored by

Jakob Bornecrantz and committed by
Ryan Pavlik
8a191daa 8a715ec4

+55 -13
+4
src/xrt/ipc/client/ipc_client_compositor.c
··· 662 662 663 663 assert(icc->compositor_created); 664 664 665 + IPC_ERROR(icc->ipc_c, "Called"); 666 + 667 + IPC_CALL_CHK(ipc_call_session_destroy(icc->ipc_c)); 668 + 665 669 icc->compositor_created = false; 666 670 } 667 671
+7
src/xrt/ipc/server/ipc_server.h
··· 375 375 ipc_server_client_thread(void *_cs); 376 376 377 377 /*! 378 + * This destroyes the native compositor for this client and any extra objects 379 + * created from it, like all of the swapchains. 380 + */ 381 + void 382 + ipc_server_client_destroy_compositor(volatile struct ipc_client_state *ics); 383 + 384 + /*! 378 385 * @defgroup ipc_server_internals Server Internals 379 386 * @brief These are only called by the platform-specific mainloop polling code. 380 387 * @ingroup ipc_server
+18
src/xrt/ipc/server/ipc_server_handler.c
··· 103 103 104 104 struct xrt_compositor_native *xcn = NULL; 105 105 106 + if (ics->xc != NULL) { 107 + return XRT_ERROR_IPC_SESSION_ALREADY_CREATED; 108 + } 109 + 106 110 xrt_result_t xret = xrt_syscomp_create_native_compositor(ics->server->xsysc, xsi, &xcn); 107 111 if (xret != XRT_SUCCESS) { 108 112 return xret; ··· 142 146 } 143 147 144 148 return xrt_comp_end_session(ics->xc); 149 + } 150 + 151 + xrt_result_t 152 + ipc_handle_session_destroy(volatile struct ipc_client_state *ics) 153 + { 154 + IPC_TRACE_MARKER(); 155 + 156 + if (ics->xc == NULL) { 157 + return XRT_ERROR_IPC_SESSION_NOT_CREATED; 158 + } 159 + 160 + ipc_server_client_destroy_compositor(ics); 161 + 162 + return XRT_SUCCESS; 145 163 } 146 164 147 165 xrt_result_t
+24 -13
src/xrt/ipc/server/ipc_server_per_client_thread.c
··· 124 124 125 125 ipc_message_channel_close((struct ipc_message_channel *)&ics->imc); 126 126 127 - ics->num_swapchains = 0; 128 - 129 127 ics->server->threads[ics->server_thread_index].state = IPC_THREAD_STOPPING; 130 128 ics->server_thread_index = -1; 131 129 memset((void *)&ics->client_state, 0, sizeof(struct ipc_app_state)); 132 - 133 - // Destroy all swapchains now. 134 - for (uint32_t j = 0; j < IPC_MAX_CLIENT_SWAPCHAINS; j++) { 135 - // Drop our reference, does NULL checking. Cast away volatile. 136 - xrt_swapchain_reference((struct xrt_swapchain **)&ics->xscs[j], NULL); 137 - ics->swapchain_data[j].active = false; 138 - IPC_TRACE(ics->server, "Destroyed swapchain %d.", j); 139 - } 140 130 141 131 os_mutex_unlock(&ics->server->global_state.lock); 142 132 143 - // Cast away volatile. 144 - xrt_comp_destroy((struct xrt_compositor **)&ics->xc); 133 + ipc_server_client_destroy_compositor(ics); 145 134 146 135 // Should we stop the server when a client disconnects? 147 136 if (ics->server->exit_on_disconnect) { ··· 154 143 155 144 /* 156 145 * 157 - * Entry point. 146 + * 'Exported' functions. 158 147 * 159 148 */ 149 + 150 + void 151 + ipc_server_client_destroy_compositor(volatile struct ipc_client_state *ics) 152 + { 153 + // Multiple threads might be looking at these fields. 154 + os_mutex_lock(&ics->server->global_state.lock); 155 + 156 + ics->num_swapchains = 0; 157 + 158 + // Destroy all swapchains now. 159 + for (uint32_t j = 0; j < IPC_MAX_CLIENT_SWAPCHAINS; j++) { 160 + // Drop our reference, does NULL checking. Cast away volatile. 161 + xrt_swapchain_reference((struct xrt_swapchain **)&ics->xscs[j], NULL); 162 + ics->swapchain_data[j].active = false; 163 + IPC_TRACE(ics->server, "Destroyed swapchain %d.", j); 164 + } 165 + 166 + os_mutex_unlock(&ics->server->global_state.lock); 167 + 168 + // Cast away volatile. 169 + xrt_comp_destroy((struct xrt_compositor **)&ics->xc); 170 + } 160 171 161 172 void * 162 173 ipc_server_client_thread(void *_ics)
+2
src/xrt/ipc/shared/proto.json
··· 66 66 67 67 "session_end": {}, 68 68 69 + "session_destroy": {}, 70 + 69 71 "compositor_get_info": { 70 72 "out": [ 71 73 {"name": "info", "type": "struct xrt_compositor_info"}