1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-01-31 10:11:17 +00:00

revent: fix playback timing

This fixes an issue introduced by commit 5965956

	revent: fix off-by-one in replay

This moved the updating of the current event to the beginning of the
body of the loop, after the check of the while loop to prevent attempting
to assign past the end of array. The problem is that one the conditions
in the check relies on the event being updated, so it need to happen
before that part of the loop condition check.

This move event update back to the end of the loop body, but it moves
the array bounds check from the while loop condition into the body, just
before the update but after the counter is incremented. This should
satisfy both, the counter being bounds checked before it is used, and
the event being updated to the next one to be played before the timing
check in the loop condition.
This commit is contained in:
Sergei Trofimov 2017-08-09 17:50:54 +01:00
parent 3f7d44de28
commit 362e93c4cb
3 changed files with 6 additions and 3 deletions

Binary file not shown.

Binary file not shown.

View File

@ -1264,15 +1264,18 @@ void replay(const char *filepath)
int32_t idx = (recording.events[i]).dev_idx;
struct input_event ev = (recording.events[i]).event;
while((i < recording.num_events) && !timercmp(&ev.time, &last_event_delta, !=)) {
idx = recording.events[i].dev_idx;
ev = recording.events[i].event;
while(!timercmp(&ev.time, &last_event_delta, !=)) {
ret = write(recording.devices.fds[idx], &ev, sizeof(ev));
if (ret != sizeof(ev))
die("Could not replay event");
dprintf("replayed event: type %d code %d value %d\n", ev.type, ev.code, ev.value);
i++;
if (i >= recording.num_events) {
break;
}
idx = recording.events[i].dev_idx;
ev = recording.events[i].event;
}
last_event_delta = ev.time;
}