# HG changeset patch # User John Tsiombikas # Date 1315107889 -10800 # Node ID 5ba9dd6742a0c10a5ee84fbd0b74cf80d028618a # Parent 61cc1a52502353447cc7f0d6ed6b38942c650b26 fixed a crash diff -r 61cc1a525023 -r 5ba9dd6742a0 Makefile --- a/Makefile Fri Sep 02 19:12:12 2011 +0300 +++ b/Makefile Sun Sep 04 06:44:49 2011 +0300 @@ -1,3 +1,5 @@ +PREFIX = /usr/local + src = $(wildcard src/*.c) obj = $(src:.c=.o) dep = $(obj:.o=.d) @@ -32,3 +34,13 @@ .PHONY: cleandep cleandep: rm -f $(dep) + +.PHONY: install +install: + mkdir -p $(PREFIX)/include $(PREFIX)/lib + cp $(lib_a) $(PREFIX)/lib/$(lib_a) + cp src/dsys2.h $(PREFIX)/include/dsys2.h + +.PHONY: uninstall +uninstall: + rm -f $(PREFIX)/include/dsys2.h $(PREFIX)/lib/$(lib_a) diff -r 61cc1a525023 -r 5ba9dd6742a0 src/dsys.c --- a/src/dsys.c Fri Sep 02 19:12:12 2011 +0300 +++ b/src/dsys.c Sun Sep 04 06:44:49 2011 +0300 @@ -128,6 +128,7 @@ perror("read_script: failed to allocate memory for an event\n"); return -1; } + memset(ev, 0, sizeof *ev); ev->t0 = dsys_msec_to_dtime(t0); ev->t1 = dsys_msec_to_dtime(t1); @@ -155,7 +156,7 @@ demo->evlist = sort_evlist(demo->evlist, demo->num_ev); - dbg_print_events(demo->evlist); + /*dbg_print_events(demo->evlist);*/ return 0; } @@ -214,7 +215,7 @@ return; /* nothing changes */ } - while(demo->active->t1 <= demo->tm) { + while(demo->active && demo->active->t1 <= demo->tm) { proc_event(demo->active, demo->tm); demo->active = demo->active->next; } @@ -239,11 +240,12 @@ if(ev->val != val) { struct callback *cb = ev->cblist; + ev->val = val; + while(cb) { cb->func(ev, cb->cls); cb = cb->next; } - ev->val = val; } } @@ -306,10 +308,15 @@ tm = demo->duration; } + if(tm < demo->tm) { + /* on backwards seek, invalidate the sliding window */ + demo->nextev = demo->active = demo->evlist; + } + demo->start_tm = demo->src_tm - tm; demo->stoppage_tm = 0; - - demo->nextev = demo->active = demo->evlist; + demo->stop_tm = demo->src_tm; + demo->tm = tm; /* recalculate events */ ev = demo->evlist; diff -r 61cc1a525023 -r 5ba9dd6742a0 src/dsys2.h --- a/src/dsys2.h Fri Sep 02 19:12:12 2011 +0300 +++ b/src/dsys2.h Sun Sep 04 06:44:49 2011 +0300 @@ -13,6 +13,9 @@ DSYS_PERIODIC }; +#ifdef __cplusplus +extern "C" { +#endif struct dsys_demo *dsys_open(const char *fname); struct dsys_demo *dsys_open_stream(FILE *fp); @@ -60,5 +63,9 @@ float dsys_dtime_to_sec(demotime_t tm); unsigned long dsys_dtime_to_msec(demotime_t tm); +#ifdef __cplusplus +} +#endif + #endif /* DSYS2_H_ */