mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-29 01:48:31 +00:00
u/sink: Ensure that image frames have monotonic timestamps
This commit is contained in:
parent
17e0c39df2
commit
d48792d9a9
|
@ -47,6 +47,9 @@ struct u_sink_force_genlock
|
||||||
pthread_mutex_t mutex;
|
pthread_mutex_t mutex;
|
||||||
pthread_cond_t cond;
|
pthread_cond_t cond;
|
||||||
|
|
||||||
|
//! Timestamp of the last frameset we pushed.
|
||||||
|
int64_t last_ts;
|
||||||
|
|
||||||
//! Should we keep running?
|
//! Should we keep running?
|
||||||
//! currently, true upon startup, false as we're exiting.
|
//! currently, true upon startup, false as we're exiting.
|
||||||
bool running;
|
bool running;
|
||||||
|
@ -137,10 +140,16 @@ force_genlock_mainloop(void *ptr)
|
||||||
frames[0]->timestamp = ts;
|
frames[0]->timestamp = ts;
|
||||||
frames[1]->timestamp = ts;
|
frames[1]->timestamp = ts;
|
||||||
|
|
||||||
// Send to the consumer, in left-right order.
|
if (ts == q->last_ts) {
|
||||||
xrt_sink_push_frame(q->consumer_left, frames[0]);
|
U_LOG_W("Got an image frame with a duplicate timestamp! Old: %lu; New: %lu", q->last_ts, ts);
|
||||||
xrt_sink_push_frame(q->consumer_right, frames[1]);
|
} else if (ts < q->last_ts) {
|
||||||
|
U_LOG_W("Got an image frame with a non-monotonically-increasing timestamp! Old: %lu; New: %lu",
|
||||||
|
q->last_ts, ts);
|
||||||
|
} else {
|
||||||
|
// Send to the consumer, in left-right order.
|
||||||
|
xrt_sink_push_frame(q->consumer_left, frames[0]);
|
||||||
|
xrt_sink_push_frame(q->consumer_right, frames[1]);
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Drop our reference - we don't need it anymore. If the consumer wants to keep it, they will have
|
* Drop our reference - we don't need it anymore. If the consumer wants to keep it, they will have
|
||||||
* referenced it in their push_frame handler.
|
* referenced it in their push_frame handler.
|
||||||
|
|
Loading…
Reference in a new issue