From 728868a86311bf67ba6624896bb461351010f415 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Stenberg?= Date: Fri, 7 Mar 2003 14:38:51 +0000 Subject: I am silly. We need the dedicated buffer for ram playlists (dir play). Now only uses the mp3 buffer when loading a list from disk. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3398 a1c6a512-1295-4272-9138-f99709370657 --- apps/playlist.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'apps/playlist.c') diff --git a/apps/playlist.c b/apps/playlist.c index 31c8648147..c458821688 100644 --- a/apps/playlist.c +++ b/apps/playlist.c @@ -40,10 +40,11 @@ static struct playlist_info playlist; #define QUEUE_FILE ROCKBOX_DIR "/.queue_file" -#define PLAYLIST_BUFFER_SIZE (&mp3end - &mp3buf[0]) + +#define PLAYLIST_BUFFER_SIZE (AVERAGE_FILENAME_LENGTH*MAX_FILES_IN_DIR) +static unsigned char playlist_buffer[PLAYLIST_BUFFER_SIZE]; extern unsigned char mp3buf[],mp3end; -static unsigned char* playlist_buffer = mp3buf; static int playlist_end_pos = 0; static char now_playing[MAX_PATH+1]; @@ -643,15 +644,20 @@ void add_indices_to_playlist(void) int i = 0; int count = 0; int next_tick = current_tick + HZ; + unsigned char* buffer = playlist_buffer; + int buflen = PLAYLIST_BUFFER_SIZE; bool store_index; - - unsigned char *p = playlist_buffer; + unsigned char *p; char line[16]; if(!playlist.in_ram) { fd = open(playlist.filename, O_RDONLY); if(-1 == fd) return; /* failure */ + + /* use mp3 buffer for maximum load speed */ + buflen = (&mp3end - &mp3buf[0]); + buffer = mp3buf; } store_index = true; @@ -663,13 +669,13 @@ void add_indices_to_playlist(void) if(playlist.in_ram) { nread = playlist_end_pos; } else { - nread = read(fd, playlist_buffer, PLAYLIST_BUFFER_SIZE); + nread = read(fd, buffer, buflen); /* Terminate on EOF */ if(nread <= 0) break; } - p = playlist_buffer; + p = buffer; for(count=0; count < nread; count++,p++) { -- cgit v1.2.3