mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-02-17 11:10:06 +00:00
st/oxr: Purge event queue of destroyed sessions
This commit is contained in:
parent
185036489c
commit
76e4092e30
doc/changes/state_trackers
src/xrt/state_trackers/oxr
3
doc/changes/state_trackers/mr.359.3.md
Normal file
3
doc/changes/state_trackers/mr.359.3.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
OpenXR: When a `XrSession` is destroyed purge the event queue of any events that
|
||||||
|
references to it so that no events gets delivered to the applications with
|
||||||
|
stales handles.
|
|
@ -133,6 +133,44 @@ oxr_event_push_XrEventDataSessionStateChanged(struct oxr_logger *log,
|
||||||
return XR_SUCCESS;
|
return XR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XrResult
|
||||||
|
oxr_event_remove_session_events(struct oxr_logger *log,
|
||||||
|
struct oxr_session *sess)
|
||||||
|
{
|
||||||
|
struct oxr_instance *inst = sess->sys->inst;
|
||||||
|
XrSession session = oxr_session_to_openxr(sess);
|
||||||
|
|
||||||
|
lock(inst);
|
||||||
|
|
||||||
|
struct oxr_event *e = inst->next_event;
|
||||||
|
while (e != NULL) {
|
||||||
|
struct oxr_event *cur = e;
|
||||||
|
e = e->next;
|
||||||
|
|
||||||
|
XrEventDataSessionStateChanged *changed = oxr_event_extra(cur);
|
||||||
|
if (changed->type != XR_TYPE_EVENT_DATA_SESSION_STATE_CHANGED) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changed->session != session) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cur == inst->next_event) {
|
||||||
|
inst->next_event = cur->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cur == inst->last_event) {
|
||||||
|
inst->last_event = NULL;
|
||||||
|
}
|
||||||
|
free(cur);
|
||||||
|
}
|
||||||
|
|
||||||
|
unlock(inst);
|
||||||
|
|
||||||
|
return XR_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
XrResult
|
XrResult
|
||||||
oxr_poll_event(struct oxr_logger *log,
|
oxr_poll_event(struct oxr_logger *log,
|
||||||
struct oxr_instance *inst,
|
struct oxr_instance *inst,
|
||||||
|
|
|
@ -692,6 +692,13 @@ oxr_event_push_XrEventDataSessionStateChanged(struct oxr_logger *log,
|
||||||
XrSessionState state,
|
XrSessionState state,
|
||||||
XrTime time);
|
XrTime time);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This clears all pending events refers to the given session.
|
||||||
|
*/
|
||||||
|
XrResult
|
||||||
|
oxr_event_remove_session_events(struct oxr_logger *log,
|
||||||
|
struct oxr_session *sess);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
|
|
|
@ -840,6 +840,8 @@ oxr_session_destroy(struct oxr_logger *log, struct oxr_handle_base *hb)
|
||||||
{
|
{
|
||||||
struct oxr_session *sess = (struct oxr_session *)hb;
|
struct oxr_session *sess = (struct oxr_session *)hb;
|
||||||
|
|
||||||
|
XrResult ret = oxr_event_remove_session_events(log, sess);
|
||||||
|
|
||||||
// Does a null-ptr check.
|
// Does a null-ptr check.
|
||||||
xrt_comp_destroy(&sess->compositor);
|
xrt_comp_destroy(&sess->compositor);
|
||||||
|
|
||||||
|
@ -848,7 +850,7 @@ oxr_session_destroy(struct oxr_logger *log, struct oxr_handle_base *hb)
|
||||||
|
|
||||||
free(sess);
|
free(sess);
|
||||||
|
|
||||||
return XR_SUCCESS;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define OXR_SESSION_ALLOCATE(LOG, SYS, OUT) \
|
#define OXR_SESSION_ALLOCATE(LOG, SYS, OUT) \
|
||||||
|
|
Loading…
Reference in a new issue