summaryrefslogtreecommitdiff
path: root/apps/codecs/dumb/src/core/makeduh.c
diff options
context:
space:
mode:
authorMichiel Van Der Kolk <not.valid@email.address>2005-03-17 20:50:03 +0000
committerMichiel Van Der Kolk <not.valid@email.address>2005-03-17 20:50:03 +0000
commit27be5bc72855a0fbbdae230bc144624c9eb85f5e (patch)
treeb553f1321df924c4b744ffcab48dce5f4f081f7d /apps/codecs/dumb/src/core/makeduh.c
parent7e7662bb716917ca431204f0113d400c1014f2e8 (diff)
downloadrockbox-27be5bc72855a0fbbdae230bc144624c9eb85f5e.tar.gz
rockbox-27be5bc72855a0fbbdae230bc144624c9eb85f5e.zip
Initial check in dumb 0.9.2 - has a few usages of floating point that should
be rewritten to fixed point. seems to compile cleanly for iriver. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6197 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/dumb/src/core/makeduh.c')
-rw-r--r--apps/codecs/dumb/src/core/makeduh.c92
1 files changed, 92 insertions, 0 deletions
diff --git a/apps/codecs/dumb/src/core/makeduh.c b/apps/codecs/dumb/src/core/makeduh.c
new file mode 100644
index 0000000000..1e422fb502
--- /dev/null
+++ b/apps/codecs/dumb/src/core/makeduh.c
@@ -0,0 +1,92 @@
1/* _______ ____ __ ___ ___
2 * \ _ \ \ / \ / \ \ / / ' ' '
3 * | | \ \ | | || | \/ | . .
4 * | | | | | | || ||\ /| |
5 * | | | | | | || || \/ | | ' ' '
6 * | | | | | | || || | | . .
7 * | |_/ / \ \__// || | |
8 * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque
9 * / \
10 * / . \
11 * makeduh.c - Function to construct a DUH from / / \ \
12 * its components. | < / \_
13 * | \/ /\ /
14 * By entheh. \_ / > /
15 * | \ / /
16 * | ' /
17 * \__/
18 */
19
20#include <stdlib.h>
21
22#include "dumb.h"
23#include "internal/dumb.h"
24
25
26
27static DUH_SIGNAL *make_signal(DUH_SIGTYPE_DESC *desc, sigdata_t *sigdata)
28{
29 DUH_SIGNAL *signal;
30
31 ASSERT((desc->start_sigrenderer && desc->end_sigrenderer) || (!desc->start_sigrenderer && !desc->end_sigrenderer));
32 ASSERT(desc->sigrenderer_get_samples && desc->sigrenderer_get_current_sample);
33
34 signal = malloc(sizeof(*signal));
35
36 if (!signal) {
37 if (desc->unload_sigdata)
38 if (sigdata)
39 (*desc->unload_sigdata)(sigdata);
40 return NULL;
41 }
42
43 signal->desc = desc;
44 signal->sigdata = sigdata;
45
46 return signal;
47}
48
49
50
51DUH *make_duh(long length, int n_signals, DUH_SIGTYPE_DESC *desc[], sigdata_t *sigdata[])
52{
53 DUH *duh = malloc(sizeof(*duh));
54 int i;
55 int fail;
56
57 if (duh) {
58 duh->n_signals = n_signals;
59
60 duh->signal = malloc(n_signals * sizeof(*duh->signal));
61
62 if (!duh->signal) {
63 free(duh);
64 duh = NULL;
65 }
66 }
67
68 if (!duh) {
69 for (i = 0; i < n_signals; i++)
70 if (desc[i]->unload_sigdata)
71 if (sigdata[i])
72 (*desc[i]->unload_sigdata)(sigdata[i]);
73 return NULL;
74 }
75
76 fail = 0;
77
78 for (i = 0; i < n_signals; i++) {
79 duh->signal[i] = make_signal(desc[i], sigdata[i]);
80 if (!duh->signal[i])
81 fail = 1;
82 }
83
84 if (fail) {
85 unload_duh(duh);
86 return NULL;
87 }
88
89 duh->length = length;
90
91 return duh;
92}