summaryrefslogtreecommitdiff
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
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
-rw-r--r--apps/codecs.c93
-rw-r--r--apps/codecs.h97
-rw-r--r--apps/codecs/Makefile2
-rw-r--r--apps/codecs/a52.c3
-rw-r--r--apps/codecs/aac.c6
-rw-r--r--apps/codecs/alac.c6
-rw-r--r--apps/codecs/flac.c6
-rw-r--r--apps/codecs/mpa.c3
-rw-r--r--apps/codecs/mpc.c3
-rw-r--r--apps/codecs/shorten.c5
-rw-r--r--apps/codecs/vorbis.c3
-rw-r--r--apps/codecs/wav.c4
-rw-r--r--apps/codecs/wavpack.c4
-rw-r--r--firmware/export/config-gmini120.h2
-rw-r--r--firmware/export/config-gminisp.h2
-rw-r--r--firmware/export/config-h100.h2
-rw-r--r--firmware/export/config-h120.h2
-rw-r--r--firmware/export/config-h300.h2
-rw-r--r--firmware/export/config-iaudiox5.h2
-rw-r--r--firmware/export/config-ipodcolor.h2
-rw-r--r--firmware/export/config-ipodnano.h2
-rw-r--r--firmware/export/config-ipodvideo.h2
-rw-r--r--uisimulator/common/io.c29
23 files changed, 117 insertions, 165 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;
-}
diff --git a/apps/codecs.h b/apps/codecs.h
index 5d5fbfe..320431f 100644
--- a/apps/codecs.h
+++ b/apps/codecs.h
@@ -80,32 +80,23 @@
#define PREFIX(_x_) _x_
#endif
+#define CODEC_MAGIC 0x52434F44 /* RCOD */
+
/* increase this every time the api struct changes */
-#define CODEC_API_VERSION 44
+#define CODEC_API_VERSION 1
/* 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 44
+#define CODEC_MIN_API_VERSION 1
/* codec return codes */
enum codec_status {
CODEC_OK = 0,
CODEC_USB_CONNECTED,
-
- CODEC_WRONG_API_VERSION = -1,
- CODEC_WRONG_MODEL = -2,
- CODEC_ERROR = -3,
+ CODEC_ERROR = -1,
};
-/* compatibility test macro */
-#define TEST_CODEC_API(_api_) \
-do { \
- int _rc_ = _api_->codec_test(CODEC_API_VERSION, 1, MEM); \
- if (_rc_<0) \
- return _rc_; \
-} while(0)
-
/* NOTE: To support backwards compatibility, only add new functions at
the end of the structure. Every time you add a new function,
remember to increase CODEC_API_VERSION. If you make changes to the
@@ -113,10 +104,6 @@ do { \
version
*/
struct codec_api {
- /* these two fields must always be first, to ensure
- TEST_CODEC_API will always work */
- int version;
- int (*codec_test)(int api_version, int model, int memsize);
off_t filesize; /* Total file length */
off_t curpos; /* Current buffer position */
@@ -158,6 +145,8 @@ struct codec_api {
void (*advance_buffer_loc)(void *ptr);
/* Seek file buffer to position <newpos> beginning of file. */
bool (*seek_buffer)(off_t newpos);
+ /* Codec should call this function when it has done the seeking. */
+ void (*seek_complete)(void);
/* Calculate mp3 seek position from given time data in ms. */
off_t (*mp3_get_filepos)(int newtime);
/* Request file change from file buffer. Returns true is next
@@ -165,6 +154,7 @@ struct codec_api {
codec should exit immediately with PLUGIN_OK status. */
bool (*request_next_track)(void);
+ void (*set_offset)(unsigned int value);
/* Configure different codec buffer parameters. */
void (*configure)(int setting, void *value);
@@ -228,6 +218,7 @@ struct codec_api {
char *(*strcat)(char *s1, const char *s2);
int (*memcmp)(const void *s1, const void *s2, size_t n);
char *(*strcasestr) (const char* phaystack, const char* pneedle);
+ void *(*memchr)(const void *s1, int c, size_t n);
/* sound */
void (*sound_set)(int setting, int value);
@@ -236,9 +227,6 @@ struct codec_api {
void (*mp3_play_pause)(bool play);
void (*mp3_play_stop)(void);
bool (*mp3_is_playing)(void);
-#if CONFIG_CODEC != SWCODEC
- void (*bitswap)(unsigned char *data, int length);
-#endif
#if CONFIG_CODEC == SWCODEC
void (*pcm_play_data)(void (*get_more)(unsigned char** start, long*size));
void (*pcm_play_stop)(void);
@@ -263,24 +251,6 @@ struct codec_api {
struct mp3entry* (*audio_current_track)(void);
void (*audio_flush_and_reload_tracks)(void);
int (*audio_get_file_pos)(void);
-#if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
- unsigned long (*mpeg_get_last_header)(void);
-#endif
-#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
- void (*sound_set_pitch)(int pitch);
-#endif
-
- /* MAS communication */
-#if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
- int (*mas_readmem)(int bank, int addr, unsigned long* dest, int len);
- int (*mas_writemem)(int bank, int addr, const unsigned long* src, int len);
- int (*mas_readreg)(int reg);
- int (*mas_writereg)(int reg, unsigned int val);
-#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
- int (*mas_codec_writereg)(int reg, unsigned int val);
- int (*mas_codec_readreg)(int reg);
-#endif
-#endif
/* tag database */
struct tagdb_header *tagdbheader;
@@ -301,6 +271,9 @@ struct codec_api {
#if defined(DEBUG) || defined(SIMULATOR)
void (*debugf)(const char *fmt, ...);
#endif
+#ifdef ROCKBOX_HAS_LOGF
+ void (*logf)(const char *fmt, ...);
+#endif
struct user_settings* global_settings;
bool (*mp3info)(struct mp3entry *entry, const char *filename, bool v1first);
int (*count_mp3_frames)(int fd, int startpos, int filesize,
@@ -313,35 +286,45 @@ struct codec_api {
long max_offset, unsigned long last_header);
int (*battery_level)(void);
bool (*battery_level_safe)(void);
-#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
- unsigned short (*peak_meter_scale_value)(unsigned short val,
- int meterwidth);
- void (*peak_meter_set_use_dbfs)(bool use);
- bool (*peak_meter_get_use_dbfs)(void);
-#endif
/* new stuff at the end, sort into place next time
the API gets incompatible */
-
-#ifdef ROCKBOX_HAS_LOGF
- void (*logf)(const char *fmt, ...);
-#endif
- void *(*memchr)(const void *s1, int c, size_t n);
- void (*set_offset)(unsigned int value);
- /* Codec should call this function when it has done the seeking. */
- void (*seek_complete)(void);
};
+/* codec header */
+struct codec_header {
+ unsigned long magic;
+ unsigned short target_id;
+ unsigned short api_version;
+ unsigned char *load_addr;
+ unsigned char *end_addr;
+ enum codec_status(*entry_point)(struct codec_api*);
+};
+#ifdef CODEC
+#ifndef SIMULATOR
+/* plugin_* is correct, codecs use the plugin linker script */
+extern unsigned char plugin_start_addr[];
+extern unsigned char plugin_end_addr[];
+#define CODEC_HEADER \
+ const struct codec_header __header \
+ __attribute__ ((section (".header")))= { \
+ CODEC_MAGIC, TARGET_ID, CODEC_API_VERSION, \
+ plugin_start_addr, plugin_end_addr, codec_start };
+#else /* SIMULATOR */
+#define CODEC_HEADER \
+ const struct codec_header __header = { \
+ CODEC_MAGIC, TARGET_ID, CODEC_API_VERSION, \
+ NULL, NULL, codec_start };
+#endif
+#endif
+
/* defined by the codec loader (codec.c) */
-#if CONFIG_CODEC == SWCODEC
int codec_load_ram(char* codecptr, int size, void* ptr2, int bufwrap,
struct codec_api *api);
int codec_load_file(const char* codec, struct codec_api *api);
-#endif
/* defined by the codec */
-enum codec_status codec_start(struct codec_api* rockbox)
- __attribute__ ((section (".entry")));
+enum codec_status codec_start(struct codec_api* rockbox);
#endif
diff --git a/apps/codecs/Makefile b/apps/codecs/Makefile
index 5aec2ed..d0cd97d 100644
--- a/apps/codecs/Makefile
+++ b/apps/codecs/Makefile
@@ -10,7 +10,7 @@
INCLUDES = -I$(FIRMDIR)/include -I$(FIRMDIR)/export -I$(FIRMDIR)/common \
-I$(FIRMDIR)/drivers -I$(APPSDIR) -Ilib -I$(BUILDDIR)
CFLAGS = $(GCCOPTS) $(INCLUDES) $(TARGET) $(EXTRA_DEFINES) \
- -DMEM=${MEMORYSIZE} -DCODEC
+ -DTARGET_ID=$(TARGET_ID) -DMEM=${MEMORYSIZE} -DCODEC
ifdef APPEXTRA
INCLUDES += $(patsubst %,-I$(APPSDIR)/%,$(subst :, ,$(APPEXTRA)))
diff --git a/apps/codecs/a52.c b/apps/codecs/a52.c
index dd504e8..f12fce1 100644
--- a/apps/codecs/a52.c
+++ b/apps/codecs/a52.c
@@ -22,6 +22,8 @@
#include <codecs/liba52/config-a52.h>
#include <codecs/liba52/a52.h>
+CODEC_HEADER
+
#define BUFFER_SIZE 4096
#define A52_SAMPLESPERFRAME (6*256)
@@ -129,7 +131,6 @@ enum codec_status codec_start(struct codec_api *api)
int sample_loc;
/* Generic codec initialisation */
- TEST_CODEC_API(api);
ci = api;
#ifdef USE_IRAM
diff --git a/apps/codecs/aac.c b/apps/codecs/aac.c
index a6ce017..baa3935 100644
--- a/apps/codecs/aac.c
+++ b/apps/codecs/aac.c
@@ -23,6 +23,8 @@
#include "libfaad/structs.h"
#include "libfaad/decoder.h"
+CODEC_HEADER
+
#ifndef SIMULATOR
extern char iramcopy[];
extern char iramstart[];
@@ -51,10 +53,8 @@ enum codec_status codec_start(struct codec_api* api)
int16_t* decodedbuffer;
/* Generic codec initialisation */
- TEST_CODEC_API(api);
-
rb = api;
- ci = (struct codec_api*)api;
+ ci = api;
#ifndef SIMULATOR
rb->memcpy(iramstart, iramcopy, iramend-iramstart);
diff --git a/apps/codecs/alac.c b/apps/codecs/alac.c
index 30c1ada..7ca70ce 100644
--- a/apps/codecs/alac.c
+++ b/apps/codecs/alac.c
@@ -21,6 +21,8 @@
#include "libm4a/m4a.h"
#include "libalac/decomp.h"
+CODEC_HEADER
+
#ifdef USE_IRAM
extern char iramcopy[];
extern char iramstart[];
@@ -50,10 +52,8 @@ enum codec_status codec_start(struct codec_api* api)
alac_file alac;
/* Generic codec initialisation */
- TEST_CODEC_API(api);
-
rb = api;
- ci = (struct codec_api*)api;
+ ci = api;
#ifdef USE_IRAM
rb->memcpy(iramstart, iramcopy, iramend-iramstart);
diff --git a/apps/codecs/flac.c b/apps/codecs/flac.c
index ae05b0f..a96963d 100644
--- a/apps/codecs/flac.c
+++ b/apps/codecs/flac.c
@@ -20,6 +20,8 @@
#include "codeclib.h"
#include <codecs/libffmpegFLAC/decoder.h>
+CODEC_HEADER
+
#ifdef USE_IRAM
extern char iramcopy[];
extern char iramstart[];
@@ -226,10 +228,8 @@ enum codec_status codec_start(struct codec_api* api)
int frame;
/* Generic codec initialisation */
- TEST_CODEC_API(api);
-
rb = api;
- ci = (struct codec_api*)api;
+ ci = api;
#ifdef USE_IRAM
ci->memcpy(iramstart, iramcopy, iramend-iramstart);
diff --git a/apps/codecs/mpa.c b/apps/codecs/mpa.c
index 3d824d9..3c57f3f 100644
--- a/apps/codecs/mpa.c
+++ b/apps/codecs/mpa.c
@@ -21,6 +21,8 @@
#include <codecs/libmad/mad.h>
#include <inttypes.h>
+CODEC_HEADER
+
struct mad_stream stream IBSS_ATTR;
struct mad_frame frame IBSS_ATTR;
struct mad_synth synth IBSS_ATTR;
@@ -81,7 +83,6 @@ enum codec_status codec_start(struct codec_api *api)
char *inputbuffer;
ci = api;
- TEST_CODEC_API(api);
#ifdef USE_IRAM
ci->memcpy(iramstart, iramcopy, iramend - iramstart);
diff --git a/apps/codecs/mpc.c b/apps/codecs/mpc.c
index 207a63c..1d1ed3a 100644
--- a/apps/codecs/mpc.c
+++ b/apps/codecs/mpc.c
@@ -20,6 +20,8 @@
#include "codeclib.h"
#include <codecs/libmusepack/musepack.h>
+CODEC_HEADER
+
mpc_decoder decoder;
/* Our implementations of the mpc_reader callback functions. */
@@ -82,7 +84,6 @@ enum codec_status codec_start(struct codec_api *api)
mpc_reader reader;
mpc_streaminfo info;
- TEST_CODEC_API(api);
#ifdef USE_IRAM
ci->memcpy(iramstart, iramcopy, iramend - iramstart);
ci->memset(iedata, 0, iend - iedata);
diff --git a/apps/codecs/shorten.c b/apps/codecs/shorten.c
index 9e679f5..ffbd42a 100644
--- a/apps/codecs/shorten.c
+++ b/apps/codecs/shorten.c
@@ -20,6 +20,8 @@
#include "codeclib.h"
#include <codecs/libffmpegFLAC/shndec.h>
+CODEC_HEADER
+
#ifdef USE_IRAM
extern char iramcopy[];
extern char iramstart[];
@@ -50,9 +52,8 @@ enum codec_status codec_start(struct codec_api* api)
long bytesleft;
/* Generic codec initialisation */
- TEST_CODEC_API(api);
rb = api;
- ci = (struct codec_api*)api;
+ ci = api;
#ifdef USE_IRAM
ci->memcpy(iramstart, iramcopy, iramend-iramstart);
diff --git a/apps/codecs/vorbis.c b/apps/codecs/vorbis.c
index 795e689..fdd7a95 100644
--- a/apps/codecs/vorbis.c
+++ b/apps/codecs/vorbis.c
@@ -21,6 +21,8 @@
#include "Tremor/ivorbisfile.h"
#include "Tremor/ogg.h"
+CODEC_HEADER
+
static struct codec_api *rb;
/* Some standard functions and variables needed by Tremor */
@@ -122,7 +124,6 @@ enum codec_status codec_start(struct codec_api *api)
ogg_uint32_t vf_serialnos;
ogg_int64_t vf_pcmlengths[2];
- TEST_CODEC_API(api);
rb = api;
#ifdef USE_IRAM
diff --git a/apps/codecs/wav.c b/apps/codecs/wav.c
index e86b559..1dda2c3 100644
--- a/apps/codecs/wav.c
+++ b/apps/codecs/wav.c
@@ -20,6 +20,8 @@
#include "codeclib.h"
#include "inttypes.h"
+CODEC_HEADER
+
struct codec_api* rb;
/* This codec support WAVE files with the following formats:
@@ -230,8 +232,6 @@ enum codec_status codec_start(struct codec_api* api)
int32_t * const int32_samples = (int32_t*)int16_samples;
/* Generic codec initialisation */
- TEST_CODEC_API(api);
-
rb = api;
ci = api;
diff --git a/apps/codecs/wavpack.c b/apps/codecs/wavpack.c
index ff890ba..2804d3e 100644
--- a/apps/codecs/wavpack.c
+++ b/apps/codecs/wavpack.c
@@ -20,6 +20,8 @@
#include "codeclib.h"
#include "libwavpack/wavpack.h"
+CODEC_HEADER
+
static struct codec_api *ci;
#define FORCE_DSP_USE /* fixes some WavPack bugs; adds about 12% to boost ratio
@@ -52,8 +54,6 @@ enum codec_status codec_start(struct codec_api* api)
int bps, nchans, sr_100;
/* Generic codec initialisation */
- TEST_CODEC_API(api);
-
ci = api;
#ifdef USE_IRAM
diff --git a/firmware/export/config-gmini120.h b/firmware/export/config-gmini120.h
index 29066ec..8ffe51c 100644
--- a/firmware/export/config-gmini120.h
+++ b/firmware/export/config-gmini120.h
@@ -28,7 +28,7 @@
#define CODEC_SIZE 0x40000
/* The number of bytes reserved for loadable plugins */
-#define PLUGIN_BUFFER_SIZE 0xC0000
+#define PLUGIN_BUFFER_SIZE 0x80000
#ifndef SIMULATOR
diff --git a/firmware/export/config-gminisp.h b/firmware/export/config-gminisp.h
index 982e8f3..4aa4723 100644
--- a/firmware/export/config-gminisp.h
+++ b/firmware/export/config-gminisp.h
@@ -19,7 +19,7 @@
#define CODEC_SIZE 0x40000
/* The number of bytes reserved for loadable plugins */
-#define PLUGIN_BUFFER_SIZE 0xC0000
+#define PLUGIN_BUFFER_SIZE 0x80000
#ifndef SIMULATOR
diff --git a/firmware/export/config-h100.h b/firmware/export/config-h100.h
index 6d19b44..34c0cc4 100644
--- a/firmware/export/config-h100.h
+++ b/firmware/export/config-h100.h
@@ -45,7 +45,7 @@
#define CODEC_SIZE 0x80000
/* The number of bytes reserved for loadable plugins */
-#define PLUGIN_BUFFER_SIZE 0xC0000
+#define PLUGIN_BUFFER_SIZE 0x80000
#define CONFIG_TUNER TEA5767
#define CONFIG_TUNER_XTAL 32768
diff --git a/firmware/export/config-h120.h b/firmware/export/config-h120.h
index 5c6f763..2790063 100644
--- a/firmware/export/config-h120.h
+++ b/firmware/export/config-h120.h
@@ -41,7 +41,7 @@
#define CODEC_SIZE 0x80000
/* The number of bytes reserved for loadable plugins */
-#define PLUGIN_BUFFER_SIZE 0xC0000
+#define PLUGIN_BUFFER_SIZE 0x80000
#define CONFIG_TUNER TEA5767
#define CONFIG_TUNER_XTAL 32768
diff --git a/firmware/export/config-h300.h b/firmware/export/config-h300.h
index 2698d12..806ae0a 100644
--- a/firmware/export/config-h300.h
+++ b/firmware/export/config-h300.h
@@ -46,7 +46,7 @@
#define CODEC_SIZE 0x80000
/* The number of bytes reserved for loadable plugins */
-#define PLUGIN_BUFFER_SIZE 0xC0000
+#define PLUGIN_BUFFER_SIZE 0x80000
#define CONFIG_TUNER TEA5767
#define CONFIG_TUNER_XTAL 32768
diff --git a/firmware/export/config-iaudiox5.h b/firmware/export/config-iaudiox5.h
index a06d22b..ac30734 100644
--- a/firmware/export/config-iaudiox5.h
+++ b/firmware/export/config-iaudiox5.h
@@ -38,7 +38,7 @@
#define CODEC_SIZE 0x40000
/* The number of bytes reserved for loadable plugins */
-#define PLUGIN_BUFFER_SIZE 0xC0000
+#define PLUGIN_BUFFER_SIZE 0x80000
#ifndef SIMULATOR
diff --git a/firmware/export/config-ipodcolor.h b/firmware/export/config-ipodcolor.h
index b88c9bc..b413b86 100644
--- a/firmware/export/config-ipodcolor.h
+++ b/firmware/export/config-ipodcolor.h
@@ -38,7 +38,7 @@
#define CODEC_SIZE 0x80000
/* The number of bytes reserved for loadable plugins */
-#define PLUGIN_BUFFER_SIZE 0xC0000
+#define PLUGIN_BUFFER_SIZE 0x80000
/* Define this if you have the WM8975 audio codec */
#define HAVE_WM8975
diff --git a/firmware/export/config-ipodnano.h b/firmware/export/config-ipodnano.h
index 207aa18..728c83e 100644
--- a/firmware/export/config-ipodnano.h
+++ b/firmware/export/config-ipodnano.h
@@ -38,7 +38,7 @@
#define CODEC_SIZE 0x80000
/* The number of bytes reserved for loadable plugins */
-#define PLUGIN_BUFFER_SIZE 0xC0000
+#define PLUGIN_BUFFER_SIZE 0x80000
/* Define this if you have the WM8975 audio codec */
#define HAVE_WM8975
diff --git a/firmware/export/config-ipodvideo.h b/firmware/export/config-ipodvideo.h
index d6d9bbc..0e6dc15 100644
--- a/firmware/export/config-ipodvideo.h
+++ b/firmware/export/config-ipodvideo.h
@@ -38,7 +38,7 @@
#define CODEC_SIZE 0x80000
/* The number of bytes reserved for loadable plugins */
-#define PLUGIN_BUFFER_SIZE 0xC0000
+#define PLUGIN_BUFFER_SIZE 0x80000
/* Define this if you have the WM8975 audio codec */
#define HAVE_WM8975
diff --git a/uisimulator/common/io.c b/uisimulator/common/io.c
index 1871b29..68eb893 100644
--- a/uisimulator/common/io.c
+++ b/uisimulator/common/io.c
@@ -306,20 +306,20 @@ int sim_fsync(int fd)
void *sim_codec_load_ram(char* codecptr, int size,
void* ptr2, int bufwrap, int *pd_fd)
{
- void *pd;
- char *path = "archos/_temp_codec.dll";
- int (*codec_start)(void * api);
+ void *pd, *hdr;
+ const char *path = "archos/_temp_codec.dll";
int fd;
int copy_n;
#ifdef WIN32
char buf[256];
#endif
+ *pd_fd = 0;
+
/* We have to create the dynamic link library file from ram
- * so we could simulate the codec loading.
- */
- *pd_fd = -1;
- fd = open(path, O_WRONLY | O_CREAT, S_IRWXU);
+ so we could simulate the codec loading. */
+
+ fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU);
if (fd < 0) {
DEBUGF("failed to open for write: %s\n", path);
return NULL;
@@ -341,7 +341,7 @@ void *sim_codec_load_ram(char* codecptr, int size,
}
}
close(fd);
-
+
/* Now load the library. */
pd = dlopen(path, RTLD_NOW);
if (!pd) {
@@ -357,17 +357,12 @@ void *sim_codec_load_ram(char* codecptr, int size,
return NULL;
}
- codec_start = dlsym(pd, "codec_start");
- if (!codec_start) {
- codec_start = dlsym(pd, "_codec_start");
- if (!codec_start) {
- dlclose(pd);
- return NULL;
- }
- }
+ hdr = dlsym(pd, "__header");
+ if (!hdr)
+ hdr = dlsym(pd, "___header");
*pd_fd = (int)pd;
- return codec_start;
+ return hdr; /* maybe NULL if symbol not present */
}
void sim_codec_close(int pd)