···9595 struct xrt_session_event_sink *broadcast;
96969797 /*!
9898+ * The notify device, usually the head device. Used to notify when
9999+ * reference spaces are used and not used. Must not change during
100100+ * runtime.
101101+ */
102102+ struct xrt_device *notify;
103103+104104+ /*!
98105 * Can we do a recenter of the local and local_floor spaces, protected
99106 * by the lock.
100107 *
···133140 case XRT_SPACE_REFERENCE_TYPE_STAGE: return "stage";
134141 case XRT_SPACE_REFERENCE_TYPE_UNBOUNDED: return "unbounded";
135142 }
143143+}
144144+145145+static struct u_space *
146146+get_semantic_space(struct u_space_overseer *uso, enum xrt_reference_space_type type)
147147+{
148148+ switch (type) {
149149+ case XRT_SPACE_REFERENCE_TYPE_VIEW: return u_space(uso->base.semantic.view);
150150+ case XRT_SPACE_REFERENCE_TYPE_LOCAL: return u_space(uso->base.semantic.local);
151151+ case XRT_SPACE_REFERENCE_TYPE_LOCAL_FLOOR: return u_space(uso->base.semantic.local_floor);
152152+ case XRT_SPACE_REFERENCE_TYPE_STAGE: return u_space(uso->base.semantic.stage);
153153+ case XRT_SPACE_REFERENCE_TYPE_UNBOUNDED: return u_space(uso->base.semantic.unbounded);
154154+ }
155155+156156+ return NULL;
136157}
137158138159/*!
···220241221242/*
222243 *
244244+ * Reference space to device notification code.
245245+ *
246246+ */
247247+248248+static void
249249+notify_ref_space_usage_device(struct u_space_overseer *uso, enum xrt_reference_space_type type, bool used)
250250+{
251251+ struct xrt_device *xdev = NULL;
252252+ enum xrt_input_name name = 0;
253253+254254+ struct u_space *uspace = get_semantic_space(uso, type);
255255+ if (uspace == NULL) {
256256+ // This is weird, should always be a space.
257257+ return;
258258+ }
259259+260260+ if (uspace->type == U_SPACE_TYPE_POSE) {
261261+ xdev = uspace->pose.xdev;
262262+ name = uspace->pose.xname;
263263+ } else {
264264+ xdev = uso->notify;
265265+ }
266266+267267+ if (xdev == NULL || !xdev->ref_space_usage_supported) {
268268+ return;
269269+ }
270270+271271+ xrt_device_ref_space_usage(xdev, type, name, used);
272272+}
273273+274274+275275+/*
276276+ *
223277 * Graph traversing functions.
224278 *
225279 */
···513567514568 U_LOG_D("Ref-space %s in use", type_to_small_string(type));
515569570570+516571 /*
517517- * This space intentionally left blank for future expansion,
518518- * use it for adding new functionality on used/unused switches.
572572+ * We have a reference space that was not in use but is now in used.
519573 */
574574+575575+ // Notify any device that might want to know about it.
576576+ notify_ref_space_usage_device(uso, type, true);
520577521578 return XRT_SUCCESS;
522579}
···536593537594 U_LOG_D("Ref-space %s no longer in use", type_to_small_string(type));
538595596596+539597 /*
540540- * This space intentionally left blank for future expansion,
541541- * use it for adding new functionality on used/unused switches.
598598+ * We have a reference space that was in use but is no longer used.
542599 */
600600+601601+ // Notify any device that might want to know about it.
602602+ notify_ref_space_usage_device(uso, type, false);
543603544604 return XRT_SUCCESS;
545605}
···772832 // Setup view space if we have a head.
773833 if (head != NULL) {
774834 u_space_overseer_create_pose_space(uso, head, XRT_INPUT_GENERIC_HEAD_POSE, &uso->base.semantic.view);
835835+836836+ // Set the head to the notify device, for reference space usage.
837837+ uso->notify = head;
775838 }
776839}
777840