diff --git a/src/emu/emu.c b/src/emu/emu.c index 29879aa..123cc5c 100644 --- a/src/emu/emu.c +++ b/src/emu/emu.c @@ -3,7 +3,7 @@ #define _POSIX_C_SOURCE 2 -#define ENABLE_DEBUG +//#define ENABLE_DEBUG #include "emu.h" @@ -45,7 +45,7 @@ emu_init(struct emu *emu, int argc, char *argv[]) return -1; } - if (player_init(&emu->player, &emu->trace) != 0) { + if (player_init(&emu->player, &emu->trace, 0) != 0) { err("cannot init player for trace '%s'\n", emu->args.tracedir); return -1; diff --git a/src/emu/ovnidump.c b/src/emu/ovnidump.c index 80cf05f..b4f22d7 100644 --- a/src/emu/ovnidump.c +++ b/src/emu/ovnidump.c @@ -99,7 +99,7 @@ main(int argc, char *argv[]) return 1; } - if (player_init(player, trace) != 0) { + if (player_init(player, trace, 1) != 0) { err("player_init failed"); return 1; } diff --git a/src/emu/player.c b/src/emu/player.c index 3253482..b3b6ce4 100644 --- a/src/emu/player.c +++ b/src/emu/player.c @@ -89,7 +89,7 @@ check_clock_gate(struct trace *trace) } int -player_init(struct player *player, struct trace *trace) +player_init(struct player *player, struct trace *trace, int unsorted) { memset(player, 0, sizeof(struct player)); @@ -98,10 +98,14 @@ player_init(struct player *player, struct trace *trace) player->first_event = 1; player->stream = NULL; player->trace = trace; + player->unsorted = unsorted; /* Load initial streams and events */ struct stream *stream; DL_FOREACH(trace->streams, stream) { + if (unsorted) + stream_allow_unsorted(stream); + int ret = step_stream(player, stream); if (ret > 0) { /* No more events */ @@ -114,8 +118,8 @@ player_init(struct player *player, struct trace *trace) /* Ensure the first event sclocks are not too far apart. Otherwise an * offset table is mandatory. */ - if (check_clock_gate(trace) != 0) { - err("check_clock_gate failed\n"); + if (unsorted == 0 && check_clock_gate(trace) != 0) { + err("check_clock_gate failed"); return -1; } @@ -147,9 +151,10 @@ update_clocks(struct player *player, struct stream *stream) } if (sclock < player->lastclock) { - err("backwards jump in time %ld -> %ld in stream '%s'\n", + err("backwards jump in time %ld -> %ld in stream '%s'", player->lastclock, sclock, stream->relpath); - return -1; + if (player->unsorted == 0) + return -1; } player->lastclock = sclock; diff --git a/src/emu/player.h b/src/emu/player.h index 3554669..06d09b3 100644 --- a/src/emu/player.h +++ b/src/emu/player.h @@ -16,11 +16,12 @@ struct player { int64_t lastclock; int64_t deltaclock; int first_event; + int unsorted; struct stream *stream; struct emu_ev ev; }; -int player_init(struct player *player, struct trace *trace); +int player_init(struct player *player, struct trace *trace, int unsorted); int player_step(struct player *player); struct emu_ev *player_ev(struct player *player); struct stream *player_stream(struct player *player);