From 44554e60756288e99bf664ea87f86dc482006eff Mon Sep 17 00:00:00 2001 From: Andrew Mahone Date: Fri, 23 Jan 2009 09:51:26 +0000 Subject: [PATCH] initialize the codecs API in the codec loader, using the same method as used in the plugin loader git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19824 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs.c | 3 ++- apps/codecs.h | 17 +++++++++-------- apps/codecs/codec_crt0.c | 11 +++++------ 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/apps/codecs.c b/apps/codecs.c index 2c547ffd5d..cddebb623d 100644 --- a/apps/codecs.c +++ b/apps/codecs.c @@ -229,8 +229,9 @@ static int codec_load_ram(int size, struct codec_api *api) return CODEC_ERROR; } + *(hdr->api) = api; invalidate_icache(); - status = hdr->entry_point(api); + status = hdr->entry_point(); sim_codec_close(pd); diff --git a/apps/codecs.h b/apps/codecs.h index 64db750d6a..e603c8b35b 100644 --- a/apps/codecs.h +++ b/apps/codecs.h @@ -75,12 +75,12 @@ #define CODEC_ENC_MAGIC 0x52454E43 /* RENC */ /* increase this every time the api struct changes */ -#define CODEC_API_VERSION 29 +#define CODEC_API_VERSION 30 /* update this to latest version if a change to the api struct breaks backwards compatibility (and please take the opportunity to sort in any new function which are "waiting" at the end of the function table) */ -#define CODEC_MIN_API_VERSION 29 +#define CODEC_MIN_API_VERSION 30 /* codec return codes */ enum codec_status { @@ -243,7 +243,8 @@ struct codec_header { unsigned short api_version; unsigned char *load_addr; unsigned char *end_addr; - enum codec_status(*entry_point)(struct codec_api*); + enum codec_status(*entry_point)(void); + struct codec_api **api; }; extern unsigned char codecbuf[]; @@ -259,13 +260,13 @@ extern unsigned char plugin_end_addr[]; const struct codec_header __header \ __attribute__ ((section (".header")))= { \ CODEC_MAGIC, TARGET_ID, CODEC_API_VERSION, \ - plugin_start_addr, plugin_end_addr, codec_start }; + plugin_start_addr, plugin_end_addr, codec_start, &ci }; /* encoders */ #define CODEC_ENC_HEADER \ const struct codec_header __header \ __attribute__ ((section (".header")))= { \ CODEC_ENC_MAGIC, TARGET_ID, CODEC_API_VERSION, \ - plugin_start_addr, plugin_end_addr, codec_start }; + plugin_start_addr, plugin_end_addr, codec_start, &ci }; #else /* def SIMULATOR */ /* decoders */ @@ -273,12 +274,12 @@ extern unsigned char plugin_end_addr[]; const struct codec_header __header \ __attribute__((visibility("default"))) = { \ CODEC_MAGIC, TARGET_ID, CODEC_API_VERSION, \ - NULL, NULL, codec_start }; + NULL, NULL, codec_start, &ci }; /* encoders */ #define CODEC_ENC_HEADER \ const struct codec_header __header = { \ CODEC_ENC_MAGIC, TARGET_ID, CODEC_API_VERSION, \ - NULL, NULL, codec_start }; + NULL, NULL, codec_start, &ci }; #endif /* SIMULATOR */ #endif /* CODEC */ @@ -291,7 +292,7 @@ int codec_load_buf(unsigned int hid, struct codec_api *api); int codec_load_file(const char* codec, struct codec_api *api); /* defined by the codec */ -enum codec_status codec_start(struct codec_api* rockbox); +enum codec_status codec_start(void); enum codec_status codec_main(void); #ifndef CACHE_FUNCTION_WRAPPERS diff --git a/apps/codecs/codec_crt0.c b/apps/codecs/codec_crt0.c index 84e4762c50..167a91ec4c 100644 --- a/apps/codecs/codec_crt0.c +++ b/apps/codecs/codec_crt0.c @@ -22,7 +22,7 @@ #include "config.h" #include "codeclib.h" -struct codec_api *ci; +struct codec_api *ci __attribute__ ((section (".data"))); extern unsigned char iramcopy[]; extern unsigned char iramstart[]; @@ -36,16 +36,15 @@ extern enum codec_status codec_main(void); CACHE_FUNCTION_WRAPPERS(ci); -enum codec_status codec_start(struct codec_api *api) +enum codec_status codec_start(void) { #ifndef SIMULATOR #ifdef USE_IRAM - api->memcpy(iramstart, iramcopy, iramend - iramstart); - api->memset(iedata, 0, iend - iedata); + ci->memcpy(iramstart, iramcopy, iramend - iramstart); + ci->memset(iedata, 0, iend - iedata); #endif - api->memset(plugin_bss_start, 0, plugin_end_addr - plugin_bss_start); + ci->memset(plugin_bss_start, 0, plugin_end_addr - plugin_bss_start); #endif - ci = api; #if NUM_CORES > 1 /* writeback cleared iedata and bss areas */ flush_icache();