summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/codec_thread.c15
-rw-r--r--apps/codecs.c23
-rw-r--r--apps/codecs.h6
3 files changed, 23 insertions, 21 deletions
diff --git a/apps/codec_thread.c b/apps/codec_thread.c
index 7cf45c3490..4801c4aa35 100644
--- a/apps/codec_thread.c
+++ b/apps/codec_thread.c
@@ -208,19 +208,6 @@ void codec_thread_do_callback(void (*fn)(void), unsigned int *id)
/** --- codec API callbacks --- **/
-static void * codec_get_buffer(size_t *size)
-{
- ssize_t s = CODEC_SIZE - codec_size;
- void *buf = &codecbuf[codec_size];
- ALIGN_BUFFER(buf, s, CACHEALIGN_SIZE);
-
- if (s <= 0)
- return NULL;
-
- *size = s;
- return buf;
-}
-
static void codec_pcmbuf_insert_callback(
const void *ch1, const void *ch2, int count)
{
@@ -420,7 +407,7 @@ void codec_init_codec_api(void)
{
ci.dsp = (struct dsp_config *)dsp_configure(NULL, DSP_MYDSP,
CODEC_IDX_AUDIO);
- ci.codec_get_buffer = codec_get_buffer;
+ ci.codec_get_buffer = codeclib_get_buffer;
ci.pcmbuf_insert = codec_pcmbuf_insert_callback;
ci.set_elapsed = audio_codec_update_elapsed;
ci.read_filebuf = codec_filebuf_callback;
diff --git a/apps/codecs.c b/apps/codecs.c
index 25ace4969b..0fe848ecd3 100644
--- a/apps/codecs.c
+++ b/apps/codecs.c
@@ -61,12 +61,14 @@
#endif
#if (CONFIG_PLATFORM & PLATFORM_HOSTED)
-#if CONFIG_CODEC == SWCODEC
-unsigned char codecbuf[CODEC_SIZE];
-#endif
+/* For PLATFORM_HOSTED this buffer must be define here. */
+static unsigned char codecbuf[CODEC_SIZE];
+#else
+/* For PLATFORM_NATIVE this buffer is defined in *.lds files. */
+extern unsigned char codecbuf[];
#endif
-size_t codec_size;
+static size_t codec_size;
extern void* plugin_get_audio_buffer(size_t *buffer_size);
@@ -171,6 +173,19 @@ void codec_get_full_path(char *path, const char *codec_root_fn)
CODECS_DIR, codec_root_fn);
}
+/* Returns pointer to and size of free codec RAM. Aligns to CACHEALIGN_SIZE. */
+void *codeclib_get_buffer(size_t *size)
+{
+ void *buf = &codecbuf[codec_size];
+ *size = CODEC_SIZE - codec_size;
+ ALIGN_BUFFER(buf, *size, CACHEALIGN_SIZE);
+
+ if (*size <= 0)
+ return NULL;
+
+ return buf;
+}
+
/** codec loading and call interface **/
static void *curr_handle = NULL;
static struct codec_header *c_hdr = NULL;
diff --git a/apps/codecs.h b/apps/codecs.h
index 5c50116038..07b8cd5d4f 100644
--- a/apps/codecs.h
+++ b/apps/codecs.h
@@ -235,9 +235,6 @@ struct codec_header {
struct codec_api **api;
};
-extern unsigned char codecbuf[];
-extern size_t codec_size;
-
#ifdef CODEC
#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
/* plugin_* is correct, codecs use the plugin linker script */
@@ -277,6 +274,9 @@ extern unsigned char plugin_end_addr[];
assumes buffer size is MAX_PATH */
void codec_get_full_path(char *path, const char *codec_root_fn);
+/* Returns pointer to and size of free codec RAM */
+void *codeclib_get_buffer(size_t *size);
+
/* defined by the codec loader (codec.c) */
int codec_load_buf(int hid, struct codec_api *api);
int codec_load_file(const char* codec, struct codec_api *api);