[PATCH evemu 5/5] Record events with an initial offset of 1µs

Peter Hutterer peter.hutterer at who-t.net
Thu Aug 6 17:58:26 PDT 2015


Since 63df84261355d, the first event frame always has a timestamp of 0.0. When
reading those events we'll replay the first event frame, and set evtime. On
the second frame, evtime is 0.0 which evemu_read_event_realtime() takes as
"uninitialized" and thus resets it again, causing the second frame to be
replayed immediately instead of waiting for the correct time.

Since this behavior is part of the API, work around this by giving the first
event an offset of 1µs. Since the 0 offset was to make reading event logs
easier, this offset won't hurt us. It won't change existing recordings, but
over time this will be less of an issue and it's less of a hack than trying to
work magic values into evemu_play/evemu_read_event_realtime.

The alternative to this hack would be to add another API (or break the current
one), but it's not yet worth it for the little gain we get from it.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/evemu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/evemu.c b/src/evemu.c
index ad45dd3..3ccb849 100644
--- a/src/evemu.c
+++ b/src/evemu.c
@@ -768,7 +768,7 @@ int evemu_record(FILE *fp, int fd, int ms)
 			long time;
 
 			if (offset == 0)
-				offset = time_to_long(&ev.time);
+				offset = time_to_long(&ev.time) - 1;
 
 			time = time_to_long(&ev.time);
 			ev.time = long_to_time(time - offset);
-- 
2.4.3



More information about the Input-tools mailing list