The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

u/sink: Ensure that image frames have monotonic timestamps

authored by

Moses Turner and committed by
Jakob Bornecrantz
d48792d9 17e0c39d

+13 -4
+13 -4
src/xrt/auxiliary/util/u_sink_force_genlock.c
··· 47 47 pthread_mutex_t mutex; 48 48 pthread_cond_t cond; 49 49 50 + //! Timestamp of the last frameset we pushed. 51 + int64_t last_ts; 52 + 50 53 //! Should we keep running? 51 54 //! currently, true upon startup, false as we're exiting. 52 55 bool running; ··· 137 140 frames[0]->timestamp = ts; 138 141 frames[1]->timestamp = ts; 139 142 140 - // Send to the consumer, in left-right order. 141 - xrt_sink_push_frame(q->consumer_left, frames[0]); 142 - xrt_sink_push_frame(q->consumer_right, frames[1]); 143 - 143 + if (ts == q->last_ts) { 144 + U_LOG_W("Got an image frame with a duplicate timestamp! Old: %lu; New: %lu", q->last_ts, ts); 145 + } else if (ts < q->last_ts) { 146 + U_LOG_W("Got an image frame with a non-monotonically-increasing timestamp! Old: %lu; New: %lu", 147 + q->last_ts, ts); 148 + } else { 149 + // Send to the consumer, in left-right order. 150 + xrt_sink_push_frame(q->consumer_left, frames[0]); 151 + xrt_sink_push_frame(q->consumer_right, frames[1]); 152 + } 144 153 /* 145 154 * Drop our reference - we don't need it anymore. If the consumer wants to keep it, they will have 146 155 * referenced it in their push_frame handler.