summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2003-05-09 16:01:21 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2003-05-09 16:01:21 +0000
commit20d031f9c70109dae2ea320a4c7264e1e489d8eb (patch)
tree4459bf0a6cbba8e557b60397acfff6f5be3bda10 /apps
parentaf2b7adefe31839bebbc407083d980a112e7242c (diff)
downloadrockbox-20d031f9c70109dae2ea320a4c7264e1e489d8eb.tar.gz
rockbox-20d031f9c70109dae2ea320a4c7264e1e489d8eb.zip
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
Diffstat (limited to 'apps')
-rw-r--r--apps/lang/english.lang10
-rw-r--r--apps/main.c17
-rw-r--r--apps/main_menu.c8
-rw-r--r--apps/onplay.c5
-rw-r--r--apps/playlist.c20
-rw-r--r--apps/playlist.h5
-rw-r--r--apps/settings.c57
-rw-r--r--apps/settings.h16
-rw-r--r--apps/settings_menu.c18
-rw-r--r--apps/tree.c29
-rw-r--r--apps/tree.h1
11 files changed, 121 insertions, 65 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index 83bdc468be..b30a8cd11d 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -1507,3 +1507,13 @@ id: LANG_INVERT_LCD_INVERSE
desc: in settings_menu
eng: "Inverse"
new:
+
+id: LANG_MAX_FILES_IN_DIR
+desc: in settings_menu
+eng: "Max files in dir browser"
+new:
+
+id: LANG_MAX_FILES_IN_PLAYLIST
+desc: in settings_menu
+eng: "Max playlist size"
+new:
diff --git a/apps/main.c b/apps/main.c
index af85db2243..99f01439f7 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -49,6 +49,7 @@
#include "language.h"
#include "wps-display.h"
#include "playlist.h"
+#include "buffer.h"
char appsversion[]=APPSVERSION;
@@ -65,6 +66,7 @@ void app_main(void)
void init(void)
{
init_threads();
+ buffer_init();
lcd_init();
font_init();
show_logo();
@@ -97,6 +99,8 @@ void init(void)
system_init();
kernel_init();
+ buffer_init();
+
settings_reset();
lcd_init();
@@ -165,6 +169,14 @@ void init(void)
settings_load();
+ status_init();
+ usb_start_monitoring();
+ power_init();
+ playlist_init();
+ tree_init();
+
+ /* This one must be the last one, since it wants the rest of the buffer
+ space */
mpeg_init( global_settings.volume,
global_settings.bass,
global_settings.treble,
@@ -173,11 +185,6 @@ void init(void)
global_settings.bass_boost,
global_settings.avc,
global_settings.channel_config );
-
- status_init();
- usb_start_monitoring();
- power_init();
- playlist_init();
}
int main(void)
diff --git a/apps/main_menu.c b/apps/main_menu.c
index b455e074a2..b547d2ba88 100644
--- a/apps/main_menu.c
+++ b/apps/main_menu.c
@@ -41,6 +41,7 @@
#include "fat.h"
#include "sleeptimer.h"
#include "wps.h"
+#include "buffer.h"
#ifdef HAVE_FMRADIO
#include "radio.h"
#endif
@@ -152,14 +153,7 @@ bool show_credits(void)
}
#ifdef SIMULATOR
-#define mp3buf 0
-#define mp3end 0
-
extern bool simulate_usb(void);
-#else
-/* defined in linker script */
-extern unsigned char mp3buf[];
-extern unsigned char mp3end[];
#endif
bool show_info(void)
{
diff --git a/apps/onplay.c b/apps/onplay.c
index 14e3cdd7a7..557c457bbf 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -37,6 +37,7 @@
#include "id3.h"
#include "screens.h"
#include "tree.h"
+#include "buffer.h"
static char* selected_file = NULL;
static bool reload_dir = false;
@@ -113,10 +114,6 @@ static void xingupdate(int percent)
}
-/* defined in linker script */
-extern unsigned char mp3buf[];
-extern unsigned char mp3end[];
-
static int insert_data_in_file(char *fname, int fpos, char *buf, int num_bytes)
{
int readlen;
diff --git a/apps/playlist.c b/apps/playlist.c
index 748c2ce528..b5db084f9b 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -31,6 +31,7 @@
#include "status.h"
#include "applimits.h"
#include "screens.h"
+#include "buffer.h"
#ifdef HAVE_LCD_BITMAP
#include "icons.h"
#include "widgets.h"
@@ -42,10 +43,8 @@ static struct playlist_info playlist;
#define QUEUE_FILE ROCKBOX_DIR "/.queue_file"
-#define PLAYLIST_BUFFER_SIZE (AVERAGE_FILENAME_LENGTH*MAX_FILES_IN_DIR)
-static unsigned char playlist_buffer[PLAYLIST_BUFFER_SIZE];
+static unsigned char *playlist_buffer;
-extern unsigned char mp3buf[],mp3end;
static int playlist_end_pos = 0;
static char now_playing[MAX_PATH+1];
@@ -53,6 +52,11 @@ static char now_playing[MAX_PATH+1];
void playlist_init(void)
{
playlist.fd = -1;
+ playlist.max_playlist_size = global_settings.max_files_in_playlist;
+ playlist.indices = buffer_alloc(playlist.max_playlist_size);
+ playlist.buffer_size =
+ AVERAGE_FILENAME_LENGTH * global_settings.max_files_in_dir;
+ playlist_buffer = buffer_alloc(playlist.buffer_size);
}
/*
@@ -291,7 +295,7 @@ int playlist_add(char *filename)
{
int len = strlen(filename);
- if(len+2 > PLAYLIST_BUFFER_SIZE - playlist_end_pos)
+ if(len+2 > playlist.buffer_size - playlist_end_pos)
return -1;
strcpy(&playlist_buffer[playlist_end_pos], filename);
@@ -655,7 +659,7 @@ void add_indices_to_playlist(void)
int i = 0;
int count = 0;
unsigned char* buffer = playlist_buffer;
- int buflen = PLAYLIST_BUFFER_SIZE;
+ int buflen = playlist.buffer_size;
bool store_index;
unsigned char *p;
@@ -667,7 +671,7 @@ void add_indices_to_playlist(void)
#ifndef SIMULATOR
/* use mp3 buffer for maximum load speed */
- buflen = (&mp3end - &mp3buf[0]);
+ buflen = (mp3end - mp3buf);
buffer = mp3buf;
#endif
}
@@ -705,7 +709,7 @@ void add_indices_to_playlist(void)
/* Store a new entry */
playlist.indices[ playlist.amount ] = i+count;
playlist.amount++;
- if ( playlist.amount >= MAX_PLAYLIST_SIZE ) {
+ if ( playlist.amount >= playlist.max_playlist_size ) {
lcd_clear_display();
lcd_puts(0,0,str(LANG_PLAYINDICES_PLAYLIST));
lcd_puts(0,1,str(LANG_PLAYINDICES_BUFFER));
@@ -772,7 +776,7 @@ void sort_playlist(bool start_current)
if (playlist.amount > 0)
{
- qsort(&playlist.indices, playlist.amount, sizeof(playlist.indices[0]), compare);
+ qsort(playlist.indices, playlist.amount, sizeof(playlist.indices[0]), compare);
}
if (start_current)
diff --git a/apps/playlist.h b/apps/playlist.h
index 2ea4452cca..9ff5122f44 100644
--- a/apps/playlist.h
+++ b/apps/playlist.h
@@ -31,7 +31,10 @@ struct playlist_info
char filename[MAX_PATH]; /* path name of m3u playlist on disk */
int fd; /* file descriptor of the open playlist */
int dirlen; /* Length of the path to the playlist file */
- int indices[MAX_PLAYLIST_SIZE]; /* array of indices */
+ int *indices; /* array of indices */
+ int max_playlist_size; /* Max number of files in playlist. Mirror of
+ global_settings.max_files_in_playlist */
+ int buffer_size; /* Playlist buffer size */
int index; /* index of current playing track */
int first_index; /* index of first song in playlist */
int seed; /* random seed */
diff --git a/apps/settings.c b/apps/settings.c
index 81e4d12f69..74299356bd 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -126,6 +126,8 @@ modified unless the header & checksum test fails.
Rest of config block, only saved to disk:
+0xAA Max number of files in playlist (1000-20000)
+0xAC Max number of files in dir (50-10000)
0xAE fade on pause/unpause/stop setting (bit 0)
caption backlight (bit 1)
0xB0 peak meter clip hold timeout (bit 0-4), peak meter performance (bit 7)
@@ -379,6 +381,14 @@ int settings_save( void )
config_block[0x29]=(unsigned char)(global_settings.topruntime >> 8);
}
+ config_block[0xaa] = (unsigned char)
+ global_settings.max_files_in_playlist & 0xff;
+ config_block[0xab] = (unsigned char)
+ (global_settings.max_files_in_playlist >> 8) & 0xff;
+ config_block[0xac] = (unsigned char)
+ global_settings.max_files_in_dir & 0xff;
+ config_block[0xad] = (unsigned char)
+ (global_settings.max_files_in_dir >> 8) & 0xff;
config_block[0xae] = (unsigned char)
((global_settings.fade_on_stop & 1) |
((global_settings.caption_backlight & 1) << 1));
@@ -695,6 +705,14 @@ void settings_load(void)
if (config_block[0xae] != 0xff)
global_settings.fade_on_stop = config_block[0xae];
+ if (config_block[0xac] != 0xff)
+ global_settings.max_files_in_dir =
+ config_block[0xac] | (config_block[0xad] << 8);
+
+ if (config_block[0xaa] != 0xff)
+ global_settings.max_files_in_playlist =
+ config_block[0xaa] | (config_block[0xab] << 8);
+
memcpy(&global_settings.resume_first_index, &config_block[0xF4], 4);
memcpy(&global_settings.resume_seed, &config_block[0xF8], 4);
@@ -1025,6 +1043,12 @@ bool settings_load_config(char* file)
#endif
else if (!strcasecmp(name, "volume fade"))
set_cfg_bool(&global_settings.fade_on_stop, value);
+ else if (!strcasecmp(name, "max files in dir"))
+ set_cfg_int(&global_settings.max_files_in_dir, value,
+ 50, 10000);
+ else if (!strcasecmp(name, "max files in playlist"))
+ set_cfg_int(&global_settings.max_files_in_playlist, value,
+ 1000, 20000);
}
close(fd);
@@ -1302,6 +1326,11 @@ bool settings_save_config(void)
boolopt[global_settings.rec_editable]);
#endif
+
+ fprintf(fd, "max files in dir: %d\r\n", global_settings.max_files_in_dir);
+ fprintf(fd, "max files in playlist: %d\r\n",
+ global_settings.max_files_in_playlist);
+
close(fd);
lcd_clear_display();
@@ -1384,32 +1413,8 @@ void settings_reset(void) {
global_settings.runtime = 0;
global_settings.topruntime = 0;
global_settings.fade_on_stop = true;
-}
-
-
-/*
- * dump the list of current settings
- */
-void settings_display(void)
-{
-#ifdef DEBUG
- DEBUGF( "\nsettings_display()\n" );
-
- DEBUGF( "\nvolume:\t\t%d\nbalance:\t%d\nbass:\t\t%d\ntreble:\t\t%d\n"
- "loudness:\t%d\nbass boost:\t%d\n",
- global_settings.volume,
- global_settings.balance,
- global_settings.bass,
- global_settings.treble,
- global_settings.loudness,
- global_settings.bass_boost );
-
- DEBUGF( "contrast:\t%d\ninvert:\t%d\npoweroff:\t%d\nbacklight_timeout:\t%d\n",
- global_settings.contrast,
- global_settings.invert,
- global_settings.poweroff,
- global_settings.backlight_timeout );
-#endif
+ global_settings.max_files_in_dir = 400;
+ global_settings.max_files_in_playlist = 10000;
}
bool set_bool(char* string, bool* variable )
diff --git a/apps/settings.h b/apps/settings.h
index 1a29899c01..55a6f96e2e 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -154,6 +154,16 @@ struct user_settings
bool fade_on_stop; /* fade on pause/unpause/stop */
bool caption_backlight; /* turn on backlight at end and start of track */
+
+#ifdef HAVE_FMRADIO
+ int fm_freq_step; /* Frequency step for manual tuning, in kHz */
+ bool fm_force_mono; /* Forces Mono mode if true */
+ bool fm_full_range; /* Enables full 10MHz-160MHz range if true, else
+ only 88MHz-108MHz */
+#endif
+
+ int max_files_in_dir; /* Max entries in directory (file browser) */
+ int max_files_in_playlist; /* Max entries in playlist */
};
/* prototypes */
@@ -209,9 +219,3 @@ enum { REPEAT_OFF, REPEAT_ALL, REPEAT_ONE, NUM_REPEAT_MODES };
enum { SHOW_ALL, SHOW_SUPPORTED, SHOW_MUSIC, SHOW_PLAYLIST, NUM_FILTER_MODES };
#endif /* __SETTINGS_H__ */
-
-
-
-
-
-
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index 7f03da975c..d4a56e728b 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -567,6 +567,20 @@ static bool poweroff(void)
}
#endif
+static bool max_files_in_dir(void)
+{
+ return set_int(str(LANG_MAX_FILES_IN_DIR), "",
+ &global_settings.max_files_in_dir,
+ NULL, 50, 50, 10000 );
+}
+
+static bool max_files_in_playlist(void)
+{
+ return set_int(str(LANG_MAX_FILES_IN_PLAYLIST), "",
+ &global_settings.max_files_in_playlist,
+ NULL, 1000, 1000, 10000 );
+}
+
static bool buffer_margin(void)
{
return set_int(str(LANG_MP3BUFFER_MARGIN), "s",
@@ -574,7 +588,7 @@ static bool buffer_margin(void)
mpeg_set_buffer_margin, 1, 0, 7 );
}
-static bool ff_rewind_min_step(void)
+static bool ff_rewind_min_step(void)
{
char* names[] = { "1s", "2s", "3s", "4s",
"5s", "6s", "8s", "10s",
@@ -783,6 +797,8 @@ static bool system_settings_menu(void)
#ifdef HAVE_ATA_POWER_OFF
{ str(LANG_POWEROFF), poweroff },
#endif
+ { str(LANG_MAX_FILES_IN_DIR), max_files_in_dir },
+ { str(LANG_MAX_FILES_IN_PLAYLIST), max_files_in_playlist },
#ifndef SIMULATOR
{ str(LANG_BATTERY_CAPACITY), battery_capacity },
#endif
diff --git a/apps/tree.c b/apps/tree.c
index 387878c96e..a72c98281c 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -51,21 +51,25 @@
#include "screens.h"
#include "keyboard.h"
#include "onplay.h"
+#include "buffer.h"
#ifdef HAVE_LCD_BITMAP
#include "widgets.h"
#endif
-#define NAME_BUFFER_SIZE (AVERAGE_FILENAME_LENGTH * MAX_FILES_IN_DIR)
+/* Mirror of global_settings.max_files_in_dir */
+int max_files_in_dir;
-static char name_buffer[NAME_BUFFER_SIZE];
-static int name_buffer_length;
+static char *name_buffer;
+static int name_buffer_size; /* Size of allocated buffer */
+static int name_buffer_length; /* Currently used amount */
struct entry {
short attr; /* FAT attributes + file type flags */
char *name;
};
-static struct entry dircache[MAX_FILES_IN_DIR];
+static struct entry *dircache;
+
static int dircursor;
static int dirstart;
static int dirlevel;
@@ -249,7 +253,7 @@ static int showdir(char *path, int start)
name_buffer_length = 0;
dir_buffer_full = false;
- for ( i=0; i<MAX_FILES_IN_DIR; i++ ) {
+ for ( i=0; i < max_files_in_dir; i++ ) {
int len;
struct dirent *entry = readdir(dir);
struct entry* dptr = &dircache[i];
@@ -333,7 +337,7 @@ static int showdir(char *path, int start)
continue;
}
- if (len > NAME_BUFFER_SIZE - name_buffer_length - 1) {
+ if (len > name_buffer_size - name_buffer_length - 1) {
/* Tell the world that we ran out of buffer space */
dir_buffer_full = true;
break;
@@ -348,7 +352,7 @@ static int showdir(char *path, int start)
lastdir[sizeof(lastdir)-1] = 0;
qsort(dircache,filesindir,sizeof(struct entry),compare);
- if ( dir_buffer_full || filesindir == MAX_FILES_IN_DIR ) {
+ if ( dir_buffer_full || filesindir == max_files_in_dir ) {
#ifdef HAVE_LCD_CHARCELLS
lcd_double_height(false);
#endif
@@ -1317,3 +1321,14 @@ bool create_playlist(void)
return true;
}
+
+void tree_init(void)
+{
+ /* We copy the settings value in case it is changed by the user. We can't
+ use the next reboot. */
+ max_files_in_dir = global_settings.max_files_in_dir;
+ name_buffer_size = AVERAGE_FILENAME_LENGTH * max_files_in_dir;
+
+ name_buffer = buffer_alloc(name_buffer_size);
+ dircache = buffer_alloc(max_files_in_dir * sizeof(struct entry));
+}
diff --git a/apps/tree.h b/apps/tree.h
index a1e132f775..eb0aa8b98a 100644
--- a/apps/tree.h
+++ b/apps/tree.h
@@ -32,6 +32,7 @@
#define TREE_ATTR_LNG 0x1000 /* binary lang file */
#define TREE_ATTR_MASK 0xffd0 /* which bits tree.c uses (above + DIR) */
+void tree_init(void);
void browse_root(void);
void set_current_file(char *path);
bool dirbrowse(char *root);