Mercurial > hg > dmlib
annotate dmtimelinew.c @ 346:882503ef7ab8
More work on timeline saving and loading.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 16 Oct 2012 00:29:24 +0300 |
parents | dd7b1356d726 |
children | f248defe7484 |
rev | line source |
---|---|
320
fc79b57d4646
Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1 #include "dmtimeline.h" |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
2 #include "dmresw.h" |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
3 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
4 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
5 BOOL dmSaveFloatValue(DMResource *res, DMFloat val) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
6 { |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
7 char tmp[DT_FLOAT_STORE_SIZE]; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
8 snprintf(tmp, DT_FLOAT_STORE_SIZE, "%f", val); |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
9 return (dmf_write_str(res, (Uint8 *) tmp, DT_FLOAT_STORE_SIZE) == DT_FLOAT_STORE_SIZE); |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
10 } |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
11 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
12 |
346
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
13 int dmSaveTimelinePoints(DMResource *res, DMTimelinePoints *points, int type) |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
14 { |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
15 int point; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
16 Uint32 npoints; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
17 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
18 // Save number of points |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
19 npoints = points->npoints; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
20 if (!dmf_write_le32(res, npoints)) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
21 return DMERR_FWRITE; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
22 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
23 // Save points |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
24 for (point = 0; point < points->npoints; point++) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
25 { |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
26 DMTimelinePoint *pt = &(points->points[point]); |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
27 Uint32 ptype, ptime; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
28 ptype = pt->type; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
29 ptime = pt->time; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
30 if (!dmf_write_le32(res, ptype) || |
346
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
31 !dmf_write_le32(res, ptime)) |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
32 return DMERR_FWRITE; |
346
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
33 |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
34 switch (type) |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
35 { |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
36 case EFPT_INT: |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
37 if (!dmf_write_le32(res, pt->vint)) |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
38 return DMERR_FWRITE; |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
39 break; |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
40 |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
41 case EFPT_FLOAT: |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
42 if (!dmSaveFloatValue(res, pt->vfloat)) |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
43 return DMERR_FWRITE; |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
44 break; |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
45 |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
46 case EFPT_VECTOR: |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
47 if (!dmSaveFloatValue(res, pt->vector.x) || |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
48 !dmSaveFloatValue(res, pt->vector.y) || |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
49 !dmSaveFloatValue(res, pt->vector.z) || |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
50 !dmSaveFloatValue(res, pt->vector.W)) |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
51 return DMERR_FWRITE; |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
52 break; |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
53 |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
54 case EFPT_MATRIX: |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
55 { |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
56 int x, y; |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
57 for (y = 0; y < DM_MATRIX_SIZE; y++) |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
58 for (x = 0; x < DM_MATRIX_SIZE; x++) |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
59 { |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
60 if (!dmSaveFloatValue(res, pt->matrix.m[y][x])) |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
61 return DMERR_FWRITE; |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
62 } |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
63 } |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
64 break; |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
65 } |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
66 } |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
67 return DMERR_OK; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
68 } |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
69 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
70 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
71 int dmSaveTimelineCurve(DMResource *res, DMTimelineCurve *curve) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
72 { |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
73 int err; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
74 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
75 dmfputc(curve->enabled, res); |
346
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
76 if ((err = dmSaveTimelinePoints(res, &(curve->points), EFPT_FLOAT)) != DMERR_OK) |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
77 return err; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
78 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
79 return DMERR_OK; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
80 } |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
81 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
82 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
83 int dmSaveTimelineEventParam(DMResource *res, DMTimelineEventParam *param) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
84 { |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
85 int err; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
86 DMFTimelineEventParam hdr; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
87 Uint16 len; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
88 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
89 strncpy(hdr.name, param->name, sizeof(hdr.name)); |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
90 hdr.type = param->type; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
91 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
92 if (dmf_write_str(res, (Uint8 *) hdr.name, sizeof(hdr.name)) != sizeof(hdr.name) || |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
93 !dmf_write_le32(res, hdr.type)) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
94 return DMERR_FWRITE; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
95 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
96 switch (param->type) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
97 { |
346
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
98 case EFPT_INT: |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
99 case EFPT_FLOAT: |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
100 case EFPT_VECTOR: |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
101 case EFPT_MATRIX: |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
102 if ((err = dmSaveTimelinePoints(res, ¶m->vpts, param->type)) != DMERR_OK) |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
103 return err; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
104 break; |
346
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
105 |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
106 case EFPT_STRING: |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
107 len = strlen(param->vstr); |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
108 if (!dmf_write_le16(res, len)) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
109 return DMERR_FWRITE; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
110 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
111 if (dmf_write_str(res, (Uint8 *) param->vstr, len) != len) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
112 return DMERR_FWRITE; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
113 break; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
114 } |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
115 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
116 return DMERR_OK; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
117 } |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
118 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
119 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
120 int dmSaveTimelineEvent(DMResource *res, DMTimelineEvent *event) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
121 { |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
122 int param, err; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
123 DMFTimelineEvent hdr; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
124 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
125 strncpy(hdr.effectName, event->effect->name, sizeof(hdr.effectName)); |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
126 hdr.start = event->start; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
127 hdr.duration = event->duration; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
128 hdr.nparams = event->nparams; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
129 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
130 if (!dmf_write_le32(res, hdr.start) || |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
131 !dmf_write_le32(res, hdr.duration) || |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
132 dmf_write_str(res, (Uint8 *) hdr.effectName, sizeof(hdr.effectName)) != sizeof(hdr.effectName) || |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
133 !dmf_write_le32(res, hdr.nparams)) |
346
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
134 return DMERR_FWRITE; |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
135 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
136 for (param = 0; param < event->nparams; param++) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
137 { |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
138 if ((err = dmSaveTimelineEventParam(res, &(event->params[param]))) != DMERR_OK) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
139 return err; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
140 } |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
141 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
142 return DMERR_OK; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
143 } |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
144 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
145 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
146 int dmSaveTimelineTrack(DMResource *res, DMTimelineTrack *track) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
147 { |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
148 int event, err; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
149 DMFTimelineTrack hdr; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
150 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
151 strncpy(hdr.name, track->name, sizeof(hdr.name)); |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
152 hdr.enabled = track->enabled; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
153 hdr.nevents = track->nevents; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
154 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
155 if (dmf_write_str(res, (Uint8 *) &hdr.name, sizeof(hdr.name)) != sizeof(hdr.name)) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
156 return DMERR_FWRITE; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
157 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
158 dmfputc(hdr.enabled, res); |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
159 if (!dmf_write_le32(res, hdr.nevents)) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
160 return DMERR_FWRITE; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
161 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
162 for (event = 0; event < track->nevents; event++) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
163 { |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
164 if ((err = dmSaveTimelineEvent(res, track->events[event])) != DMERR_OK) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
165 return err; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
166 } |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
167 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
168 if ((err = dmSaveTimelineCurve(res, &(track->composite))) != DMERR_OK) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
169 return err; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
170 |
328 | 171 return DMERR_OK; |
172 } | |
173 | |
174 | |
175 int dmSaveTimeline(DMResource *res, DMTimeline *tl) | |
176 { | |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
177 int track, err; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
178 DMFTimeline hdr; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
179 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
180 memcpy(&hdr.magic, DT_MAGIC_ID, sizeof(hdr.magic)); |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
181 strncpy(hdr.name, tl->name, sizeof(hdr.name)); |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
182 hdr.ntracks = tl->ntracks; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
183 hdr.duration = tl->duration; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
184 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
185 if (dmf_write_str(res, (Uint8 *) hdr.magic, sizeof(hdr.magic)) != sizeof(hdr.magic) || |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
186 dmf_write_str(res, (Uint8 *) hdr.name, sizeof(hdr.name)) != sizeof(hdr.name) || |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
187 !dmf_write_le32(res, hdr.ntracks) || |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
188 !dmf_write_le32(res, hdr.duration)) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
189 return DMERR_FWRITE; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
190 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
191 for (track = 0; track < tl->ntracks; track++) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
192 { |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
193 if ((err = dmSaveTimelineTrack(res, tl->tracks[track])) != DMERR_OK) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
194 return err; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
195 } |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
196 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
197 return DMERR_OK; |
328 | 198 } |
199 | |
200 | |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
201 int dmTimelineNew(DMTimeline **ptl, const char *name) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
202 { |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
203 DMTimeline *tl; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
204 if ((*ptl = tl = dmMalloc0(sizeof(DMTimeline))) == NULL) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
205 return DMERR_MALLOC; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
206 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
207 tl->name = dm_strdup(name); |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
208 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
209 return DMERR_OK; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
210 } |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
211 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
212 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
213 int dmTimelineAddTrack(DMTimeline *tl, DMTimelineTrack **ptrack, const char *name) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
214 { |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
215 DMTimelineTrack *track; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
216 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
217 if ((*ptrack = track = dmMalloc0(sizeof(DMTimelineTrack))) == NULL) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
218 return DMERR_MALLOC; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
219 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
220 track->name = dm_strdup(name); |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
221 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
222 if (tl->ntracks + 1 >= tl->nallocated) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
223 { |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
224 tl->nallocated += 16; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
225 tl->tracks = dmRealloc(tl->tracks, sizeof(DMTimelineTrack *) * tl->nallocated); |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
226 if (tl->tracks == NULL) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
227 return DMERR_MALLOC; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
228 } |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
229 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
230 tl->tracks[tl->ntracks] = track; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
231 tl->ntracks++; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
232 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
233 return DMERR_OK; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
234 } |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
235 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
236 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
237 int dmTimelineTrackAddEvent(DMTimelineTrack *track, int start, int duration, DMTimelineEvent **pev) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
238 { |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
239 DMTimelineEvent *ev; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
240 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
241 if ((*pev = ev = dmMalloc0(sizeof(DMTimelineEvent))) == NULL) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
242 return DMERR_MALLOC; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
243 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
244 ev->start = start; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
245 ev->duration = duration; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
246 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
247 if (track->nevents + 1 >= track->nallocated) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
248 { |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
249 track->nallocated += 16; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
250 track->events = dmRealloc(track->events, sizeof(DMTimelineEvent *) * track->nallocated); |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
251 if (track->events == NULL) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
252 return DMERR_MALLOC; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
253 } |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
254 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
255 track->events[track->nevents] = ev; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
256 track->nevents++; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
257 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
258 return DMERR_OK; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
259 } |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
260 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
261 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
262 int dmTimelineEventSetEffect(DMTimelineEvent *event, const char *name) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
263 { |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
264 int param; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
265 DMEffect *ef; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
266 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
267 if ((ef = dmFindEffectByName(name)) == NULL) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
268 return DMERR_INVALID_DATA; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
269 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
270 event->effect = ef; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
271 event->nparams = ef->nparams; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
272 event->params = dmCalloc(ef->nparams, sizeof(DMTimelineEventParam)); |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
273 if (event->params == NULL) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
274 return DMERR_MALLOC; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
275 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
276 for (param = 0; param < ef->nparams; param++) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
277 { |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
278 DMTimelineEventParam *psrc = &ef->params[param], |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
279 *pdst = &event->params[param]; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
280 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
281 pdst->name = dm_strdup(psrc->name); |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
282 pdst->type = psrc->type; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
283 pdst->vstr = dm_strdup(psrc->vstr); |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
284 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
285 if (psrc->vpts.points != NULL && psrc->vpts.npoints > 0) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
286 { |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
287 pdst->vpts.npoints = psrc->vpts.npoints; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
288 pdst->vpts.nallocated = psrc->vpts.nallocated; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
289 pdst->vpts.points = dmMalloc(psrc->vpts.nallocated * sizeof(DMTimelinePoint)); |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
290 if (pdst->vpts.points == NULL) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
291 return DMERR_MALLOC; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
292 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
293 memcpy(pdst->vpts.points, psrc->vpts.points, pdst->vpts.npoints * sizeof(DMTimelinePoint)); |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
294 } |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
295 } |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
296 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
297 return DMERR_OK; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
298 } |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
299 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
300 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
301 DMTimelineEvent *dmTimelineGetEventAt(DMTimelineTrack *track, const int time) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
302 { |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
303 int event; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
304 for (event = 0; event < track->nevents; event++) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
305 { |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
306 DMTimelineEvent *ev = track->events[event]; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
307 if (time >= ev->start && time <= ev->start + ev->duration) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
308 return ev; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
309 } |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
310 return NULL; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
311 } |