annotate src/dmtimelinew.c @ 2298:b5abfff07ca9

Add new DMGrowBuf helper functions dmGrowBufCopyOffsSize() and dmGrowBufConstCopyOffsSize().
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 04 Jul 2019 10:54:16 +0300
parents 862a943afff4
children 9807ae37ad69
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
27949209238b Update copyrights.
Matti Hamalainen <ccr@tnsp.org>
parents: 834
diff changeset
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
08ea68abb1f8 Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 350
diff changeset
7 #include "dmengine.h"
327
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
8
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
9
2013
862a943afff4 Fix some warnings in regards to strncpy().
Matti Hamalainen <ccr@tnsp.org>
parents: 1881
diff changeset
10 static BOOL dmSaveFloatValue(DMResource *res, const DMFloat val)
327
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 char tmp[DT_FLOAT_STORE_SIZE];
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
13 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
14 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
15 }
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
2013
862a943afff4 Fix some warnings in regards to strncpy().
Matti Hamalainen <ccr@tnsp.org>
parents: 1881
diff changeset
18 static int dmSaveTimelinePoints(DMResource *res, const DMTimelinePoints *points, const int type)
327
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
19 {
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
20 int point;
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
21 Uint32 npoints;
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 number of points
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
24 npoints = points->npoints;
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
25 if (!dmf_write_le32(res, npoints))
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
26 return DMERR_FWRITE;
1102
e06abfde6c39 Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 863
diff changeset
27
327
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
28 // Save points
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
29 for (point = 0; point < points->npoints; point++)
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
30 {
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
31 DMTimelinePoint *pt = &(points->points[point]);
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
32 Uint32 ptype, ptime;
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
33 ptype = pt->type;
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
34 ptime = pt->time;
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
35 if (!dmf_write_le32(res, ptype) ||
346
882503ef7ab8 More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents: 328
diff changeset
36 !dmf_write_le32(res, ptime))
327
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
37 return DMERR_FWRITE;
346
882503ef7ab8 More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents: 328
diff changeset
38
882503ef7ab8 More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents: 328
diff changeset
39 switch (type)
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_INT:
882503ef7ab8 More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents: 328
diff changeset
42 if (!dmf_write_le32(res, pt->vint))
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_FLOAT:
882503ef7ab8 More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents: 328
diff changeset
47 if (!dmSaveFloatValue(res, pt->vfloat))
882503ef7ab8 More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents: 328
diff changeset
48 return DMERR_FWRITE;
882503ef7ab8 More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents: 328
diff changeset
49 break;
1102
e06abfde6c39 Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 863
diff changeset
50
346
882503ef7ab8 More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents: 328
diff changeset
51 case EFPT_VECTOR:
882503ef7ab8 More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents: 328
diff changeset
52 if (!dmSaveFloatValue(res, pt->vector.x) ||
882503ef7ab8 More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents: 328
diff changeset
53 !dmSaveFloatValue(res, pt->vector.y) ||
882503ef7ab8 More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents: 328
diff changeset
54 !dmSaveFloatValue(res, pt->vector.z) ||
882503ef7ab8 More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents: 328
diff changeset
55 !dmSaveFloatValue(res, pt->vector.W))
882503ef7ab8 More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents: 328
diff changeset
56 return DMERR_FWRITE;
882503ef7ab8 More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents: 328
diff changeset
57 break;
882503ef7ab8 More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents: 328
diff changeset
58
882503ef7ab8 More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents: 328
diff changeset
59 case EFPT_MATRIX:
882503ef7ab8 More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents: 328
diff changeset
60 {
882503ef7ab8 More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents: 328
diff changeset
61 int x, y;
882503ef7ab8 More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents: 328
diff changeset
62 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
63 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
64 {
882503ef7ab8 More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents: 328
diff changeset
65 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
66 return DMERR_FWRITE;
882503ef7ab8 More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents: 328
diff changeset
67 }
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 break;
882503ef7ab8 More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents: 328
diff changeset
70 }
327
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
71 }
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
72 return DMERR_OK;
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
73 }
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
2013
862a943afff4 Fix some warnings in regards to strncpy().
Matti Hamalainen <ccr@tnsp.org>
parents: 1881
diff changeset
76 static int dmSaveTimelineCurve(DMResource *res, const DMTimelineCurve *curve)
327
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
77 {
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
78 int err;
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
79
638
b22db2832f3e Some work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 564
diff changeset
80 if (!dmf_write_byte(res, curve->enabled))
b22db2832f3e Some work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 564
diff changeset
81 return DMERR_FWRITE;
b22db2832f3e Some work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 564
diff changeset
82
346
882503ef7ab8 More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents: 328
diff changeset
83 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
84 return err;
1102
e06abfde6c39 Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 863
diff changeset
85
327
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
86 return DMERR_OK;
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
87 }
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
2013
862a943afff4 Fix some warnings in regards to strncpy().
Matti Hamalainen <ccr@tnsp.org>
parents: 1881
diff changeset
90 static int dmSaveTimelineEventParam(DMResource *res, const DMTimelineEventParam *param)
327
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 int err;
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
93 DMFTimelineEventParam hdr;
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
94 Uint16 len;
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 strncpy(hdr.name, param->name, sizeof(hdr.name));
2013
862a943afff4 Fix some warnings in regards to strncpy().
Matti Hamalainen <ccr@tnsp.org>
parents: 1881
diff changeset
97 hdr.name[sizeof(hdr.name) - 1] = 0;
327
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
f248defe7484 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 346
diff changeset
110 if ((err = dmSaveTimelinePoints(res, &param->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
2013
862a943afff4 Fix some warnings in regards to strncpy().
Matti Hamalainen <ccr@tnsp.org>
parents: 1881
diff changeset
128 static int dmSaveTimelineEvent(DMResource *res, const 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));
2013
862a943afff4 Fix some warnings in regards to strncpy().
Matti Hamalainen <ccr@tnsp.org>
parents: 1881
diff changeset
134 hdr.effectName[sizeof(hdr.effectName) - 1] = 0;
862a943afff4 Fix some warnings in regards to strncpy().
Matti Hamalainen <ccr@tnsp.org>
parents: 1881
diff changeset
135
327
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
136 hdr.start = event->start;
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
137 hdr.duration = event->duration;
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
138 hdr.nparams = event->nparams;
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
139
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
140 if (!dmf_write_le32(res, hdr.start) ||
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
141 !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
142 !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
143 !dmf_write_le32(res, hdr.nparams))
346
882503ef7ab8 More work on timeline saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents: 328
diff changeset
144 return DMERR_FWRITE;
327
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 for (param = 0; param < event->nparams; param++)
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 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
149 return err;
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
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
152 return DMERR_OK;
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
153 }
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
2013
862a943afff4 Fix some warnings in regards to strncpy().
Matti Hamalainen <ccr@tnsp.org>
parents: 1881
diff changeset
156 static int dmSaveTimelineTrack(DMResource *res, const DMTimelineTrack *track)
327
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 int event, err;
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
159 DMFTimelineTrack hdr;
1102
e06abfde6c39 Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 863
diff changeset
160
327
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
161 strncpy(hdr.name, track->name, sizeof(hdr.name));
2013
862a943afff4 Fix some warnings in regards to strncpy().
Matti Hamalainen <ccr@tnsp.org>
parents: 1881
diff changeset
162 hdr.name[sizeof(hdr.name) - 1] = 0;
327
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
163
638
b22db2832f3e Some work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 564
diff changeset
164 if (!dmf_write_le32(res, track->index) ||
b22db2832f3e Some work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 564
diff changeset
165 !dmf_write_le32(res, track->layer) ||
b22db2832f3e Some work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 564
diff changeset
166 !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
167 !dmf_write_byte(res, track->enabled) ||
b22db2832f3e Some work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 564
diff changeset
168 !dmf_write_le32(res, track->nevents))
327
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
169 return DMERR_FWRITE;
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
170
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
171 for (event = 0; event < track->nevents; event++)
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 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
174 return err;
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
175 }
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
176
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
177 if ((err = dmSaveTimelineCurve(res, &(track->composite))) != DMERR_OK)
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
178 return err;
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
179
328
dd7b1356d726 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 327
diff changeset
180 return DMERR_OK;
dd7b1356d726 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 327
diff changeset
181 }
dd7b1356d726 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 327
diff changeset
182
dd7b1356d726 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 327
diff changeset
183
2013
862a943afff4 Fix some warnings in regards to strncpy().
Matti Hamalainen <ccr@tnsp.org>
parents: 1881
diff changeset
184 int dmSaveTimeline(DMResource *res, const DMTimeline *tl)
328
dd7b1356d726 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 327
diff changeset
185 {
327
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
186 int track, err;
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
187 DMFTimeline hdr;
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
188
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
189 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
190 strncpy(hdr.name, tl->name, sizeof(hdr.name));
2013
862a943afff4 Fix some warnings in regards to strncpy().
Matti Hamalainen <ccr@tnsp.org>
parents: 1881
diff changeset
191 hdr.name[sizeof(hdr.name) - 1] = 0;
862a943afff4 Fix some warnings in regards to strncpy().
Matti Hamalainen <ccr@tnsp.org>
parents: 1881
diff changeset
192
327
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
193 hdr.ntracks = tl->ntracks;
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
194 hdr.duration = tl->duration;
1102
e06abfde6c39 Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 863
diff changeset
195
554
d4b84101e480 Remove useless (Uint8 *) typecasts now that dmf_{read,write}_str() uses void.
Matti Hamalainen <ccr@tnsp.org>
parents: 402
diff changeset
196 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
197 !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
198 !dmf_write_le32(res, hdr.ntracks) ||
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
199 !dmf_write_le32(res, hdr.duration))
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
200 return DMERR_FWRITE;
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 for (track = 0; track < tl->ntracks; track++)
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
203 {
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
204 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
205 return err;
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
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
208 return DMERR_OK;
328
dd7b1356d726 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 327
diff changeset
209 }
dd7b1356d726 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 327
diff changeset
210
dd7b1356d726 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 327
diff changeset
211
327
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
212 int dmTimelineNew(DMTimeline **ptl, const char *name)
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
213 {
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
214 DMTimeline *tl;
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
215 if ((*ptl = tl = dmMalloc0(sizeof(DMTimeline))) == NULL)
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
216 return DMERR_MALLOC;
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 tl->name = dm_strdup(name);
1102
e06abfde6c39 Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 863
diff changeset
219
327
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
220 return DMERR_OK;
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
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 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
225 {
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
226 DMTimelineTrack *track;
1102
e06abfde6c39 Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 863
diff changeset
227
327
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
228 if ((*ptrack = track = dmMalloc0(sizeof(DMTimelineTrack))) == NULL)
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
229 return DMERR_MALLOC;
1102
e06abfde6c39 Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 863
diff changeset
230
327
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
231 track->name = dm_strdup(name);
398
8660c6005032 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 395
diff changeset
232 track->enabled = TRUE;
327
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
233
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
234 if (tl->ntracks + 1 >= tl->nallocated)
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
235 {
834
9623b9b548d4 Reallocation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 812
diff changeset
236 void *ptmp = dmRealloc(tl->tracks, sizeof(DMTimelineTrack *) * (tl->nallocated + 16));
9623b9b548d4 Reallocation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 812
diff changeset
237 if (ptmp == NULL)
9623b9b548d4 Reallocation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 812
diff changeset
238 return DMERR_MALLOC;
327
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
239 tl->nallocated += 16;
834
9623b9b548d4 Reallocation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 812
diff changeset
240 tl->tracks = ptmp;
327
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
241 }
1102
e06abfde6c39 Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 863
diff changeset
242
327
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
243 tl->tracks[tl->ntracks] = track;
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
244 tl->ntracks++;
1102
e06abfde6c39 Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 863
diff changeset
245
327
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
246 return DMERR_OK;
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
247 }
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
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
250 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
251 {
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
252 DMTimelineEvent *ev;
1102
e06abfde6c39 Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 863
diff changeset
253
327
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
254 if ((*pev = ev = dmMalloc0(sizeof(DMTimelineEvent))) == NULL)
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
255 return DMERR_MALLOC;
1102
e06abfde6c39 Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 863
diff changeset
256
327
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
257 ev->start = start;
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
258 ev->duration = duration;
1102
e06abfde6c39 Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 863
diff changeset
259
327
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
260 if (track->nevents + 1 >= track->nallocated)
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
261 {
834
9623b9b548d4 Reallocation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 812
diff changeset
262 void *ptmp = dmRealloc(track->events, sizeof(DMTimelineEvent *) * (track->nallocated + 16));
9623b9b548d4 Reallocation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 812
diff changeset
263 if (ptmp == NULL)
9623b9b548d4 Reallocation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 812
diff changeset
264 return DMERR_MALLOC;
327
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
265 track->nallocated += 16;
834
9623b9b548d4 Reallocation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 812
diff changeset
266 track->events = ptmp;
327
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
267 }
1102
e06abfde6c39 Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 863
diff changeset
268
327
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
269 track->events[track->nevents] = ev;
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
270 track->nevents++;
1102
e06abfde6c39 Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 863
diff changeset
271
327
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
272 return DMERR_OK;
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
273 }
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
274
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
275
402
0f290af63fc1 Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents: 399
diff changeset
276 int dmTimelineEventSetEffect(DMTimelineEvent *event, DMEffect *ef)
327
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 int param;
402
0f290af63fc1 Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents: 399
diff changeset
279 if (ef == NULL)
327
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
280 return DMERR_INVALID_DATA;
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
281
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
282 event->effect = ef;
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
283 event->nparams = ef->nparams;
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
284 event->params = dmCalloc(ef->nparams, sizeof(DMTimelineEventParam));
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
285 if (event->params == NULL)
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
286 return DMERR_MALLOC;
1102
e06abfde6c39 Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 863
diff changeset
287
327
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
288 for (param = 0; param < ef->nparams; param++)
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
289 {
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
290 DMTimelineEventParam *psrc = &ef->params[param],
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
291 *pdst = &event->params[param];
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 pdst->name = dm_strdup(psrc->name);
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
294 pdst->type = psrc->type;
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
295 pdst->vstr = dm_strdup(psrc->vstr);
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
296
347
f248defe7484 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 346
diff changeset
297 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
298 {
347
f248defe7484 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 346
diff changeset
299 pdst->pts.npoints = psrc->pts.npoints;
f248defe7484 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 346
diff changeset
300 pdst->pts.nallocated = psrc->pts.nallocated;
f248defe7484 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 346
diff changeset
301 pdst->pts.points = dmMalloc(psrc->pts.nallocated * sizeof(DMTimelinePoint));
f248defe7484 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 346
diff changeset
302 if (pdst->pts.points == NULL)
327
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
303 return DMERR_MALLOC;
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
304
347
f248defe7484 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 346
diff changeset
305 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
306 }
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
307 }
1102
e06abfde6c39 Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 863
diff changeset
308
327
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
309 return DMERR_OK;
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
310 }
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
311
2964947674d1 More work on the timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
312
402
0f290af63fc1 Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents: 399
diff changeset
313 int dmTimelineEventSetEffectByIndex(DMTimelineEvent *event, const int 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 if (index < 0 || index >= nengineEffects)
0f290af63fc1 Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents: 399
diff changeset
316 return DMERR_INVALID_DATA;
0f290af63fc1 Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents: 399
diff changeset
317
0f290af63fc1 Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents: 399
diff changeset
318 return dmTimelineEventSetEffect(event, &engineEffects[index]);
0f290af63fc1 Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents: 399
diff changeset
319 }
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 int dmTimelineEventSetEffectByName(DMTimelineEvent *event, const char *name)
0f290af63fc1 Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents: 399
diff changeset
323 {
0f290af63fc1 Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents: 399
diff changeset
324 return dmTimelineEventSetEffect(event, engineFindEffectByName(name));
0f290af63fc1 Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents: 399
diff changeset
325 }
0f290af63fc1 Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents: 399
diff changeset
326
0f290af63fc1 Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents: 399
diff changeset
327
395
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
328 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
329 {
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
330 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
331 return DMERR_OK;
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
332
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
333 dst->npoints = src->npoints;
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
334 dst->nallocated = src->nallocated;
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
335 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
336 if (dst->points == NULL)
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
337 return DMERR_MALLOC;
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 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
340
395
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
341 return DMERR_OK;
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
342 }
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
343
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
344
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
345 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
346 {
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
347 dst->name = dm_strdup(src->name);
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
348 dst->type = src->type;
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
349 dst->vstr = dm_strdup(src->vstr);
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
350
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
351 return dmCopyTimelinePoints(&src->pts, &dst->pts);
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
352 }
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
353
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
354
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
355 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
356 {
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
357 int param;
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
358 DMTimelineEvent *dst;
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
359 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
360 return DMERR_MALLOC;
1102
e06abfde6c39 Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 863
diff changeset
361
395
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
362 dst->start = src->start;
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
363 dst->duration = src->duration;
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
364 dst->nparams = src->nparams;
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
365 dst->effect = src->effect;
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
366 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
367 if (dst->params == NULL)
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
368 return DMERR_MALLOC;
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
369
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
370 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
371 {
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
372 int err;
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
373 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
374 return err;
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
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
377 return DMERR_OK;
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
378 }
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
379
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 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
382 {
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
383 dst->enabled = src->enabled;
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
384 return dmCopyTimelinePoints(&(src->points), &(dst->points));
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
385 }
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
386
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
387
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
388 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
389 {
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
390 int event, err;
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
391 DMTimelineTrack *dst;
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
392 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
393 return DMERR_MALLOC;
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
394
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
395 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
396 return DMERR_MALLOC;
1102
e06abfde6c39 Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 863
diff changeset
397
395
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
398 dst->name = dm_strdup(src->name);
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
399 dst->enabled = src->enabled;
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
400 dst->nevents = src->nevents;
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 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
403 {
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
404 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
405 return err;
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
406 }
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 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
409 return err;
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
410
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
411 return DMERR_OK;
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
412 }
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
413
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
414
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
415 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
416 {
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
417 int track, err;
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
418 DMTimeline *dst;
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
419 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
420 return DMERR_MALLOC;
1102
e06abfde6c39 Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 863
diff changeset
421
395
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
422 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
423 if (dst->tracks == NULL)
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
424 return DMERR_MALLOC;
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
425
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
426 dst->name = dm_strdup(src->name);
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
427 dst->duration = src->duration;
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
428 dst->ntracks = src->ntracks;
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
429
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
430 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
431 {
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
432 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
433 return err;
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
434 }
1102
e06abfde6c39 Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 863
diff changeset
435
395
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
436 return DMERR_OK;
530db8fa4569 Implement functions for copying timelines and timeline components.
Matti Hamalainen <ccr@tnsp.org>
parents: 368
diff changeset
437 }