annotate dmtimeline.c @ 320:fc79b57d4646

Add in unfinished timeline code.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 14 Oct 2012 14:24:11 +0300
parents
children f2b65aa474c9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
320
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 #include "dmtimeline.h"
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 DMEffect *dmEffects = NULL;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 int ndmEffects = 0, ndmEffectsAlloc = 0;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 void **dmEffectData = NULL;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 int dmRegisterEffect(const DMEffect *ef)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 {
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 if (ef == NULL)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 return DMERR_NULLPTR;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 // Allocate more space for effects
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 if (ndmEffects + 1 >= ndmEffectsAlloc)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 {
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 ndmEffectsAlloc += 16;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 dmEffects = dmRealloc(dmEffects, sizeof(DMEffect) * ndmEffectsAlloc);
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 if (dmEffects == NULL)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 {
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 dmError("Could not expand effects structure.\n");
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 return DMERR_INIT_FAIL;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23 }
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25 dmEffectData = dmRealloc(dmEffectData, sizeof(void *) * ndmEffectsAlloc);
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26 if (dmEffectData == NULL)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 {
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28 dmError("Could not expand effects data structure.\n");
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29 return DMERR_INIT_FAIL;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30 }
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 }
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 // Copy effects structure
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 memcpy(dmEffects + ndmEffects, ef, sizeof(DMEffect));
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 dmEffectData[ndmEffects] = NULL;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37 ndmEffects++;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 return DMERR_OK;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 }
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43 int dmInitializeEffects()
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 {
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 int i, res;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 for (i = 0; i < ndmEffects; i++)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47 {
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48 if (dmEffects[i].init != NULL &&
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49 (res = dmEffects[i].init(&dmEffectData[i])) != DMERR_OK)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50 return res;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51 }
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53 return DMERR_OK;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54 }
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57 void dmShutdownEffects()
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58 {
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59 int i;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60 for (i = 0; i < ndmEffects; i++)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61 {
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62 if (dmEffects[i].shutdown != NULL)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63 dmEffects[i].shutdown(dmEffectData[i]);
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64 }
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65 }
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
68 DMEffect *dmFindEffect(const char *name, const int nparams)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
69 {
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70 int i;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
71 for (i = 0; i < ndmEffects; i++)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72 {
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73 if (strcmp(dmEffects[i].name, name) == 0 &&
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
74 dmEffects[i].nparams == nparams)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
75 return &dmEffects[i];
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
76 }
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
77 return NULL;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78 }
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
79
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
80
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81 int dmLoadFloatValue(DMResource *res, DMFloat *val)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
82 {
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83 char tmp[DT_FLOAT_STORE_SIZE + 1];
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84 if (dmf_read_str(res, (Uint8 *) tmp, DT_FLOAT_STORE_SIZE) != DT_FLOAT_STORE_SIZE)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
85 return DMERR_FREAD;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
87 tmp[DT_FLOAT_STORE_SIZE] = 0;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
88 *val = atof(tmp);
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
89 return DMERR_OK;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90 }
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
91
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
93 int dmLoadTimelinePoints(DMResource *res, DMTimelinePoints *points)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
94 {
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
95
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
96 return DMERR_OK;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
97 }
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
99
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
100 int dmLoadTimelineEventParam(DMResource *res, DMTimelineEventParam *param)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
101 {
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102 DMFTimelineEventParam hdr;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
103 int err;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
104 Uint16 len;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
105 Uint32 tmp32;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
106
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
107 if (dmf_read_str(res, (Uint8 *) &hdr.name, sizeof(hdr.name)) != sizeof(hdr.name))
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
108 return DMERR_FREAD;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
109 hdr.name[sizeof(hdr.name) - 1] = 0;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
110
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
111 if (!dmf_read_le32(res, &hdr.type))
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
112 return DMERR_FREAD;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
113
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
114 param->name = dm_strdup(hdr.name);
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
115 param->type = hdr.type;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
116
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
117 switch (hdr.type)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
118 {
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
119 case EFPT_POINTS:
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
120 break;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
121
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
122 case EFPT_INT:
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
123 if (!dmf_read_le32(res, &tmp32))
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
124 return DMERR_FREAD;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
125 param->vint = tmp32;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
126 break;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
127
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
128 case EFPT_FLOAT:
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
129 if ((err = dmLoadFloatValue(res, &param->vfloat)) != DMERR_OK)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
130 return err;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
131 break;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
132
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
133 case EFPT_STRING:
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
134 if (!dmf_read_le16(res, &len))
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
135 return DMERR_FREAD;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
136
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
137 param->vstr = dmMalloc((unsigned int)len + 1);
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
138 if (dmf_read_str(res, (Uint8 *) param->vstr, len) != len)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
139 return DMERR_FREAD;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
140
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
141 param->vstr[len] = 0;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
142 break;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
143 }
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
144
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
145 return DMERR_OK;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
146 }
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
147
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
148
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
149 int dmLoadTimelineEvent(DMResource *res, DMTimelineEvent **pevent)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
150 {
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
151 int param;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
152 DMFTimelineEvent hdr;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
153 DMTimelineEvent *event;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
154 if ((*pevent = event = dmMalloc0(sizeof(DMTimelineEvent))) == NULL)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
155 return DMERR_MALLOC;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
156
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
157 // Get basic event data
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
158 if (!dmf_read_le32(res, &hdr.startTime))
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
159 return DMERR_FREAD;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
160 if (!dmf_read_le32(res, &hdr.duration))
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
161 return DMERR_FREAD;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
162 if (dmf_read_str(res, (Uint8 *) &hdr.effectName, sizeof(hdr.effectName)) != sizeof(hdr.effectName))
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
163 return DMERR_FREAD;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
164 hdr.effectName[sizeof(hdr.effectName) - 1] = 0;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
165 if (!dmf_read_le32(res, &hdr.nparams))
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
166 return DMERR_FREAD;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
167
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
168 if (hdr.nparams > DT_MAX_EFFECT_PARAMS)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
169 {
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
170 dmError("Invalid number of parameters, %d > %d ('%s' @ %d:%d)\n",
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
171 hdr.nparams, DT_MAX_EFFECT_PARAMS, hdr.effectName, hdr.startTime, hdr.duration);
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
172 return DMERR_INVALID_DATA;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
173 }
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
174
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
175 event->startTime = hdr.startTime;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
176 event->duration = hdr.duration;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
177 event->nparams = hdr.nparams;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
178 event->effect = dmFindEffect(hdr.effectName, hdr.nparams);
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
179 if (event->effect == NULL)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
180 {
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
181 dmError("No matching registered effect found for '%s'.\n", hdr.effectName);
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
182 return DMERR_INVALID_DATA;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
183 }
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
184
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
185 event->params = dmCalloc(event->nparams, sizeof(DMTimelineEventParam));
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
186 if (event->params == NULL)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
187 {
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
188 dmError("Could not allocate memory for timeline event parameters.\n");
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
189 return DMERR_MALLOC;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
190 }
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
191
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
192 for (param = 0; param < event->nparams; param++)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
193 {
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
194 int err;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
195 if ((err = dmLoadTimelineEventParam(res, &(event->params[param]))) != DMERR_OK)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
196 return err;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
197 }
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
198
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
199 return DMERR_OK;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
200 }
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
201
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
202
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
203 int dmLoadTimelineCurve(DMResource *res, DMTimelineCurve *curve)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
204 {
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
205 int err;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
206
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
207 curve->enabled = dmfgetc(res);
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
208 if ((err = dmLoadTimelinePoints(res, &(curve->points))) != DMERR_OK)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
209 return err;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
210
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
211 return DMERR_OK;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
212 }
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
213
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
214
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
215 int dmLoadTimelineTrack(DMResource *res, DMTimelineTrack **ptrack)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
216 {
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
217 int event, err;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
218 DMFTimelineTrack hdr;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
219 DMTimelineTrack *track;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
220 if ((*ptrack = track = dmMalloc0(sizeof(DMTimelineTrack))) == NULL)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
221 return DMERR_MALLOC;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
222
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
223 if (dmf_read_str(res, (Uint8 *) &hdr.name, sizeof(hdr.name)) != sizeof(hdr.name))
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
224 return DMERR_FREAD;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
225
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
226 hdr.enabled = dmfgetc(res);
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
227 if (!dmf_read_le32(res, &hdr.nevents))
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
228 return DMERR_FREAD;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
229
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
230 if (hdr.nevents >= 4096)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
231 return DMERR_INVALID_DATA;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
232
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
233 if ((track->events = dmCalloc(hdr.nevents, sizeof(DMTimelineEvent *))) == NULL)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
234 return DMERR_MALLOC;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
235
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
236 hdr.name[sizeof(hdr.name) - 1] = 0;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
237 track->name = dm_strdup(hdr.name);
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
238 track->enabled = hdr.enabled;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
239 track->nevents = hdr.nevents;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
240
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
241 for (event = 0; event < track->nevents; event++)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
242 {
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
243 if ((err = dmLoadTimelineEvent(res, &(track->events[event]))) != DMERR_OK)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
244 return err;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
245 }
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
246
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
247 if ((err = dmLoadTimelineCurve(res, &(track->composite))) != DMERR_OK)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
248 return err;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
249
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
250 return DMERR_OK;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
251 }
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
252
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
253
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
254 int dmLoadTimeline(DMResource *res, DMTimeline **ptl)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
255 {
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
256 int track, err;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
257 DMFTimeline hdr;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
258 DMTimeline *tl;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
259 if ((*ptl = tl = dmMalloc0(sizeof(DMTimeline))) == NULL)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
260 return DMERR_MALLOC;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
261
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
262 // Read and check header
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
263 if (dmf_read_str(res, (Uint8 *) &hdr.magic, sizeof(hdr.magic)) != sizeof(hdr.magic))
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
264 return DMERR_FREAD;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
265
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
266 if (memcmp(hdr.magic, "SDMETLNE", sizeof(hdr.magic)) != 0)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
267 return DMERR_INVALID_DATA;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
268
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
269 if (dmf_read_str(res, (Uint8 *) &hdr.name, sizeof(hdr.name)) != sizeof(hdr.name))
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
270 return DMERR_FREAD;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
271
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
272 if (!dmf_read_le32(res, &hdr.ntracks))
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
273 return DMERR_FREAD;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
274
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
275 if (!dmf_read_le32(res, &hdr.duration))
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
276 return DMERR_FREAD;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
277
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
278 if (hdr.ntracks >= 64)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
279 return DMERR_INVALID_DATA;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
280
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
281 // Allocate track pointers
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
282 tl->tracks = (DMTimelineTrack **) dmCalloc(hdr.ntracks, sizeof(DMTimelineTrack *));
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
283 if (tl->tracks == NULL)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
284 return DMERR_MALLOC;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
285
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
286 // Copy rest
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
287 hdr.name[sizeof(hdr.name) - 1] = 0;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
288 tl->name = dm_strdup(hdr.name);
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
289 tl->duration = hdr.duration;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
290 tl->ntracks = hdr.ntracks;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
291
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
292 // Read tracks
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
293 for (track = 0; track < tl->ntracks; track++)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
294 {
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
295 if ((err = dmLoadTimelineTrack(res, &(tl->tracks[track]))) != DMERR_OK)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
296 return err;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
297 }
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
298
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
299 return DMERR_OK;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
300 }
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
301
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
302
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
303 void dmFreeTimelinePoints(DMTimelinePoints *points)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
304 {
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
305 dmFree(points->points);
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
306 points->points = NULL;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
307 points->npoints = points->nallocated = 0;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
308 }
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
309
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
310
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
311 void dmFreeTimelineTrack(DMTimelineTrack *track)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
312 {
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
313 if (track != NULL)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
314 {
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
315 dmFree(track->name);
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
316 track->name = NULL;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
317 dmFreeTimelinePoints(&(track->composite.points));
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
318 }
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
319 }
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
320
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
321
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
322 void dmFreeTimeline(DMTimeline *tl)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
323 {
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
324 if (tl != NULL)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
325 {
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
326 int i;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
327 for (i = 0; i < tl->ntracks; i++)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
328 dmFreeTimelineTrack(tl->tracks[i]);
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
329
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
330 dmFree(tl->tracks);
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
331 dmFree(tl->name);
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
332 dmFree(tl->pevents);
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
333 }
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
334 }
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
335
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
336
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
337 /* Prepare a loaded timeline for execution. Creates the "stacked" structure
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
338 * of timeline data for efficient rendering.
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
339 */
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
340 int dmPrepareTimeline(DMTimeline *tl)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
341 {
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
342 return DMERR_OK;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
343 }
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
344
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
345
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
346 /* Seeks to specified position in the timeline. The execution function
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
347 * only handles monotonously increasing time, going backwards will not work
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
348 * there correctly, thus to seek freely this function must be used.
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
349 */
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
350 int dmSeekTimeline(DMTimeline *tl, int time)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
351 {
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
352 return DMERR_OK;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
353 }
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
354
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
355
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
356 /* "Executes", or rather renders a frame on the specified timeline position.
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
357 */
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
358 int dmExecuteTimeline(DMTimeline *tl, SDL_Surface *screen, int time)
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
359 {
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
360 return DMERR_OK;
fc79b57d4646 Add in unfinished timeline code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
361 }