mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-26 17:37:34 +00:00
st/oxr: add more checks around xrBeginSession and xrEndSession
Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2162>
This commit is contained in:
parent
511efda748
commit
738acfbcf7
1
doc/changes/state_trackers/mr.2162.md
Normal file
1
doc/changes/state_trackers/mr.2162.md
Normal file
|
@ -0,0 +1 @@
|
|||
st/oxr: add more checks around xrBeginSession and xrEndSession
|
|
@ -205,6 +205,14 @@ oxr_session_enumerate_formats(struct oxr_logger *log,
|
|||
XrResult
|
||||
oxr_session_begin(struct oxr_logger *log, struct oxr_session *sess, const XrSessionBeginInfo *beginInfo)
|
||||
{
|
||||
/*
|
||||
* If the session is not running when the application calls xrBeginSession, but the session is not yet in the
|
||||
* XR_SESSION_STATE_READY state, the runtime must return error XR_ERROR_SESSION_NOT_READY.
|
||||
*/
|
||||
if (sess->state != XR_SESSION_STATE_READY) {
|
||||
return oxr_error(log, XR_ERROR_SESSION_NOT_READY, "Session is not ready to begin");
|
||||
}
|
||||
|
||||
struct xrt_compositor *xc = sess->compositor;
|
||||
if (xc != NULL) {
|
||||
XrViewConfigurationType view_type = beginInfo->primaryViewConfigurationType;
|
||||
|
@ -267,11 +275,23 @@ oxr_session_end(struct oxr_logger *log, struct oxr_session *sess)
|
|||
return XR_SUCCESS;
|
||||
}
|
||||
|
||||
struct xrt_compositor *xc = sess->compositor;
|
||||
/*
|
||||
* If the session is not running when the application calls xrEndSession, the runtime must return
|
||||
* error XR_ERROR_SESSION_NOT_RUNNING
|
||||
*/
|
||||
if (sess->state == XR_SESSION_STATE_IDLE || sess->state == XR_SESSION_STATE_READY) {
|
||||
return oxr_error(log, XR_ERROR_SESSION_NOT_RUNNING, "Session is not running");
|
||||
}
|
||||
|
||||
/*
|
||||
* If the session is still running when the application calls xrEndSession, but the session is not yet in
|
||||
* the XR_SESSION_STATE_STOPPING state, the runtime must return error XR_ERROR_SESSION_NOT_STOPPING.
|
||||
*/
|
||||
if (sess->state != XR_SESSION_STATE_STOPPING) {
|
||||
return oxr_error(log, XR_ERROR_SESSION_NOT_STOPPING, "Session is not stopping");
|
||||
}
|
||||
|
||||
struct xrt_compositor *xc = sess->compositor;
|
||||
if (xc != NULL) {
|
||||
if (sess->frame_id.waited > 0) {
|
||||
xrt_comp_discard_frame(xc, sess->frame_id.waited);
|
||||
|
|
Loading…
Reference in a new issue