···11+st/oxr: add more checks around xrBeginSession and xrEndSession
+21-1
src/xrt/state_trackers/oxr/oxr_session.c
···205205XrResult
206206oxr_session_begin(struct oxr_logger *log, struct oxr_session *sess, const XrSessionBeginInfo *beginInfo)
207207{
208208+ /*
209209+ * If the session is not running when the application calls xrBeginSession, but the session is not yet in the
210210+ * XR_SESSION_STATE_READY state, the runtime must return error XR_ERROR_SESSION_NOT_READY.
211211+ */
212212+ if (sess->state != XR_SESSION_STATE_READY) {
213213+ return oxr_error(log, XR_ERROR_SESSION_NOT_READY, "Session is not ready to begin");
214214+ }
215215+208216 struct xrt_compositor *xc = sess->compositor;
209217 if (xc != NULL) {
210218 XrViewConfigurationType view_type = beginInfo->primaryViewConfigurationType;
···267275 return XR_SUCCESS;
268276 }
269277270270- struct xrt_compositor *xc = sess->compositor;
278278+ /*
279279+ * If the session is not running when the application calls xrEndSession, the runtime must return
280280+ * error XR_ERROR_SESSION_NOT_RUNNING
281281+ */
282282+ if (sess->state == XR_SESSION_STATE_IDLE || sess->state == XR_SESSION_STATE_READY) {
283283+ return oxr_error(log, XR_ERROR_SESSION_NOT_RUNNING, "Session is not running");
284284+ }
285285+286286+ /*
287287+ * If the session is still running when the application calls xrEndSession, but the session is not yet in
288288+ * the XR_SESSION_STATE_STOPPING state, the runtime must return error XR_ERROR_SESSION_NOT_STOPPING.
289289+ */
271290 if (sess->state != XR_SESSION_STATE_STOPPING) {
272291 return oxr_error(log, XR_ERROR_SESSION_NOT_STOPPING, "Session is not stopping");
273292 }
274293294294+ struct xrt_compositor *xc = sess->compositor;
275295 if (xc != NULL) {
276296 if (sess->frame_id.waited > 0) {
277297 xrt_comp_discard_frame(xc, sess->frame_id.waited);