dsys2
diff src/dsys.c @ 10:5ba9dd6742a0
fixed a crash
author | John Tsiombikas <nuclear@siggraph.org> |
---|---|
date | Sun, 04 Sep 2011 06:44:49 +0300 |
parents | 61cc1a525023 |
children | d7d173fcd44e |
line diff
1.1 --- a/src/dsys.c Fri Sep 02 19:12:12 2011 +0300 1.2 +++ b/src/dsys.c Sun Sep 04 06:44:49 2011 +0300 1.3 @@ -128,6 +128,7 @@ 1.4 perror("read_script: failed to allocate memory for an event\n"); 1.5 return -1; 1.6 } 1.7 + memset(ev, 0, sizeof *ev); 1.8 ev->t0 = dsys_msec_to_dtime(t0); 1.9 ev->t1 = dsys_msec_to_dtime(t1); 1.10 1.11 @@ -155,7 +156,7 @@ 1.12 1.13 demo->evlist = sort_evlist(demo->evlist, demo->num_ev); 1.14 1.15 - dbg_print_events(demo->evlist); 1.16 + /*dbg_print_events(demo->evlist);*/ 1.17 1.18 return 0; 1.19 } 1.20 @@ -214,7 +215,7 @@ 1.21 return; /* nothing changes */ 1.22 } 1.23 1.24 - while(demo->active->t1 <= demo->tm) { 1.25 + while(demo->active && demo->active->t1 <= demo->tm) { 1.26 proc_event(demo->active, demo->tm); 1.27 demo->active = demo->active->next; 1.28 } 1.29 @@ -239,11 +240,12 @@ 1.30 if(ev->val != val) { 1.31 struct callback *cb = ev->cblist; 1.32 1.33 + ev->val = val; 1.34 + 1.35 while(cb) { 1.36 cb->func(ev, cb->cls); 1.37 cb = cb->next; 1.38 } 1.39 - ev->val = val; 1.40 } 1.41 } 1.42 1.43 @@ -306,10 +308,15 @@ 1.44 tm = demo->duration; 1.45 } 1.46 1.47 + if(tm < demo->tm) { 1.48 + /* on backwards seek, invalidate the sliding window */ 1.49 + demo->nextev = demo->active = demo->evlist; 1.50 + } 1.51 + 1.52 demo->start_tm = demo->src_tm - tm; 1.53 demo->stoppage_tm = 0; 1.54 - 1.55 - demo->nextev = demo->active = demo->evlist; 1.56 + demo->stop_tm = demo->src_tm; 1.57 + demo->tm = tm; 1.58 1.59 /* recalculate events */ 1.60 ev = demo->evlist;