diff options
Diffstat (limited to 'apps/plugins/lua/tlsf_helper.c')
-rw-r--r-- | apps/plugins/lua/tlsf_helper.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/apps/plugins/lua/tlsf_helper.c b/apps/plugins/lua/tlsf_helper.c new file mode 100644 index 0000000000..edf32eecf9 --- /dev/null +++ b/apps/plugins/lua/tlsf_helper.c | |||
@@ -0,0 +1,48 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2013 Marcin Bukat | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or | ||
12 | * modify it under the terms of the GNU General Public License | ||
13 | * as published by the Free Software Foundation; either version 2 | ||
14 | * of the License, or (at your option) any later version. | ||
15 | * | ||
16 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
17 | * KIND, either express or implied. | ||
18 | * | ||
19 | ****************************************************************************/ | ||
20 | |||
21 | #include "plugin.h" | ||
22 | #include <tlsf.h> | ||
23 | |||
24 | void *get_new_area(size_t *size) | ||
25 | { | ||
26 | static char *pluginbuf_ptr = NULL; | ||
27 | static char *audiobuf_ptr = NULL; | ||
28 | |||
29 | if (pluginbuf_ptr == NULL) | ||
30 | { | ||
31 | pluginbuf_ptr = rb->plugin_get_buffer(size); | ||
32 | |||
33 | /* kill tlsf signature if any */ | ||
34 | memset(pluginbuf_ptr, 0, 4); | ||
35 | |||
36 | return pluginbuf_ptr; | ||
37 | } | ||
38 | |||
39 | if (audiobuf_ptr == NULL) | ||
40 | { | ||
41 | /* grab audiobuffer */ | ||
42 | audiobuf_ptr = rb->plugin_get_audio_buffer(size); | ||
43 | |||
44 | return audiobuf_ptr; | ||
45 | } | ||
46 | |||
47 | return ((void *) ~0); | ||
48 | } | ||