summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/codecs.c13
-rw-r--r--apps/codecs.h9
-rw-r--r--apps/codecs/Tremor/oggmalloc.c2
-rw-r--r--apps/codecs/lib/codeclib.c2
-rw-r--r--apps/codecs/lib/codeclib.h2
-rw-r--r--apps/playback.c17
6 files changed, 27 insertions, 18 deletions
diff --git a/apps/codecs.c b/apps/codecs.c
index 417b546391..8e9e55a5d4 100644
--- a/apps/codecs.c
+++ b/apps/codecs.c
@@ -66,6 +66,8 @@ void sim_codec_close(void *pd);
66extern unsigned char codecbuf[]; 66extern unsigned char codecbuf[];
67#endif 67#endif
68 68
69size_t codec_size;
70
69extern void* plugin_get_audio_buffer(size_t *buffer_size); 71extern void* plugin_get_audio_buffer(size_t *buffer_size);
70 72
71struct codec_api ci = { 73struct codec_api ci = {
@@ -78,7 +80,7 @@ struct codec_api ci = {
78 0, /* new_track */ 80 0, /* new_track */
79 0, /* seek_time */ 81 0, /* seek_time */
80 NULL, /* struct dsp_config *dsp */ 82 NULL, /* struct dsp_config *dsp */
81 NULL, /* get_codec_memory */ 83 NULL, /* codec_get_buffer */
82 NULL, /* pcmbuf_insert */ 84 NULL, /* pcmbuf_insert */
83 NULL, /* set_elapsed */ 85 NULL, /* set_elapsed */
84 NULL, /* read_filebuf */ 86 NULL, /* read_filebuf */
@@ -193,6 +195,9 @@ static int codec_load_ram(int size, struct codec_api *api)
193 logf("codec header error"); 195 logf("codec header error");
194 return CODEC_ERROR; 196 return CODEC_ERROR;
195 } 197 }
198
199 codec_size = hdr->end_addr - codecbuf;
200
196#else /* SIMULATOR */ 201#else /* SIMULATOR */
197 void *pd; 202 void *pd;
198 203
@@ -211,6 +216,9 @@ static int codec_load_ram(int size, struct codec_api *api)
211 sim_codec_close(pd); 216 sim_codec_close(pd);
212 return CODEC_ERROR; 217 return CODEC_ERROR;
213 } 218 }
219
220 codec_size = codecbuf - codecbuf;
221
214#endif /* SIMULATOR */ 222#endif /* SIMULATOR */
215 if (hdr->api_version > CODEC_API_VERSION 223 if (hdr->api_version > CODEC_API_VERSION
216 || hdr->api_version < CODEC_MIN_API_VERSION) { 224 || hdr->api_version < CODEC_MIN_API_VERSION) {
@@ -226,7 +234,8 @@ static int codec_load_ram(int size, struct codec_api *api)
226 return status; 234 return status;
227} 235}
228 236
229int codec_load_buf(unsigned int hid, struct codec_api *api) { 237int codec_load_buf(unsigned int hid, struct codec_api *api)
238{
230 int rc; 239 int rc;
231 rc = bufread(hid, CODEC_SIZE, codecbuf); 240 rc = bufread(hid, CODEC_SIZE, codecbuf);
232 if (rc < 0) { 241 if (rc < 0) {
diff --git a/apps/codecs.h b/apps/codecs.h
index becb73c8b7..6d8c1016a8 100644
--- a/apps/codecs.h
+++ b/apps/codecs.h
@@ -82,12 +82,12 @@
82#define CODEC_ENC_MAGIC 0x52454E43 /* RENC */ 82#define CODEC_ENC_MAGIC 0x52454E43 /* RENC */
83 83
84/* increase this every time the api struct changes */ 84/* increase this every time the api struct changes */
85#define CODEC_API_VERSION 25 85#define CODEC_API_VERSION 26
86 86
87/* update this to latest version if a change to the api struct breaks 87/* update this to latest version if a change to the api struct breaks
88 backwards compatibility (and please take the opportunity to sort in any 88 backwards compatibility (and please take the opportunity to sort in any
89 new function which are "waiting" at the end of the function table) */ 89 new function which are "waiting" at the end of the function table) */
90#define CODEC_MIN_API_VERSION 25 90#define CODEC_MIN_API_VERSION 26
91 91
92/* codec return codes */ 92/* codec return codes */
93enum codec_status { 93enum codec_status {
@@ -125,7 +125,7 @@ struct codec_api {
125 struct dsp_config *dsp; 125 struct dsp_config *dsp;
126 126
127 /* Returns buffer to malloc array. Only codeclib should need this. */ 127 /* Returns buffer to malloc array. Only codeclib should need this. */
128 void* (*get_codec_memory)(size_t *size); 128 void* (*codec_get_buffer)(size_t *size);
129 /* Insert PCM data into audio buffer for playback. Playback will start 129 /* Insert PCM data into audio buffer for playback. Playback will start
130 automatically. */ 130 automatically. */
131 bool (*pcmbuf_insert)(const void *ch1, const void *ch2, int count); 131 bool (*pcmbuf_insert)(const void *ch1, const void *ch2, int count);
@@ -256,6 +256,9 @@ struct codec_header {
256 enum codec_status(*entry_point)(struct codec_api*); 256 enum codec_status(*entry_point)(struct codec_api*);
257}; 257};
258 258
259extern unsigned char codecbuf[];
260extern size_t codec_size;
261
259#ifdef CODEC 262#ifdef CODEC
260#ifndef SIMULATOR 263#ifndef SIMULATOR
261/* plugin_* is correct, codecs use the plugin linker script */ 264/* plugin_* is correct, codecs use the plugin linker script */
diff --git a/apps/codecs/Tremor/oggmalloc.c b/apps/codecs/Tremor/oggmalloc.c
index d7e903b156..b11eaa54f5 100644
--- a/apps/codecs/Tremor/oggmalloc.c
+++ b/apps/codecs/Tremor/oggmalloc.c
@@ -5,7 +5,7 @@ static size_t bufsize, tmp_ptr, mem_ptr;
5 5
6void ogg_malloc_init(void) 6void ogg_malloc_init(void)
7{ 7{
8 mallocbuf = ci->get_codec_memory(&bufsize); 8 mallocbuf = ci->codec_get_buffer(&bufsize);
9 tmp_ptr = bufsize & ~3; 9 tmp_ptr = bufsize & ~3;
10 mem_ptr = 0; 10 mem_ptr = 0;
11} 11}
diff --git a/apps/codecs/lib/codeclib.c b/apps/codecs/lib/codeclib.c
index e537995db9..6e11eb1aa1 100644
--- a/apps/codecs/lib/codeclib.c
+++ b/apps/codecs/lib/codeclib.c
@@ -36,7 +36,7 @@ unsigned char* filebuf; // The rest of the MP3 buffer
36int codec_init(void) 36int codec_init(void)
37{ 37{
38 mem_ptr = 0; 38 mem_ptr = 0;
39 mallocbuf = (unsigned char *)ci->get_codec_memory((size_t *)&bufsize); 39 mallocbuf = (unsigned char *)ci->codec_get_buffer((size_t *)&bufsize);
40 40
41 return 0; 41 return 0;
42} 42}
diff --git a/apps/codecs/lib/codeclib.h b/apps/codecs/lib/codeclib.h
index 87cc926c6b..744accb8aa 100644
--- a/apps/codecs/lib/codeclib.h
+++ b/apps/codecs/lib/codeclib.h
@@ -24,8 +24,6 @@
24#include "system.h" 24#include "system.h"
25#include <sys/types.h> 25#include <sys/types.h>
26 26
27#define MALLOC_BUFSIZE (512*1024)
28
29extern struct codec_api *ci; 27extern struct codec_api *ci;
30extern long mem_ptr; 28extern long mem_ptr;
31extern long bufsize; 29extern long bufsize;
diff --git a/apps/playback.c b/apps/playback.c
index f41cca64a2..bfad1a280c 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -166,10 +166,8 @@ enum filling_state {
166 166
167/* As defined in plugins/lib/xxx2wav.h */ 167/* As defined in plugins/lib/xxx2wav.h */
168#if MEM > 1 168#if MEM > 1
169#define MALLOC_BUFSIZE (512*1024)
170#define GUARD_BUFSIZE (32*1024) 169#define GUARD_BUFSIZE (32*1024)
171#else 170#else
172#define MALLOC_BUFSIZE (100*1024)
173#define GUARD_BUFSIZE (8*1024) 171#define GUARD_BUFSIZE (8*1024)
174#endif 172#endif
175 173
@@ -924,10 +922,12 @@ static bool codec_pcmbuf_insert_callback(
924 return true; 922 return true;
925} /* codec_pcmbuf_insert_callback */ 923} /* codec_pcmbuf_insert_callback */
926 924
927static void* codec_get_memory_callback(size_t *size) 925static void* codec_get_buffer(size_t *size)
928{ 926{
929 *size = MALLOC_BUFSIZE; 927 if (codec_size >= CODEC_SIZE)
930 return malloc_buf; 928 return NULL;
929 *size = CODEC_SIZE - codec_size;
930 return &codecbuf[codec_size];
931} 931}
932 932
933/* Between the codec and PCM track change, we need to keep updating the 933/* Between the codec and PCM track change, we need to keep updating the
@@ -2297,7 +2297,7 @@ static void audio_finalise_track_change(void)
2297 2297
2298/* 2298/*
2299 * Layout audio buffer as follows - iram buffer depends on target: 2299 * Layout audio buffer as follows - iram buffer depends on target:
2300 * [|SWAP:iram][|TALK]|MALLOC|FILE|GUARD|PCM|[SWAP:dram[|iram]|] 2300 * [|SWAP:iram][|TALK]|FILE|GUARD|PCM|[SWAP:dram[|iram]|]
2301 */ 2301 */
2302static void audio_reset_buffer(void) 2302static void audio_reset_buffer(void)
2303{ 2303{
@@ -2313,7 +2313,7 @@ static void audio_reset_buffer(void)
2313 /* Align the malloc buf to line size. Especially important to cf 2313 /* Align the malloc buf to line size. Especially important to cf
2314 targets that do line reads/writes. */ 2314 targets that do line reads/writes. */
2315 malloc_buf = (unsigned char *)(((uintptr_t)malloc_buf + 15) & ~15); 2315 malloc_buf = (unsigned char *)(((uintptr_t)malloc_buf + 15) & ~15);
2316 filebuf = malloc_buf + MALLOC_BUFSIZE; /* filebuf line align implied */ 2316 filebuf = malloc_buf; /* filebuf line align implied */
2317 filebuflen = audiobufend - filebuf; 2317 filebuflen = audiobufend - filebuf;
2318 2318
2319 filebuflen &= ~15; 2319 filebuflen &= ~15;
@@ -2338,7 +2338,6 @@ static void audio_reset_buffer(void)
2338 size_t pcmbufsize; 2338 size_t pcmbufsize;
2339 const unsigned char *pcmbuf = pcmbuf_get_meminfo(&pcmbufsize); 2339 const unsigned char *pcmbuf = pcmbuf_get_meminfo(&pcmbufsize);
2340 logf("mabuf: %08X", (unsigned)malloc_buf); 2340 logf("mabuf: %08X", (unsigned)malloc_buf);
2341 logf("mabufe: %08X", (unsigned)(malloc_buf + MALLOC_BUFSIZE));
2342 logf("fbuf: %08X", (unsigned)filebuf); 2341 logf("fbuf: %08X", (unsigned)filebuf);
2343 logf("fbufe: %08X", (unsigned)(filebuf + filebuflen)); 2342 logf("fbufe: %08X", (unsigned)(filebuf + filebuflen));
2344 logf("gbuf: %08X", (unsigned)(filebuf + filebuflen)); 2343 logf("gbuf: %08X", (unsigned)(filebuf + filebuflen));
@@ -2513,7 +2512,7 @@ void audio_init(void)
2513 /* Initialize codec api. */ 2512 /* Initialize codec api. */
2514 ci.read_filebuf = codec_filebuf_callback; 2513 ci.read_filebuf = codec_filebuf_callback;
2515 ci.pcmbuf_insert = codec_pcmbuf_insert_callback; 2514 ci.pcmbuf_insert = codec_pcmbuf_insert_callback;
2516 ci.get_codec_memory = codec_get_memory_callback; 2515 ci.codec_get_buffer = codec_get_buffer;
2517 ci.request_buffer = codec_request_buffer_callback; 2516 ci.request_buffer = codec_request_buffer_callback;
2518 ci.advance_buffer = codec_advance_buffer_callback; 2517 ci.advance_buffer = codec_advance_buffer_callback;
2519 ci.advance_buffer_loc = codec_advance_buffer_loc_callback; 2518 ci.advance_buffer_loc = codec_advance_buffer_loc_callback;