mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-02-14 01:30:07 +00:00
ipc: Fix headless sessions
This commit is contained in:
parent
f5caa0388a
commit
467ed130de
src/xrt/ipc
|
@ -808,15 +808,6 @@ ipc_compositor_destroy(struct xrt_compositor *xc)
|
|||
|
||||
assert(icc->compositor_created);
|
||||
|
||||
xret = ipc_call_session_destroy(icc->ipc_c);
|
||||
|
||||
/*
|
||||
* We are probably in a really bad state if we fail, at
|
||||
* least print out the error and continue as best we can.
|
||||
*/
|
||||
IPC_CHK_ONLY_PRINT(icc->ipc_c, xret, "ipc_call_session_destroy");
|
||||
|
||||
|
||||
os_precise_sleeper_deinit(&icc->sleeper);
|
||||
|
||||
icc->compositor_created = false;
|
||||
|
@ -1018,8 +1009,15 @@ ipc_client_create_native_compositor(struct xrt_system_compositor *xsysc,
|
|||
return XRT_ERROR_MULTI_SESSION_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
// Needs to be done before init.
|
||||
xret = ipc_call_session_create(icc->ipc_c, xsi);
|
||||
/*
|
||||
* Needs to be done before init, we don't own the service side session
|
||||
* the session does. But we create it here in case any extra arguments
|
||||
* that only the compositor knows about needs to be sent.
|
||||
*/
|
||||
xret = ipc_call_session_create( //
|
||||
icc->ipc_c, // ipc_c
|
||||
xsi, // xsi
|
||||
true); // create_native_compositor
|
||||
IPC_CHK_AND_RET(icc->ipc_c, xret, "ipc_call_session_create");
|
||||
|
||||
// Needs to be done after session create call.
|
||||
|
|
|
@ -60,6 +60,19 @@ static void
|
|||
ipc_client_session_destroy(struct xrt_session *xs)
|
||||
{
|
||||
struct ipc_client_session *ics = ipc_session(xs);
|
||||
xrt_result_t xret;
|
||||
|
||||
/*
|
||||
* We own the session in both cases of headless or created with a
|
||||
* native compositor, so we need to destroy it.
|
||||
*/
|
||||
xret = ipc_call_session_destroy(ics->ipc_c);
|
||||
|
||||
/*
|
||||
* We are probably in a really bad state if we fail, at
|
||||
* least print out the error and continue as best we can.
|
||||
*/
|
||||
IPC_CHK_ONLY_PRINT(ics->ipc_c, xret, "ipc_call_session_destroy");
|
||||
|
||||
free(ics);
|
||||
}
|
||||
|
|
|
@ -42,6 +42,51 @@ ipc_system(struct xrt_system *xsys)
|
|||
return (struct ipc_client_system *)xsys;
|
||||
}
|
||||
|
||||
static inline xrt_result_t
|
||||
create_headless(struct ipc_client_system *icsys, const struct xrt_session_info *xsi, struct xrt_session **out_xs)
|
||||
{
|
||||
xrt_result_t xret = XRT_SUCCESS;
|
||||
|
||||
// We create the session ourselves.
|
||||
xret = ipc_call_session_create( //
|
||||
icsys->ipc_c, // ipc_c
|
||||
xsi, // xsi
|
||||
false); // create_native_compositor
|
||||
IPC_CHK_AND_RET(icsys->ipc_c, xret, "ipc_call_session_create");
|
||||
|
||||
struct xrt_session *xs = ipc_client_session_create(icsys->ipc_c);
|
||||
assert(xs != NULL);
|
||||
|
||||
*out_xs = xs;
|
||||
|
||||
return XRT_SUCCESS;
|
||||
}
|
||||
|
||||
static inline xrt_result_t
|
||||
create_with_comp(struct ipc_client_system *icsys,
|
||||
const struct xrt_session_info *xsi,
|
||||
struct xrt_session **out_xs,
|
||||
struct xrt_compositor_native **out_xcn)
|
||||
{
|
||||
xrt_result_t xret = XRT_SUCCESS;
|
||||
|
||||
assert(icsys->xsysc != NULL);
|
||||
|
||||
// The native compositor creates the session.
|
||||
xret = ipc_client_create_native_compositor( //
|
||||
icsys->xsysc, //
|
||||
xsi, //
|
||||
out_xcn); //
|
||||
IPC_CHK_AND_RET(icsys->ipc_c, xret, "ipc_client_create_native_compositor");
|
||||
|
||||
struct xrt_session *xs = ipc_client_session_create(icsys->ipc_c);
|
||||
assert(xs != NULL);
|
||||
|
||||
*out_xs = xs;
|
||||
|
||||
return XRT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
|
@ -56,35 +101,18 @@ ipc_client_system_create_session(struct xrt_system *xsys,
|
|||
struct xrt_compositor_native **out_xcn)
|
||||
{
|
||||
struct ipc_client_system *icsys = ipc_system(xsys);
|
||||
xrt_result_t xret = XRT_SUCCESS;
|
||||
|
||||
if (out_xcn != NULL && icsys->xsysc == NULL) {
|
||||
U_LOG_E("No system compositor in system, can't create native compositor.");
|
||||
return XRT_ERROR_COMPOSITOR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
struct xrt_session *xs = ipc_client_session_create(icsys->ipc_c);
|
||||
|
||||
// Skip making a native compositor if not asked for.
|
||||
if (out_xcn == NULL) {
|
||||
goto out_session;
|
||||
return create_headless(icsys, xsi, out_xs);
|
||||
} else {
|
||||
return create_with_comp(icsys, xsi, out_xs, out_xcn);
|
||||
}
|
||||
|
||||
xret = ipc_client_create_native_compositor( //
|
||||
icsys->xsysc, //
|
||||
xsi, //
|
||||
out_xcn); //
|
||||
if (xret != XRT_SUCCESS) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
out_session:
|
||||
*out_xs = xs;
|
||||
|
||||
return XRT_SUCCESS;
|
||||
|
||||
err:
|
||||
return xret;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -204,7 +204,9 @@ ipc_handle_system_compositor_get_info(volatile struct ipc_client_state *ics,
|
|||
}
|
||||
|
||||
xrt_result_t
|
||||
ipc_handle_session_create(volatile struct ipc_client_state *ics, const struct xrt_session_info *xsi)
|
||||
ipc_handle_session_create(volatile struct ipc_client_state *ics,
|
||||
const struct xrt_session_info *xsi,
|
||||
bool create_native_compositor)
|
||||
{
|
||||
IPC_TRACE_MARKER();
|
||||
|
||||
|
@ -215,6 +217,10 @@ ipc_handle_session_create(volatile struct ipc_client_state *ics, const struct xr
|
|||
return XRT_ERROR_IPC_SESSION_ALREADY_CREATED;
|
||||
}
|
||||
|
||||
if (!create_native_compositor) {
|
||||
IPC_INFO(ics->server, "App asked for headless session, creating native compositor anyways");
|
||||
}
|
||||
|
||||
xrt_result_t xret = xrt_system_create_session(ics->server->xsys, xsi, &xs, &xcn);
|
||||
if (xret != XRT_SUCCESS) {
|
||||
return xret;
|
||||
|
|
|
@ -64,7 +64,8 @@
|
|||
|
||||
"session_create": {
|
||||
"in": [
|
||||
{"name": "overlay_info", "type": "struct xrt_session_info"}
|
||||
{"name": "xsi", "type": "struct xrt_session_info"},
|
||||
{"name": "create_native_compositor", "type": "bool"}
|
||||
]
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue