The open source OpenXR runtime

u/sink: Make sink_queue drop the oldest frame when full

Instead of discarding the incoming frame when the queue is
at capacity, drop the oldest frame possible. I can't
think of a situation where it would be better to work on
stale data in preference to fresh data. If there is, we
can easily add a flag to choose behaviour.

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2188>

authored by

Jan Schmidt and committed by
Marge Bot
eb4d2cd9 8b0f9e22

+5 -1
+5 -1
src/xrt/auxiliary/util/u_sink_queue.c
··· 99 99 queue_try_refpush(struct u_sink_queue *q, struct xrt_frame *xf) 100 100 { 101 101 if (queue_is_full(q)) { 102 - return false; 102 + // Drop the oldest frame 103 + if (!queue_is_empty(q)) { 104 + struct xrt_frame *old = queue_pop(q); 105 + xrt_frame_reference(&old, NULL); 106 + } 103 107 } 104 108 struct u_sink_queue_elem *elem = U_TYPED_CALLOC(struct u_sink_queue_elem); 105 109 xrt_frame_reference(&elem->frame, xf);