Mercurial > hg > dmlib
annotate src/dmtimelinew.c @ 1315:7687412f9aef
Fix jssmod sample conversion flags storing .. urgh.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 20 Aug 2017 01:54:54 +0300 |
parents | e06abfde6c39 |
children | 73545a442ffe |
rev | line source |
---|---|
642
0888971cbff8
Add comment headers to several files.
Matti Hamalainen <ccr@tnsp.org>
parents:
638
diff
changeset
|
1 /* |
0888971cbff8
Add comment headers to several files.
Matti Hamalainen <ccr@tnsp.org>
parents:
638
diff
changeset
|
2 * dmlib |
0888971cbff8
Add comment headers to several files.
Matti Hamalainen <ccr@tnsp.org>
parents:
638
diff
changeset
|
3 * -- Timeline file writing |
0888971cbff8
Add comment headers to several files.
Matti Hamalainen <ccr@tnsp.org>
parents:
638
diff
changeset
|
4 * Programmed and designed by Matti 'ccr' Hamalainen |
863 | 5 * (C) Copyright 2012-2015 Tecnic Software productions (TNSP) |
642
0888971cbff8
Add comment headers to several files.
Matti Hamalainen <ccr@tnsp.org>
parents:
638
diff
changeset
|
6 */ |
368 | 7 #include "dmengine.h" |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
8 #include "dmresw.h" |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
9 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
10 |
350
834f3b686ad3
More work on timeline stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
347
diff
changeset
|
11 static BOOL dmSaveFloatValue(DMResource *res, DMFloat val) |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
12 { |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
13 char tmp[DT_FLOAT_STORE_SIZE]; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
14 snprintf(tmp, DT_FLOAT_STORE_SIZE, "%f", val); |
554
d4b84101e480
Remove useless (Uint8 *) typecasts now that dmf_{read,write}_str() uses void.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
15 return !dmf_write_str(res, tmp, DT_FLOAT_STORE_SIZE); |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
16 } |
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 |
350
834f3b686ad3
More work on timeline stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
347
diff
changeset
|
19 static 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
|
20 { |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
21 int point; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
22 Uint32 npoints; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
23 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
24 // Save number of points |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
25 npoints = points->npoints; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
26 if (!dmf_write_le32(res, npoints)) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
27 return DMERR_FWRITE; |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
28 |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
29 // Save points |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
30 for (point = 0; point < points->npoints; point++) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
31 { |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
32 DMTimelinePoint *pt = &(points->points[point]); |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
33 Uint32 ptype, ptime; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
34 ptype = pt->type; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
35 ptime = pt->time; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
36 if (!dmf_write_le32(res, ptype) || |
346
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
37 !dmf_write_le32(res, ptime)) |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
38 return DMERR_FWRITE; |
346
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
39 |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
40 switch (type) |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
41 { |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
42 case EFPT_INT: |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
43 if (!dmf_write_le32(res, pt->vint)) |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
44 return DMERR_FWRITE; |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
45 break; |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
46 |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
47 case EFPT_FLOAT: |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
48 if (!dmSaveFloatValue(res, pt->vfloat)) |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
49 return DMERR_FWRITE; |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
50 break; |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
51 |
346
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
52 case EFPT_VECTOR: |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
53 if (!dmSaveFloatValue(res, pt->vector.x) || |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
54 !dmSaveFloatValue(res, pt->vector.y) || |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
55 !dmSaveFloatValue(res, pt->vector.z) || |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
56 !dmSaveFloatValue(res, pt->vector.W)) |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
57 return DMERR_FWRITE; |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
58 break; |
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 case EFPT_MATRIX: |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
61 { |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
62 int x, y; |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
63 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
|
64 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
|
65 { |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
66 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
|
67 return DMERR_FWRITE; |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
68 } |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
69 } |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
70 break; |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
71 } |
327
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 return DMERR_OK; |
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 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
76 |
350
834f3b686ad3
More work on timeline stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
347
diff
changeset
|
77 static int dmSaveTimelineCurve(DMResource *res, DMTimelineCurve *curve) |
327
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 int err; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
80 |
638
b22db2832f3e
Some work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
564
diff
changeset
|
81 if (!dmf_write_byte(res, curve->enabled)) |
b22db2832f3e
Some work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
564
diff
changeset
|
82 return DMERR_FWRITE; |
b22db2832f3e
Some work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
564
diff
changeset
|
83 |
346
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
84 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
|
85 return err; |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
86 |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
87 return DMERR_OK; |
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 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
90 |
350
834f3b686ad3
More work on timeline stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
347
diff
changeset
|
91 static int dmSaveTimelineEventParam(DMResource *res, DMTimelineEventParam *param) |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
92 { |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
93 int err; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
94 DMFTimelineEventParam hdr; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
95 Uint16 len; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
96 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
97 strncpy(hdr.name, param->name, sizeof(hdr.name)); |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
98 hdr.type = param->type; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
99 |
554
d4b84101e480
Remove useless (Uint8 *) typecasts now that dmf_{read,write}_str() uses void.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
100 if (!dmf_write_str(res, hdr.name, sizeof(hdr.name)) || |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
101 !dmf_write_le32(res, hdr.type)) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
102 return DMERR_FWRITE; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
103 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
104 switch (param->type) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
105 { |
346
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
106 case EFPT_INT: |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
107 case EFPT_FLOAT: |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
108 case EFPT_VECTOR: |
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
109 case EFPT_MATRIX: |
347 | 110 if ((err = dmSaveTimelinePoints(res, ¶m->pts, param->type)) != DMERR_OK) |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
111 return err; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
112 break; |
346
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
113 |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
114 case EFPT_STRING: |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
115 len = strlen(param->vstr); |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
116 if (!dmf_write_le16(res, len)) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
117 return DMERR_FWRITE; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
118 |
554
d4b84101e480
Remove useless (Uint8 *) typecasts now that dmf_{read,write}_str() uses void.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
119 if (!dmf_write_str(res, param->vstr, len)) |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
120 return DMERR_FWRITE; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
121 break; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
122 } |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
123 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
124 return DMERR_OK; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
125 } |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
126 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
127 |
350
834f3b686ad3
More work on timeline stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
347
diff
changeset
|
128 static int dmSaveTimelineEvent(DMResource *res, DMTimelineEvent *event) |
327
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 int param, err; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
131 DMFTimelineEvent hdr; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
132 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
133 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
|
134 hdr.start = event->start; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
135 hdr.duration = event->duration; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
136 hdr.nparams = event->nparams; |
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 (!dmf_write_le32(res, hdr.start) || |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
139 !dmf_write_le32(res, hdr.duration) || |
554
d4b84101e480
Remove useless (Uint8 *) typecasts now that dmf_{read,write}_str() uses void.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
140 !dmf_write_str(res, hdr.effectName, sizeof(hdr.effectName)) || |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
141 !dmf_write_le32(res, hdr.nparams)) |
346
882503ef7ab8
More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
328
diff
changeset
|
142 return DMERR_FWRITE; |
327
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 for (param = 0; param < event->nparams; param++) |
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 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
|
147 return err; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
148 } |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
149 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
150 return DMERR_OK; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
151 } |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
152 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
153 |
350
834f3b686ad3
More work on timeline stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
347
diff
changeset
|
154 static int dmSaveTimelineTrack(DMResource *res, DMTimelineTrack *track) |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
155 { |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
156 int event, err; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
157 DMFTimelineTrack hdr; |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
158 |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
159 strncpy(hdr.name, track->name, sizeof(hdr.name)); |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
160 |
638
b22db2832f3e
Some work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
564
diff
changeset
|
161 if (!dmf_write_le32(res, track->index) || |
b22db2832f3e
Some work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
564
diff
changeset
|
162 !dmf_write_le32(res, track->layer) || |
b22db2832f3e
Some work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
564
diff
changeset
|
163 !dmf_write_str(res, hdr.name, sizeof(hdr.name)) || |
b22db2832f3e
Some work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
564
diff
changeset
|
164 !dmf_write_byte(res, track->enabled) || |
b22db2832f3e
Some work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
564
diff
changeset
|
165 !dmf_write_le32(res, track->nevents)) |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
166 return DMERR_FWRITE; |
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 for (event = 0; event < track->nevents; event++) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
169 { |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
170 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
|
171 return err; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
172 } |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
173 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
174 if ((err = dmSaveTimelineCurve(res, &(track->composite))) != DMERR_OK) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
175 return err; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
176 |
328 | 177 return DMERR_OK; |
178 } | |
179 | |
180 | |
181 int dmSaveTimeline(DMResource *res, DMTimeline *tl) | |
182 { | |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
183 int track, err; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
184 DMFTimeline hdr; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
185 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
186 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
|
187 strncpy(hdr.name, tl->name, sizeof(hdr.name)); |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
188 hdr.ntracks = tl->ntracks; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
189 hdr.duration = tl->duration; |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
190 |
554
d4b84101e480
Remove useless (Uint8 *) typecasts now that dmf_{read,write}_str() uses void.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
191 if (!dmf_write_str(res, hdr.magic, sizeof(hdr.magic)) || |
d4b84101e480
Remove useless (Uint8 *) typecasts now that dmf_{read,write}_str() uses void.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
192 !dmf_write_str(res, hdr.name, sizeof(hdr.name)) || |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
193 !dmf_write_le32(res, hdr.ntracks) || |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
194 !dmf_write_le32(res, hdr.duration)) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
195 return DMERR_FWRITE; |
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 for (track = 0; track < tl->ntracks; track++) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
198 { |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
199 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
|
200 return err; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
201 } |
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 return DMERR_OK; |
328 | 204 } |
205 | |
206 | |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
207 int dmTimelineNew(DMTimeline **ptl, const char *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 DMTimeline *tl; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
210 if ((*ptl = tl = dmMalloc0(sizeof(DMTimeline))) == NULL) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
211 return DMERR_MALLOC; |
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 tl->name = dm_strdup(name); |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
214 |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
215 return DMERR_OK; |
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 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
218 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
219 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
|
220 { |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
221 DMTimelineTrack *track; |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
222 |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
223 if ((*ptrack = track = dmMalloc0(sizeof(DMTimelineTrack))) == NULL) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
224 return DMERR_MALLOC; |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
225 |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
226 track->name = dm_strdup(name); |
398 | 227 track->enabled = TRUE; |
327
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 if (tl->ntracks + 1 >= tl->nallocated) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
230 { |
834 | 231 void *ptmp = dmRealloc(tl->tracks, sizeof(DMTimelineTrack *) * (tl->nallocated + 16)); |
232 if (ptmp == NULL) | |
233 return DMERR_MALLOC; | |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
234 tl->nallocated += 16; |
834 | 235 tl->tracks = ptmp; |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
236 } |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
237 |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
238 tl->tracks[tl->ntracks] = track; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
239 tl->ntracks++; |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
240 |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
241 return DMERR_OK; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
242 } |
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 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
245 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
|
246 { |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
247 DMTimelineEvent *ev; |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
248 |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
249 if ((*pev = ev = dmMalloc0(sizeof(DMTimelineEvent))) == NULL) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
250 return DMERR_MALLOC; |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
251 |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
252 ev->start = start; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
253 ev->duration = duration; |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
254 |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
255 if (track->nevents + 1 >= track->nallocated) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
256 { |
834 | 257 void *ptmp = dmRealloc(track->events, sizeof(DMTimelineEvent *) * (track->nallocated + 16)); |
258 if (ptmp == NULL) | |
259 return DMERR_MALLOC; | |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
260 track->nallocated += 16; |
834 | 261 track->events = ptmp; |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
262 } |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
263 |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
264 track->events[track->nevents] = ev; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
265 track->nevents++; |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
266 |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
267 return DMERR_OK; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
268 } |
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 |
402
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
399
diff
changeset
|
271 int dmTimelineEventSetEffect(DMTimelineEvent *event, DMEffect *ef) |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
272 { |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
273 int param; |
402
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
399
diff
changeset
|
274 if (ef == NULL) |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
275 return DMERR_INVALID_DATA; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
276 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
277 event->effect = ef; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
278 event->nparams = ef->nparams; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
279 event->params = dmCalloc(ef->nparams, sizeof(DMTimelineEventParam)); |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
280 if (event->params == NULL) |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
281 return DMERR_MALLOC; |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
282 |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
283 for (param = 0; param < ef->nparams; param++) |
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 DMTimelineEventParam *psrc = &ef->params[param], |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
286 *pdst = &event->params[param]; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
287 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
288 pdst->name = dm_strdup(psrc->name); |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
289 pdst->type = psrc->type; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
290 pdst->vstr = dm_strdup(psrc->vstr); |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
291 |
347 | 292 if (psrc->pts.points != NULL && psrc->pts.npoints > 0) |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
293 { |
347 | 294 pdst->pts.npoints = psrc->pts.npoints; |
295 pdst->pts.nallocated = psrc->pts.nallocated; | |
296 pdst->pts.points = dmMalloc(psrc->pts.nallocated * sizeof(DMTimelinePoint)); | |
297 if (pdst->pts.points == NULL) | |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
298 return DMERR_MALLOC; |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
299 |
347 | 300 memcpy(pdst->pts.points, psrc->pts.points, pdst->pts.npoints * sizeof(DMTimelinePoint)); |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
301 } |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
302 } |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
303 |
327
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
304 return DMERR_OK; |
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 |
2964947674d1
More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
307 |
402
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
399
diff
changeset
|
308 int dmTimelineEventSetEffectByIndex(DMTimelineEvent *event, const int index) |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
399
diff
changeset
|
309 { |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
399
diff
changeset
|
310 if (index < 0 || index >= nengineEffects) |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
399
diff
changeset
|
311 return DMERR_INVALID_DATA; |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
399
diff
changeset
|
312 |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
399
diff
changeset
|
313 return dmTimelineEventSetEffect(event, &engineEffects[index]); |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
399
diff
changeset
|
314 } |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
399
diff
changeset
|
315 |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
399
diff
changeset
|
316 |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
399
diff
changeset
|
317 int dmTimelineEventSetEffectByName(DMTimelineEvent *event, const char *name) |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
399
diff
changeset
|
318 { |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
399
diff
changeset
|
319 return dmTimelineEventSetEffect(event, engineFindEffectByName(name)); |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
399
diff
changeset
|
320 } |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
399
diff
changeset
|
321 |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
399
diff
changeset
|
322 |
395
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
323 int dmCopyTimelinePoints(const DMTimelinePoints *src, DMTimelinePoints *dst) |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
324 { |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
325 if (src->points == NULL || src->npoints <= 0 || src->nallocated <= 0) |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
326 return DMERR_OK; |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
327 |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
328 dst->npoints = src->npoints; |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
329 dst->nallocated = src->nallocated; |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
330 dst->points = dmCalloc(src->nallocated, sizeof(DMTimelinePoint)); |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
331 if (dst->points == NULL) |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
332 return DMERR_MALLOC; |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
333 |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
334 memcpy(dst->points, src->points, sizeof(DMTimelinePoint) * src->npoints); |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
335 |
395
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
336 return DMERR_OK; |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
337 } |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
338 |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
339 |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
340 int dmCopyTimelineEventParam(const DMTimelineEventParam *src, DMTimelineEventParam *dst) |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
341 { |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
342 dst->name = dm_strdup(src->name); |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
343 dst->type = src->type; |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
344 dst->vstr = dm_strdup(src->vstr); |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
345 |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
346 return dmCopyTimelinePoints(&src->pts, &dst->pts); |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
347 } |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
348 |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
349 |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
350 int dmCopyTimelineEvent(const DMTimelineEvent *src, DMTimelineEvent **pdst) |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
351 { |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
352 int param; |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
353 DMTimelineEvent *dst; |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
354 if ((*pdst = dst = dmMalloc0(sizeof(DMTimelineEvent))) == NULL) |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
355 return DMERR_MALLOC; |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
356 |
395
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
357 dst->start = src->start; |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
358 dst->duration = src->duration; |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
359 dst->nparams = src->nparams; |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
360 dst->effect = src->effect; |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
361 dst->params = dmCalloc(src->nparams, sizeof(DMTimelineEventParam)); |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
362 if (dst->params == NULL) |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
363 return DMERR_MALLOC; |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
364 |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
365 for (param = 0; param < src->nparams; param++) |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
366 { |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
367 int err; |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
368 if ((err = dmCopyTimelineEventParam(&(src->params[param]), &(dst->params[param]))) != DMERR_OK) |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
369 return err; |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
370 } |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
371 |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
372 return DMERR_OK; |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
373 } |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
374 |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
375 |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
376 int dmCopyTimelineCurve(const DMTimelineCurve *src, DMTimelineCurve *dst) |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
377 { |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
378 dst->enabled = src->enabled; |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
379 return dmCopyTimelinePoints(&(src->points), &(dst->points)); |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
380 } |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
381 |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
382 |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
383 int dmCopyTimelineTrack(const DMTimelineTrack *src, DMTimelineTrack **pdst) |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
384 { |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
385 int event, err; |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
386 DMTimelineTrack *dst; |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
387 if ((*pdst = dst = dmMalloc0(sizeof(DMTimelineTrack))) == NULL) |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
388 return DMERR_MALLOC; |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
389 |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
390 if ((dst->events = dmCalloc(src->nevents, sizeof(DMTimelineEvent *))) == NULL) |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
391 return DMERR_MALLOC; |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
392 |
395
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
393 dst->name = dm_strdup(src->name); |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
394 dst->enabled = src->enabled; |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
395 dst->nevents = src->nevents; |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
396 |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
397 for (event = 0; event < src->nevents; event++) |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
398 { |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
399 if ((err = dmCopyTimelineEvent(src->events[event], &(dst->events[event]))) != DMERR_OK) |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
400 return err; |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
401 } |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
402 |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
403 if ((err = dmCopyTimelineCurve(&(src->composite), &(dst->composite))) != DMERR_OK) |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
404 return err; |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
405 |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
406 return DMERR_OK; |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
407 } |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
408 |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
409 |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
410 int dmCopyTimeline(const DMTimeline *src, DMTimeline **pdst) |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
411 { |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
412 int track, err; |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
413 DMTimeline *dst; |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
414 if ((*pdst = dst = dmMalloc0(sizeof(DMTimeline))) == NULL) |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
415 return DMERR_MALLOC; |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
416 |
395
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
417 dst->tracks = (DMTimelineTrack **) dmCalloc(src->ntracks, sizeof(DMTimelineTrack *)); |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
418 if (dst->tracks == NULL) |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
419 return DMERR_MALLOC; |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
420 |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
421 dst->name = dm_strdup(src->name); |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
422 dst->duration = src->duration; |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
423 dst->ntracks = src->ntracks; |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
424 |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
425 for (track = 0; track < src->ntracks; track++) |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
426 { |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
427 if ((err = dmCopyTimelineTrack(src->tracks[track], &(dst->tracks[track]))) != DMERR_OK) |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
428 return err; |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
429 } |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
430 |
395
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
431 return DMERR_OK; |
530db8fa4569
Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents:
368
diff
changeset
|
432 } |