Fail gracefully when a unknown stream is found

This commit is contained in:
Rodrigo Arias 2023-02-23 16:13:54 +01:00 committed by Rodrigo Arias Mallo
parent 0eb88af4b9
commit 8bf5d8c571
2 changed files with 20 additions and 6 deletions

View File

@ -92,15 +92,24 @@ emu_connect(struct emu *emu)
return 0; return 0;
} }
static void static int
set_current(struct emu *emu) set_current(struct emu *emu)
{ {
emu->ev = player_ev(&emu->player); emu->ev = player_ev(&emu->player);
emu->stream = player_stream(&emu->player); emu->stream = player_stream(&emu->player);
struct lpt *lpt = system_get_lpt(emu->stream); struct lpt *lpt = system_get_lpt(emu->stream);
if (lpt == NULL) {
/* For now die if we have a unknown stream */
err("event from unknown stream: %s",
emu->stream->path);
return -1;
}
emu->loom = lpt->loom; emu->loom = lpt->loom;
emu->proc = lpt->proc; emu->proc = lpt->proc;
emu->thread = lpt->thread; emu->thread = lpt->thread;
return 0;
} }
static void static void
@ -145,7 +154,10 @@ emu_step(struct emu *emu)
return -1; return -1;
} }
set_current(emu); if (set_current(emu) != 0) {
err("cannot set current event information");
return -1;
}
dbg("----- mvc=%s dclock=%ld -----", emu->ev->mcv, emu->ev->dclock); dbg("----- mvc=%s dclock=%ld -----", emu->ev->mcv, emu->ev->dclock);

View File

@ -413,10 +413,9 @@ init_offsets(struct system *sys, struct trace *trace)
for (struct stream *s = trace->streams; s; s = s->next) { for (struct stream *s = trace->streams; s; s = s->next) {
struct lpt *lpt = system_get_lpt(s); struct lpt *lpt = system_get_lpt(s);
if (lpt == NULL) { /* Not LPT stream */
err("cannot get stream lpt"); if (lpt == NULL)
return -1; continue;
}
int64_t offset = lpt->loom->clock_offset; int64_t offset = lpt->loom->clock_offset;
if (stream_clkoff_set(s, offset) != 0) { if (stream_clkoff_set(s, offset) != 0) {
@ -478,6 +477,9 @@ system_get_lpt(struct stream *stream)
{ {
struct lpt *lpt = stream_data_get(stream); struct lpt *lpt = stream_data_get(stream);
if (lpt == NULL)
return NULL;
if (lpt->stream != stream) if (lpt->stream != stream)
die("inconsistent stream in lpt map"); die("inconsistent stream in lpt map");