summaryrefslogtreecommitdiff
path: root/apps/codecs/dumb/src/helpers/sampbuf.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/helpers/sampbuf.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/helpers/sampbuf.c')
-rw-r--r--apps/codecs/dumb/src/helpers/sampbuf.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/apps/codecs/dumb/src/helpers/sampbuf.c b/apps/codecs/dumb/src/helpers/sampbuf.c
new file mode 100644
index 0000000000..75510c729a
--- /dev/null
+++ b/apps/codecs/dumb/src/helpers/sampbuf.c
@@ -0,0 +1,47 @@
1/* _______ ____ __ ___ ___
2 * \ _ \ \ / \ / \ \ / / ' ' '
3 * | | \ \ | | || | \/ | . .
4 * | | | | | | || ||\ /| |
5 * | | | | | | || || \/ | | ' ' '
6 * | | | | | | || || | | . .
7 * | |_/ / \ \__// || | |
8 * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque
9 * / \
10 * / . \
11 * sampbuf.c - Helper for allocating sample / / \ \
12 * buffers. | < / \_
13 * | \/ /\ /
14 * By entheh. \_ / > /
15 * | \ / /
16 * | ' /
17 * \__/
18 */
19
20#include <stdlib.h>
21#include "dumb.h"
22
23
24
25sample_t **create_sample_buffer(int n_channels, long length)
26{
27 int i;
28 sample_t **samples = malloc(n_channels * sizeof(*samples));
29 if (!samples) return NULL;
30 samples[0] = malloc(n_channels * length * sizeof(*samples[0]));
31 if (!samples[0]) {
32 free(samples);
33 return NULL;
34 }
35 for (i = 1; i < n_channels; i++) samples[i] = samples[i-1] + length;
36 return samples;
37}
38
39
40
41void destroy_sample_buffer(sample_t **samples)
42{
43 if (samples) {
44 free(samples[0]);
45 free(samples);
46 }
47}