From 20d031f9c70109dae2ea320a4c7264e1e489d8eb Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Fri, 9 May 2003 16:01:21 +0000 Subject: Configurable dir browser file buffer size. No more 400-file limit. No more whining. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3661 a1c6a512-1295-4272-9138-f99709370657 --- firmware/app.lds | 2 +- firmware/buffer.c | 43 +++++++++++++++++++++++++++++++++++++++++++ firmware/export/buffer.h | 30 ++++++++++++++++++++++++++++++ firmware/mp3data.c | 8 +------- firmware/mpeg.c | 5 +---- firmware/rolo.c | 6 ++++-- 6 files changed, 80 insertions(+), 14 deletions(-) create mode 100644 firmware/buffer.c create mode 100644 firmware/export/buffer.h (limited to 'firmware') diff --git a/firmware/app.lds b/firmware/app.lds index 4dc20ac05e..46a6ca70fb 100644 --- a/firmware/app.lds +++ b/firmware/app.lds @@ -77,7 +77,7 @@ SECTIONS .mp3buf : { - _mp3buf = .; + _mp3buffer = .; } > DRAM .mp3end ENDADDR - 0x300: diff --git a/firmware/buffer.c b/firmware/buffer.c new file mode 100644 index 0000000000..4db0b94889 --- /dev/null +++ b/firmware/buffer.c @@ -0,0 +1,43 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2002 by Linus Nielsen Feltzing + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include +#include "buffer.h" + +#ifdef SIMULATOR +unsigned char mp3buffer[0x100000]; +unsigned char mp3end[1]; +#else +/* defined in linker script */ +extern unsigned char mp3buffer[]; +#endif + +unsigned char *mp3buf; + +void buffer_init(void) +{ + mp3buf = mp3buffer; +} + +void *buffer_alloc(size_t size) +{ + void *retval = mp3buf; + + mp3buf += size; + return retval; +} diff --git a/firmware/export/buffer.h b/firmware/export/buffer.h new file mode 100644 index 0000000000..24b676ad93 --- /dev/null +++ b/firmware/export/buffer.h @@ -0,0 +1,30 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2002 by Linus Nielsen Feltzing + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef BUFFER_H +#define BUFFER_H + +/* defined in linker script */ +extern unsigned char mp3end[]; + +extern unsigned char *mp3buf; + +void buffer_init(void); +void *buffer_alloc(size_t size); + +#endif diff --git a/firmware/mp3data.c b/firmware/mp3data.c index cf9d6832cb..5baa9ec149 100644 --- a/firmware/mp3data.c +++ b/firmware/mp3data.c @@ -34,6 +34,7 @@ #include "debug.h" #include "mp3data.h" #include "file.h" +#include "buffer.h" #define DEBUG_VERBOSE @@ -253,13 +254,6 @@ unsigned long find_next_frame(int fd, int *offset, int max_offset, unsigned long return header; } -#ifdef SIMULATOR -unsigned char mp3buf[0x100000]; -unsigned char mp3end[1]; -#else -extern unsigned char mp3buf[]; -extern unsigned char mp3end[]; -#endif static int fnf_read_index; static int fnf_buf_len; diff --git a/firmware/mpeg.c b/firmware/mpeg.c index ef65303879..fbdc112f58 100644 --- a/firmware/mpeg.c +++ b/firmware/mpeg.c @@ -27,6 +27,7 @@ #include #include "thread.h" #include "mp3data.h" +#include "buffer.h" #ifndef SIMULATOR #include "i2c.h" #include "mas.h" @@ -460,10 +461,6 @@ static struct event_queue mpeg_queue; static char mpeg_stack[DEFAULT_STACK_SIZE + 0x1000]; static char mpeg_thread_name[] = "mpeg"; -/* defined in linker script */ -extern unsigned char mp3buf[]; -extern unsigned char mp3end[]; - static int mp3buflen; static int mp3buf_write; static int mp3buf_swapwrite; diff --git a/firmware/rolo.c b/firmware/rolo.c index f8aad52546..7a0eafb79e 100644 --- a/firmware/rolo.c +++ b/firmware/rolo.c @@ -26,6 +26,7 @@ #include "system.h" #include "i2c.h" #include "string.h" +#include "buffer.h" #define IRQ0_EDGE_TRIGGER 0x80 @@ -36,6 +37,8 @@ static void rolo_error(char *text) lcd_puts_scroll(0, 1, text); lcd_update(); button_get(true); + button_get(true); + button_get(true); lcd_stop_scroll(); } /*************************************************************************** @@ -49,7 +52,6 @@ int rolo_load(char* filename) { int fd,slen; unsigned long length,file_length,i; - extern unsigned char mp3buf[],mp3end; unsigned short checksum,file_checksum; unsigned char* ramstart = (void*)0x09000000; void (*start_func)(void) = (void*)ramstart + 0x200; @@ -88,7 +90,7 @@ int rolo_load(char* filename) lseek(fd, FIRMWARE_OFFSET_FILE_DATA, SEEK_SET); /* verify that file can be read and descrambled */ - if ((&mp3buf[0] + (2*length)+4) >= &mp3end) { + if ((mp3buf + (2*length)+4) >= &mp3end) { rolo_error("Not enough room to load file"); return -1; } -- cgit v1.2.3