summaryrefslogtreecommitdiff
path: root/apps/codecs.c
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2006-01-18 00:05:14 +0000
committerJens Arnold <amiconn@rockbox.org>2006-01-18 00:05:14 +0000
commitb8749fdf219ffcfc17b7781217f388953268af49 (patch)
tree7369b5cb4f94f0c6589eb8bbf1bf63537c898b62 /apps/codecs.c
parent507ff53c9c429de6c3bf5bfd6eb1a129cfc12cad (diff)
downloadrockbox-b8749fdf219ffcfc17b7781217f388953268af49.zip
rockbox-b8749fdf219ffcfc17b7781217f388953268af49.tar.gz
rockbox-b8749fdf219ffcfc17b7781217f388953268af49.tar.bz2
rockbox-b8749fdf219ffcfc17b7781217f388953268af49.tar.xz
New codec loader, using the same mechanism as the new plugin loader. API version numbering restarted for the new system. Uses the target ID from configure, so don't change that too often. * Fixed sim_plugin_load_ram() to truncate the tempfile. * Reduced plugin buffer size to 512KB for iriver and iPod.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8362 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs.c')
-rw-r--r--apps/codecs.c93
1 files changed, 31 insertions, 62 deletions
diff --git a/apps/codecs.c b/apps/codecs.c
index 831b9b4..d12b436 100644
--- a/apps/codecs.c
+++ b/apps/codecs.c
@@ -68,13 +68,9 @@ extern unsigned char codecbuf[];
extern void* plugin_get_audio_buffer(int *buffer_size);
-static int codec_test(int api_version, int model, int memsize);
-
struct codec_api ci_voice;
struct codec_api ci = {
- CODEC_API_VERSION,
- codec_test,
0, /* filesize */
0, /* curpos */
@@ -95,6 +91,8 @@ struct codec_api ci = {
NULL,
NULL,
NULL,
+ NULL,
+ NULL,
gui_syncsplash,
@@ -155,6 +153,7 @@ struct codec_api ci = {
strcat,
memcmp,
strcasestr,
+ memchr,
/* sound */
sound_set,
@@ -163,9 +162,6 @@ struct codec_api ci = {
mp3_play_pause,
mp3_play_stop,
mp3_is_playing,
-#if CONFIG_CODEC != SWCODEC
- bitswap,
-#endif
#if CONFIG_CODEC == SWCODEC
pcm_play_data,
pcm_play_stop,
@@ -190,24 +186,6 @@ struct codec_api ci = {
audio_current_track,
audio_flush_and_reload_tracks,
audio_get_file_pos,
-#if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
- mpeg_get_last_header,
-#endif
-#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
- sound_set_pitch,
-#endif
-
-#if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
- /* MAS communication */
- mas_readmem,
- mas_writemem,
- mas_readreg,
- mas_writereg,
-#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
- mas_codec_writereg,
- mas_codec_readreg,
-#endif
-#endif /* !simulator and HWCODEC != SWCODEC */
/* tag database */
&tagdbheader,
@@ -227,6 +205,9 @@ struct codec_api ci = {
#if defined(DEBUG) || defined(SIMULATOR)
debugf,
#endif
+#ifdef ROCKBOX_HAS_LOGF
+ logf,
+#endif
&global_settings,
mp3info,
count_mp3_frames,
@@ -234,28 +215,16 @@ struct codec_api ci = {
find_next_frame,
battery_level,
battery_level_safe,
-#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
- peak_meter_scale_value,
- peak_meter_set_use_dbfs,
- peak_meter_get_use_dbfs,
-#endif
/* new stuff at the end, sort into place next time
the API gets incompatible */
-#ifdef ROCKBOX_HAS_LOGF
- logf,
-#endif
-
- memchr,
- NULL,
- NULL,
};
int codec_load_ram(char* codecptr, int size, void* ptr2, int bufwrap,
struct codec_api *api)
{
- enum codec_status (*codec_start)(const struct codec_api* api);
+ struct codec_header *hdr;
int status;
#ifndef SIMULATOR
int copy_n;
@@ -272,22 +241,40 @@ int codec_load_ram(char* codecptr, int size, void* ptr2, int bufwrap,
memcpy(&codecbuf[copy_n], ptr2, size);
}
}
- codec_start = (void*)&codecbuf;
+ hdr = (struct codec_header *)codecbuf;
+ if (hdr->magic != CODEC_MAGIC
+ || hdr->target_id != TARGET_ID
+ || hdr->load_addr != codecbuf
+ || hdr->end_addr > codecbuf + CODEC_SIZE) {
+ return CODEC_ERROR;
+ }
#else /* SIMULATOR */
int pd;
- codec_start = sim_codec_load_ram(codecptr, size, ptr2, bufwrap, &pd);
+ hdr = sim_codec_load_ram(codecptr, size, ptr2, bufwrap, &pd);
if (pd < 0)
return CODEC_ERROR;
+
+ if (hdr == NULL
+ || hdr->magic != CODEC_MAGIC
+ || hdr->target_id != TARGET_ID
+ || hdr->entry_point == NULL) {
+ sim_codec_close(pd);
+ return CODEC_ERROR;
+ }
#endif /* SIMULATOR */
+ if (hdr->api_version > CODEC_API_VERSION
+ || hdr->api_version < CODEC_MIN_API_VERSION) {
+ sim_codec_close(pd);
+ return CODEC_ERROR;
+ }
invalidate_icache();
- status = codec_start(api);
-#ifdef SIMULATOR
+ status = hdr->entry_point(api);
+
sim_codec_close(pd);
-#endif
-
+
return status;
}
@@ -317,21 +304,3 @@ int codec_load_file(const char *plugin, struct codec_api *api)
return codec_load_ram(codecbuf, (size_t)rc, NULL, 0, api);
}
-
-static int codec_test(int api_version, int model, int memsize)
-{
- if (api_version < CODEC_MIN_API_VERSION ||
- api_version > CODEC_API_VERSION)
- return CODEC_WRONG_API_VERSION;
-
- (void)model;
-#if 0
- if (model != MODEL)
- return CODEC_WRONG_MODEL;
-#endif
-
- if (memsize != MEM)
- return CODEC_WRONG_MODEL;
-
- return CODEC_OK;
-}