diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2003-05-09 16:01:21 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2003-05-09 16:01:21 +0000 |
commit | 20d031f9c70109dae2ea320a4c7264e1e489d8eb (patch) | |
tree | 4459bf0a6cbba8e557b60397acfff6f5be3bda10 | |
parent | af2b7adefe31839bebbc407083d980a112e7242c (diff) | |
download | rockbox-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
-rw-r--r-- | apps/lang/english.lang | 10 | ||||
-rw-r--r-- | apps/main.c | 17 | ||||
-rw-r--r-- | apps/main_menu.c | 8 | ||||
-rw-r--r-- | apps/onplay.c | 5 | ||||
-rw-r--r-- | apps/playlist.c | 20 | ||||
-rw-r--r-- | apps/playlist.h | 5 | ||||
-rw-r--r-- | apps/settings.c | 57 | ||||
-rw-r--r-- | apps/settings.h | 16 | ||||
-rw-r--r-- | apps/settings_menu.c | 18 | ||||
-rw-r--r-- | apps/tree.c | 29 | ||||
-rw-r--r-- | apps/tree.h | 1 | ||||
-rw-r--r-- | firmware/app.lds | 2 | ||||
-rw-r--r-- | firmware/buffer.c | 43 | ||||
-rw-r--r-- | firmware/export/buffer.h | 30 | ||||
-rw-r--r-- | firmware/mp3data.c | 8 | ||||
-rw-r--r-- | firmware/mpeg.c | 5 | ||||
-rw-r--r-- | firmware/rolo.c | 6 | ||||
-rw-r--r-- | uisimulator/win32/Makefile | 5 | ||||
-rw-r--r-- | uisimulator/x11/Makefile | 5 |
19 files changed, 209 insertions, 81 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 | |||
1507 | desc: in settings_menu | 1507 | desc: in settings_menu |
1508 | eng: "Inverse" | 1508 | eng: "Inverse" |
1509 | new: | 1509 | new: |
1510 | |||
1511 | id: LANG_MAX_FILES_IN_DIR | ||
1512 | desc: in settings_menu | ||
1513 | eng: "Max files in dir browser" | ||
1514 | new: | ||
1515 | |||
1516 | id: LANG_MAX_FILES_IN_PLAYLIST | ||
1517 | desc: in settings_menu | ||
1518 | eng: "Max playlist size" | ||
1519 | 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 @@ | |||
49 | #include "language.h" | 49 | #include "language.h" |
50 | #include "wps-display.h" | 50 | #include "wps-display.h" |
51 | #include "playlist.h" | 51 | #include "playlist.h" |
52 | #include "buffer.h" | ||
52 | 53 | ||
53 | char appsversion[]=APPSVERSION; | 54 | char appsversion[]=APPSVERSION; |
54 | 55 | ||
@@ -65,6 +66,7 @@ void app_main(void) | |||
65 | void init(void) | 66 | void init(void) |
66 | { | 67 | { |
67 | init_threads(); | 68 | init_threads(); |
69 | buffer_init(); | ||
68 | lcd_init(); | 70 | lcd_init(); |
69 | font_init(); | 71 | font_init(); |
70 | show_logo(); | 72 | show_logo(); |
@@ -97,6 +99,8 @@ void init(void) | |||
97 | system_init(); | 99 | system_init(); |
98 | kernel_init(); | 100 | kernel_init(); |
99 | 101 | ||
102 | buffer_init(); | ||
103 | |||
100 | settings_reset(); | 104 | settings_reset(); |
101 | 105 | ||
102 | lcd_init(); | 106 | lcd_init(); |
@@ -165,6 +169,14 @@ void init(void) | |||
165 | 169 | ||
166 | settings_load(); | 170 | settings_load(); |
167 | 171 | ||
172 | status_init(); | ||
173 | usb_start_monitoring(); | ||
174 | power_init(); | ||
175 | playlist_init(); | ||
176 | tree_init(); | ||
177 | |||
178 | /* This one must be the last one, since it wants the rest of the buffer | ||
179 | space */ | ||
168 | mpeg_init( global_settings.volume, | 180 | mpeg_init( global_settings.volume, |
169 | global_settings.bass, | 181 | global_settings.bass, |
170 | global_settings.treble, | 182 | global_settings.treble, |
@@ -173,11 +185,6 @@ void init(void) | |||
173 | global_settings.bass_boost, | 185 | global_settings.bass_boost, |
174 | global_settings.avc, | 186 | global_settings.avc, |
175 | global_settings.channel_config ); | 187 | global_settings.channel_config ); |
176 | |||
177 | status_init(); | ||
178 | usb_start_monitoring(); | ||
179 | power_init(); | ||
180 | playlist_init(); | ||
181 | } | 188 | } |
182 | 189 | ||
183 | int main(void) | 190 | 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 @@ | |||
41 | #include "fat.h" | 41 | #include "fat.h" |
42 | #include "sleeptimer.h" | 42 | #include "sleeptimer.h" |
43 | #include "wps.h" | 43 | #include "wps.h" |
44 | #include "buffer.h" | ||
44 | #ifdef HAVE_FMRADIO | 45 | #ifdef HAVE_FMRADIO |
45 | #include "radio.h" | 46 | #include "radio.h" |
46 | #endif | 47 | #endif |
@@ -152,14 +153,7 @@ bool show_credits(void) | |||
152 | } | 153 | } |
153 | 154 | ||
154 | #ifdef SIMULATOR | 155 | #ifdef SIMULATOR |
155 | #define mp3buf 0 | ||
156 | #define mp3end 0 | ||
157 | |||
158 | extern bool simulate_usb(void); | 156 | extern bool simulate_usb(void); |
159 | #else | ||
160 | /* defined in linker script */ | ||
161 | extern unsigned char mp3buf[]; | ||
162 | extern unsigned char mp3end[]; | ||
163 | #endif | 157 | #endif |
164 | bool show_info(void) | 158 | bool show_info(void) |
165 | { | 159 | { |
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 @@ | |||
37 | #include "id3.h" | 37 | #include "id3.h" |
38 | #include "screens.h" | 38 | #include "screens.h" |
39 | #include "tree.h" | 39 | #include "tree.h" |
40 | #include "buffer.h" | ||
40 | 41 | ||
41 | static char* selected_file = NULL; | 42 | static char* selected_file = NULL; |
42 | static bool reload_dir = false; | 43 | static bool reload_dir = false; |
@@ -113,10 +114,6 @@ static void xingupdate(int percent) | |||
113 | } | 114 | } |
114 | 115 | ||
115 | 116 | ||
116 | /* defined in linker script */ | ||
117 | extern unsigned char mp3buf[]; | ||
118 | extern unsigned char mp3end[]; | ||
119 | |||
120 | static int insert_data_in_file(char *fname, int fpos, char *buf, int num_bytes) | 117 | static int insert_data_in_file(char *fname, int fpos, char *buf, int num_bytes) |
121 | { | 118 | { |
122 | int readlen; | 119 | 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 @@ | |||
31 | #include "status.h" | 31 | #include "status.h" |
32 | #include "applimits.h" | 32 | #include "applimits.h" |
33 | #include "screens.h" | 33 | #include "screens.h" |
34 | #include "buffer.h" | ||
34 | #ifdef HAVE_LCD_BITMAP | 35 | #ifdef HAVE_LCD_BITMAP |
35 | #include "icons.h" | 36 | #include "icons.h" |
36 | #include "widgets.h" | 37 | #include "widgets.h" |
@@ -42,10 +43,8 @@ static struct playlist_info playlist; | |||
42 | 43 | ||
43 | #define QUEUE_FILE ROCKBOX_DIR "/.queue_file" | 44 | #define QUEUE_FILE ROCKBOX_DIR "/.queue_file" |
44 | 45 | ||
45 | #define PLAYLIST_BUFFER_SIZE (AVERAGE_FILENAME_LENGTH*MAX_FILES_IN_DIR) | 46 | static unsigned char *playlist_buffer; |
46 | static unsigned char playlist_buffer[PLAYLIST_BUFFER_SIZE]; | ||
47 | 47 | ||
48 | extern unsigned char mp3buf[],mp3end; | ||
49 | static int playlist_end_pos = 0; | 48 | static int playlist_end_pos = 0; |
50 | 49 | ||
51 | static char now_playing[MAX_PATH+1]; | 50 | static char now_playing[MAX_PATH+1]; |
@@ -53,6 +52,11 @@ static char now_playing[MAX_PATH+1]; | |||
53 | void playlist_init(void) | 52 | void playlist_init(void) |
54 | { | 53 | { |
55 | playlist.fd = -1; | 54 | playlist.fd = -1; |
55 | playlist.max_playlist_size = global_settings.max_files_in_playlist; | ||
56 | playlist.indices = buffer_alloc(playlist.max_playlist_size); | ||
57 | playlist.buffer_size = | ||
58 | AVERAGE_FILENAME_LENGTH * global_settings.max_files_in_dir; | ||
59 | playlist_buffer = buffer_alloc(playlist.buffer_size); | ||
56 | } | 60 | } |
57 | 61 | ||
58 | /* | 62 | /* |
@@ -291,7 +295,7 @@ int playlist_add(char *filename) | |||
291 | { | 295 | { |
292 | int len = strlen(filename); | 296 | int len = strlen(filename); |
293 | 297 | ||
294 | if(len+2 > PLAYLIST_BUFFER_SIZE - playlist_end_pos) | 298 | if(len+2 > playlist.buffer_size - playlist_end_pos) |
295 | return -1; | 299 | return -1; |
296 | 300 | ||
297 | strcpy(&playlist_buffer[playlist_end_pos], filename); | 301 | strcpy(&playlist_buffer[playlist_end_pos], filename); |
@@ -655,7 +659,7 @@ void add_indices_to_playlist(void) | |||
655 | int i = 0; | 659 | int i = 0; |
656 | int count = 0; | 660 | int count = 0; |
657 | unsigned char* buffer = playlist_buffer; | 661 | unsigned char* buffer = playlist_buffer; |
658 | int buflen = PLAYLIST_BUFFER_SIZE; | 662 | int buflen = playlist.buffer_size; |
659 | bool store_index; | 663 | bool store_index; |
660 | unsigned char *p; | 664 | unsigned char *p; |
661 | 665 | ||
@@ -667,7 +671,7 @@ void add_indices_to_playlist(void) | |||
667 | 671 | ||
668 | #ifndef SIMULATOR | 672 | #ifndef SIMULATOR |
669 | /* use mp3 buffer for maximum load speed */ | 673 | /* use mp3 buffer for maximum load speed */ |
670 | buflen = (&mp3end - &mp3buf[0]); | 674 | buflen = (mp3end - mp3buf); |
671 | buffer = mp3buf; | 675 | buffer = mp3buf; |
672 | #endif | 676 | #endif |
673 | } | 677 | } |
@@ -705,7 +709,7 @@ void add_indices_to_playlist(void) | |||
705 | /* Store a new entry */ | 709 | /* Store a new entry */ |
706 | playlist.indices[ playlist.amount ] = i+count; | 710 | playlist.indices[ playlist.amount ] = i+count; |
707 | playlist.amount++; | 711 | playlist.amount++; |
708 | if ( playlist.amount >= MAX_PLAYLIST_SIZE ) { | 712 | if ( playlist.amount >= playlist.max_playlist_size ) { |
709 | lcd_clear_display(); | 713 | lcd_clear_display(); |
710 | lcd_puts(0,0,str(LANG_PLAYINDICES_PLAYLIST)); | 714 | lcd_puts(0,0,str(LANG_PLAYINDICES_PLAYLIST)); |
711 | lcd_puts(0,1,str(LANG_PLAYINDICES_BUFFER)); | 715 | lcd_puts(0,1,str(LANG_PLAYINDICES_BUFFER)); |
@@ -772,7 +776,7 @@ void sort_playlist(bool start_current) | |||
772 | 776 | ||
773 | if (playlist.amount > 0) | 777 | if (playlist.amount > 0) |
774 | { | 778 | { |
775 | qsort(&playlist.indices, playlist.amount, sizeof(playlist.indices[0]), compare); | 779 | qsort(playlist.indices, playlist.amount, sizeof(playlist.indices[0]), compare); |
776 | } | 780 | } |
777 | 781 | ||
778 | if (start_current) | 782 | 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 | |||
31 | char filename[MAX_PATH]; /* path name of m3u playlist on disk */ | 31 | char filename[MAX_PATH]; /* path name of m3u playlist on disk */ |
32 | int fd; /* file descriptor of the open playlist */ | 32 | int fd; /* file descriptor of the open playlist */ |
33 | int dirlen; /* Length of the path to the playlist file */ | 33 | int dirlen; /* Length of the path to the playlist file */ |
34 | int indices[MAX_PLAYLIST_SIZE]; /* array of indices */ | 34 | int *indices; /* array of indices */ |
35 | int max_playlist_size; /* Max number of files in playlist. Mirror of | ||
36 | global_settings.max_files_in_playlist */ | ||
37 | int buffer_size; /* Playlist buffer size */ | ||
35 | int index; /* index of current playing track */ | 38 | int index; /* index of current playing track */ |
36 | int first_index; /* index of first song in playlist */ | 39 | int first_index; /* index of first song in playlist */ |
37 | int seed; /* random seed */ | 40 | 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. | |||
126 | 126 | ||
127 | 127 | ||
128 | Rest of config block, only saved to disk: | 128 | Rest of config block, only saved to disk: |
129 | 0xAA Max number of files in playlist (1000-20000) | ||
130 | 0xAC Max number of files in dir (50-10000) | ||
129 | 0xAE fade on pause/unpause/stop setting (bit 0) | 131 | 0xAE fade on pause/unpause/stop setting (bit 0) |
130 | caption backlight (bit 1) | 132 | caption backlight (bit 1) |
131 | 0xB0 peak meter clip hold timeout (bit 0-4), peak meter performance (bit 7) | 133 | 0xB0 peak meter clip hold timeout (bit 0-4), peak meter performance (bit 7) |
@@ -379,6 +381,14 @@ int settings_save( void ) | |||
379 | config_block[0x29]=(unsigned char)(global_settings.topruntime >> 8); | 381 | config_block[0x29]=(unsigned char)(global_settings.topruntime >> 8); |
380 | } | 382 | } |
381 | 383 | ||
384 | config_block[0xaa] = (unsigned char) | ||
385 | global_settings.max_files_in_playlist & 0xff; | ||
386 | config_block[0xab] = (unsigned char) | ||
387 | (global_settings.max_files_in_playlist >> 8) & 0xff; | ||
388 | config_block[0xac] = (unsigned char) | ||
389 | global_settings.max_files_in_dir & 0xff; | ||
390 | config_block[0xad] = (unsigned char) | ||
391 | (global_settings.max_files_in_dir >> 8) & 0xff; | ||
382 | config_block[0xae] = (unsigned char) | 392 | config_block[0xae] = (unsigned char) |
383 | ((global_settings.fade_on_stop & 1) | | 393 | ((global_settings.fade_on_stop & 1) | |
384 | ((global_settings.caption_backlight & 1) << 1)); | 394 | ((global_settings.caption_backlight & 1) << 1)); |
@@ -695,6 +705,14 @@ void settings_load(void) | |||
695 | if (config_block[0xae] != 0xff) | 705 | if (config_block[0xae] != 0xff) |
696 | global_settings.fade_on_stop = config_block[0xae]; | 706 | global_settings.fade_on_stop = config_block[0xae]; |
697 | 707 | ||
708 | if (config_block[0xac] != 0xff) | ||
709 | global_settings.max_files_in_dir = | ||
710 | config_block[0xac] | (config_block[0xad] << 8); | ||
711 | |||
712 | if (config_block[0xaa] != 0xff) | ||
713 | global_settings.max_files_in_playlist = | ||
714 | config_block[0xaa] | (config_block[0xab] << 8); | ||
715 | |||
698 | memcpy(&global_settings.resume_first_index, &config_block[0xF4], 4); | 716 | memcpy(&global_settings.resume_first_index, &config_block[0xF4], 4); |
699 | memcpy(&global_settings.resume_seed, &config_block[0xF8], 4); | 717 | memcpy(&global_settings.resume_seed, &config_block[0xF8], 4); |
700 | 718 | ||
@@ -1025,6 +1043,12 @@ bool settings_load_config(char* file) | |||
1025 | #endif | 1043 | #endif |
1026 | else if (!strcasecmp(name, "volume fade")) | 1044 | else if (!strcasecmp(name, "volume fade")) |
1027 | set_cfg_bool(&global_settings.fade_on_stop, value); | 1045 | set_cfg_bool(&global_settings.fade_on_stop, value); |
1046 | else if (!strcasecmp(name, "max files in dir")) | ||
1047 | set_cfg_int(&global_settings.max_files_in_dir, value, | ||
1048 | 50, 10000); | ||
1049 | else if (!strcasecmp(name, "max files in playlist")) | ||
1050 | set_cfg_int(&global_settings.max_files_in_playlist, value, | ||
1051 | 1000, 20000); | ||
1028 | } | 1052 | } |
1029 | 1053 | ||
1030 | close(fd); | 1054 | close(fd); |
@@ -1302,6 +1326,11 @@ bool settings_save_config(void) | |||
1302 | boolopt[global_settings.rec_editable]); | 1326 | boolopt[global_settings.rec_editable]); |
1303 | 1327 | ||
1304 | #endif | 1328 | #endif |
1329 | |||
1330 | fprintf(fd, "max files in dir: %d\r\n", global_settings.max_files_in_dir); | ||
1331 | fprintf(fd, "max files in playlist: %d\r\n", | ||
1332 | global_settings.max_files_in_playlist); | ||
1333 | |||
1305 | close(fd); | 1334 | close(fd); |
1306 | 1335 | ||
1307 | lcd_clear_display(); | 1336 | lcd_clear_display(); |
@@ -1384,32 +1413,8 @@ void settings_reset(void) { | |||
1384 | global_settings.runtime = 0; | 1413 | global_settings.runtime = 0; |
1385 | global_settings.topruntime = 0; | 1414 | global_settings.topruntime = 0; |
1386 | global_settings.fade_on_stop = true; | 1415 | global_settings.fade_on_stop = true; |
1387 | } | 1416 | global_settings.max_files_in_dir = 400; |
1388 | 1417 | global_settings.max_files_in_playlist = 10000; | |
1389 | |||
1390 | /* | ||
1391 | * dump the list of current settings | ||
1392 | */ | ||
1393 | void settings_display(void) | ||
1394 | { | ||
1395 | #ifdef DEBUG | ||
1396 | DEBUGF( "\nsettings_display()\n" ); | ||
1397 | |||
1398 | DEBUGF( "\nvolume:\t\t%d\nbalance:\t%d\nbass:\t\t%d\ntreble:\t\t%d\n" | ||
1399 | "loudness:\t%d\nbass boost:\t%d\n", | ||
1400 | global_settings.volume, | ||
1401 | global_settings.balance, | ||
1402 | global_settings.bass, | ||
1403 | global_settings.treble, | ||
1404 | global_settings.loudness, | ||
1405 | global_settings.bass_boost ); | ||
1406 | |||
1407 | DEBUGF( "contrast:\t%d\ninvert:\t%d\npoweroff:\t%d\nbacklight_timeout:\t%d\n", | ||
1408 | global_settings.contrast, | ||
1409 | global_settings.invert, | ||
1410 | global_settings.poweroff, | ||
1411 | global_settings.backlight_timeout ); | ||
1412 | #endif | ||
1413 | } | 1418 | } |
1414 | 1419 | ||
1415 | bool set_bool(char* string, bool* variable ) | 1420 | 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 | |||
154 | 154 | ||
155 | bool fade_on_stop; /* fade on pause/unpause/stop */ | 155 | bool fade_on_stop; /* fade on pause/unpause/stop */ |
156 | bool caption_backlight; /* turn on backlight at end and start of track */ | 156 | bool caption_backlight; /* turn on backlight at end and start of track */ |
157 | |||
158 | #ifdef HAVE_FMRADIO | ||
159 | int fm_freq_step; /* Frequency step for manual tuning, in kHz */ | ||
160 | bool fm_force_mono; /* Forces Mono mode if true */ | ||
161 | bool fm_full_range; /* Enables full 10MHz-160MHz range if true, else | ||
162 | only 88MHz-108MHz */ | ||
163 | #endif | ||
164 | |||
165 | int max_files_in_dir; /* Max entries in directory (file browser) */ | ||
166 | int max_files_in_playlist; /* Max entries in playlist */ | ||
157 | }; | 167 | }; |
158 | 168 | ||
159 | /* prototypes */ | 169 | /* prototypes */ |
@@ -209,9 +219,3 @@ enum { REPEAT_OFF, REPEAT_ALL, REPEAT_ONE, NUM_REPEAT_MODES }; | |||
209 | enum { SHOW_ALL, SHOW_SUPPORTED, SHOW_MUSIC, SHOW_PLAYLIST, NUM_FILTER_MODES }; | 219 | enum { SHOW_ALL, SHOW_SUPPORTED, SHOW_MUSIC, SHOW_PLAYLIST, NUM_FILTER_MODES }; |
210 | 220 | ||
211 | #endif /* __SETTINGS_H__ */ | 221 | #endif /* __SETTINGS_H__ */ |
212 | |||
213 | |||
214 | |||
215 | |||
216 | |||
217 | |||
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) | |||
567 | } | 567 | } |
568 | #endif | 568 | #endif |
569 | 569 | ||
570 | static bool max_files_in_dir(void) | ||
571 | { | ||
572 | return set_int(str(LANG_MAX_FILES_IN_DIR), "", | ||
573 | &global_settings.max_files_in_dir, | ||
574 | NULL, 50, 50, 10000 ); | ||
575 | } | ||
576 | |||
577 | static bool max_files_in_playlist(void) | ||
578 | { | ||
579 | return set_int(str(LANG_MAX_FILES_IN_PLAYLIST), "", | ||
580 | &global_settings.max_files_in_playlist, | ||
581 | NULL, 1000, 1000, 10000 ); | ||
582 | } | ||
583 | |||
570 | static bool buffer_margin(void) | 584 | static bool buffer_margin(void) |
571 | { | 585 | { |
572 | return set_int(str(LANG_MP3BUFFER_MARGIN), "s", | 586 | return set_int(str(LANG_MP3BUFFER_MARGIN), "s", |
@@ -574,7 +588,7 @@ static bool buffer_margin(void) | |||
574 | mpeg_set_buffer_margin, 1, 0, 7 ); | 588 | mpeg_set_buffer_margin, 1, 0, 7 ); |
575 | } | 589 | } |
576 | 590 | ||
577 | static bool ff_rewind_min_step(void) | 591 | static bool ff_rewind_min_step(void) |
578 | { | 592 | { |
579 | char* names[] = { "1s", "2s", "3s", "4s", | 593 | char* names[] = { "1s", "2s", "3s", "4s", |
580 | "5s", "6s", "8s", "10s", | 594 | "5s", "6s", "8s", "10s", |
@@ -783,6 +797,8 @@ static bool system_settings_menu(void) | |||
783 | #ifdef HAVE_ATA_POWER_OFF | 797 | #ifdef HAVE_ATA_POWER_OFF |
784 | { str(LANG_POWEROFF), poweroff }, | 798 | { str(LANG_POWEROFF), poweroff }, |
785 | #endif | 799 | #endif |
800 | { str(LANG_MAX_FILES_IN_DIR), max_files_in_dir }, | ||
801 | { str(LANG_MAX_FILES_IN_PLAYLIST), max_files_in_playlist }, | ||
786 | #ifndef SIMULATOR | 802 | #ifndef SIMULATOR |
787 | { str(LANG_BATTERY_CAPACITY), battery_capacity }, | 803 | { str(LANG_BATTERY_CAPACITY), battery_capacity }, |
788 | #endif | 804 | #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 @@ | |||
51 | #include "screens.h" | 51 | #include "screens.h" |
52 | #include "keyboard.h" | 52 | #include "keyboard.h" |
53 | #include "onplay.h" | 53 | #include "onplay.h" |
54 | #include "buffer.h" | ||
54 | 55 | ||
55 | #ifdef HAVE_LCD_BITMAP | 56 | #ifdef HAVE_LCD_BITMAP |
56 | #include "widgets.h" | 57 | #include "widgets.h" |
57 | #endif | 58 | #endif |
58 | 59 | ||
59 | #define NAME_BUFFER_SIZE (AVERAGE_FILENAME_LENGTH * MAX_FILES_IN_DIR) | 60 | /* Mirror of global_settings.max_files_in_dir */ |
61 | int max_files_in_dir; | ||
60 | 62 | ||
61 | static char name_buffer[NAME_BUFFER_SIZE]; | 63 | static char *name_buffer; |
62 | static int name_buffer_length; | 64 | static int name_buffer_size; /* Size of allocated buffer */ |
65 | static int name_buffer_length; /* Currently used amount */ | ||
63 | struct entry { | 66 | struct entry { |
64 | short attr; /* FAT attributes + file type flags */ | 67 | short attr; /* FAT attributes + file type flags */ |
65 | char *name; | 68 | char *name; |
66 | }; | 69 | }; |
67 | 70 | ||
68 | static struct entry dircache[MAX_FILES_IN_DIR]; | 71 | static struct entry *dircache; |
72 | |||
69 | static int dircursor; | 73 | static int dircursor; |
70 | static int dirstart; | 74 | static int dirstart; |
71 | static int dirlevel; | 75 | static int dirlevel; |
@@ -249,7 +253,7 @@ static int showdir(char *path, int start) | |||
249 | name_buffer_length = 0; | 253 | name_buffer_length = 0; |
250 | dir_buffer_full = false; | 254 | dir_buffer_full = false; |
251 | 255 | ||
252 | for ( i=0; i<MAX_FILES_IN_DIR; i++ ) { | 256 | for ( i=0; i < max_files_in_dir; i++ ) { |
253 | int len; | 257 | int len; |
254 | struct dirent *entry = readdir(dir); | 258 | struct dirent *entry = readdir(dir); |
255 | struct entry* dptr = &dircache[i]; | 259 | struct entry* dptr = &dircache[i]; |
@@ -333,7 +337,7 @@ static int showdir(char *path, int start) | |||
333 | continue; | 337 | continue; |
334 | } | 338 | } |
335 | 339 | ||
336 | if (len > NAME_BUFFER_SIZE - name_buffer_length - 1) { | 340 | if (len > name_buffer_size - name_buffer_length - 1) { |
337 | /* Tell the world that we ran out of buffer space */ | 341 | /* Tell the world that we ran out of buffer space */ |
338 | dir_buffer_full = true; | 342 | dir_buffer_full = true; |
339 | break; | 343 | break; |
@@ -348,7 +352,7 @@ static int showdir(char *path, int start) | |||
348 | lastdir[sizeof(lastdir)-1] = 0; | 352 | lastdir[sizeof(lastdir)-1] = 0; |
349 | qsort(dircache,filesindir,sizeof(struct entry),compare); | 353 | qsort(dircache,filesindir,sizeof(struct entry),compare); |
350 | 354 | ||
351 | if ( dir_buffer_full || filesindir == MAX_FILES_IN_DIR ) { | 355 | if ( dir_buffer_full || filesindir == max_files_in_dir ) { |
352 | #ifdef HAVE_LCD_CHARCELLS | 356 | #ifdef HAVE_LCD_CHARCELLS |
353 | lcd_double_height(false); | 357 | lcd_double_height(false); |
354 | #endif | 358 | #endif |
@@ -1317,3 +1321,14 @@ bool create_playlist(void) | |||
1317 | 1321 | ||
1318 | return true; | 1322 | return true; |
1319 | } | 1323 | } |
1324 | |||
1325 | void tree_init(void) | ||
1326 | { | ||
1327 | /* We copy the settings value in case it is changed by the user. We can't | ||
1328 | use the next reboot. */ | ||
1329 | max_files_in_dir = global_settings.max_files_in_dir; | ||
1330 | name_buffer_size = AVERAGE_FILENAME_LENGTH * max_files_in_dir; | ||
1331 | |||
1332 | name_buffer = buffer_alloc(name_buffer_size); | ||
1333 | dircache = buffer_alloc(max_files_in_dir * sizeof(struct entry)); | ||
1334 | } | ||
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 @@ | |||
32 | #define TREE_ATTR_LNG 0x1000 /* binary lang file */ | 32 | #define TREE_ATTR_LNG 0x1000 /* binary lang file */ |
33 | #define TREE_ATTR_MASK 0xffd0 /* which bits tree.c uses (above + DIR) */ | 33 | #define TREE_ATTR_MASK 0xffd0 /* which bits tree.c uses (above + DIR) */ |
34 | 34 | ||
35 | void tree_init(void); | ||
35 | void browse_root(void); | 36 | void browse_root(void); |
36 | void set_current_file(char *path); | 37 | void set_current_file(char *path); |
37 | bool dirbrowse(char *root); | 38 | bool dirbrowse(char *root); |
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 | |||
77 | 77 | ||
78 | .mp3buf : | 78 | .mp3buf : |
79 | { | 79 | { |
80 | _mp3buf = .; | 80 | _mp3buffer = .; |
81 | } > DRAM | 81 | } > DRAM |
82 | 82 | ||
83 | .mp3end ENDADDR - 0x300: | 83 | .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 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Linus Nielsen Feltzing | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include <stdio.h> | ||
20 | #include "buffer.h" | ||
21 | |||
22 | #ifdef SIMULATOR | ||
23 | unsigned char mp3buffer[0x100000]; | ||
24 | unsigned char mp3end[1]; | ||
25 | #else | ||
26 | /* defined in linker script */ | ||
27 | extern unsigned char mp3buffer[]; | ||
28 | #endif | ||
29 | |||
30 | unsigned char *mp3buf; | ||
31 | |||
32 | void buffer_init(void) | ||
33 | { | ||
34 | mp3buf = mp3buffer; | ||
35 | } | ||
36 | |||
37 | void *buffer_alloc(size_t size) | ||
38 | { | ||
39 | void *retval = mp3buf; | ||
40 | |||
41 | mp3buf += size; | ||
42 | return retval; | ||
43 | } | ||
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 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Linus Nielsen Feltzing | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #ifndef BUFFER_H | ||
20 | #define BUFFER_H | ||
21 | |||
22 | /* defined in linker script */ | ||
23 | extern unsigned char mp3end[]; | ||
24 | |||
25 | extern unsigned char *mp3buf; | ||
26 | |||
27 | void buffer_init(void); | ||
28 | void *buffer_alloc(size_t size); | ||
29 | |||
30 | #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 @@ | |||
34 | #include "debug.h" | 34 | #include "debug.h" |
35 | #include "mp3data.h" | 35 | #include "mp3data.h" |
36 | #include "file.h" | 36 | #include "file.h" |
37 | #include "buffer.h" | ||
37 | 38 | ||
38 | #define DEBUG_VERBOSE | 39 | #define DEBUG_VERBOSE |
39 | 40 | ||
@@ -253,13 +254,6 @@ unsigned long find_next_frame(int fd, int *offset, int max_offset, unsigned long | |||
253 | return header; | 254 | return header; |
254 | } | 255 | } |
255 | 256 | ||
256 | #ifdef SIMULATOR | ||
257 | unsigned char mp3buf[0x100000]; | ||
258 | unsigned char mp3end[1]; | ||
259 | #else | ||
260 | extern unsigned char mp3buf[]; | ||
261 | extern unsigned char mp3end[]; | ||
262 | #endif | ||
263 | static int fnf_read_index; | 257 | static int fnf_read_index; |
264 | static int fnf_buf_len; | 258 | static int fnf_buf_len; |
265 | 259 | ||
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 @@ | |||
27 | #include <kernel.h> | 27 | #include <kernel.h> |
28 | #include "thread.h" | 28 | #include "thread.h" |
29 | #include "mp3data.h" | 29 | #include "mp3data.h" |
30 | #include "buffer.h" | ||
30 | #ifndef SIMULATOR | 31 | #ifndef SIMULATOR |
31 | #include "i2c.h" | 32 | #include "i2c.h" |
32 | #include "mas.h" | 33 | #include "mas.h" |
@@ -460,10 +461,6 @@ static struct event_queue mpeg_queue; | |||
460 | static char mpeg_stack[DEFAULT_STACK_SIZE + 0x1000]; | 461 | static char mpeg_stack[DEFAULT_STACK_SIZE + 0x1000]; |
461 | static char mpeg_thread_name[] = "mpeg"; | 462 | static char mpeg_thread_name[] = "mpeg"; |
462 | 463 | ||
463 | /* defined in linker script */ | ||
464 | extern unsigned char mp3buf[]; | ||
465 | extern unsigned char mp3end[]; | ||
466 | |||
467 | static int mp3buflen; | 464 | static int mp3buflen; |
468 | static int mp3buf_write; | 465 | static int mp3buf_write; |
469 | static int mp3buf_swapwrite; | 466 | 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 @@ | |||
26 | #include "system.h" | 26 | #include "system.h" |
27 | #include "i2c.h" | 27 | #include "i2c.h" |
28 | #include "string.h" | 28 | #include "string.h" |
29 | #include "buffer.h" | ||
29 | 30 | ||
30 | #define IRQ0_EDGE_TRIGGER 0x80 | 31 | #define IRQ0_EDGE_TRIGGER 0x80 |
31 | 32 | ||
@@ -36,6 +37,8 @@ static void rolo_error(char *text) | |||
36 | lcd_puts_scroll(0, 1, text); | 37 | lcd_puts_scroll(0, 1, text); |
37 | lcd_update(); | 38 | lcd_update(); |
38 | button_get(true); | 39 | button_get(true); |
40 | button_get(true); | ||
41 | button_get(true); | ||
39 | lcd_stop_scroll(); | 42 | lcd_stop_scroll(); |
40 | } | 43 | } |
41 | /*************************************************************************** | 44 | /*************************************************************************** |
@@ -49,7 +52,6 @@ int rolo_load(char* filename) | |||
49 | { | 52 | { |
50 | int fd,slen; | 53 | int fd,slen; |
51 | unsigned long length,file_length,i; | 54 | unsigned long length,file_length,i; |
52 | extern unsigned char mp3buf[],mp3end; | ||
53 | unsigned short checksum,file_checksum; | 55 | unsigned short checksum,file_checksum; |
54 | unsigned char* ramstart = (void*)0x09000000; | 56 | unsigned char* ramstart = (void*)0x09000000; |
55 | void (*start_func)(void) = (void*)ramstart + 0x200; | 57 | void (*start_func)(void) = (void*)ramstart + 0x200; |
@@ -88,7 +90,7 @@ int rolo_load(char* filename) | |||
88 | lseek(fd, FIRMWARE_OFFSET_FILE_DATA, SEEK_SET); | 90 | lseek(fd, FIRMWARE_OFFSET_FILE_DATA, SEEK_SET); |
89 | 91 | ||
90 | /* verify that file can be read and descrambled */ | 92 | /* verify that file can be read and descrambled */ |
91 | if ((&mp3buf[0] + (2*length)+4) >= &mp3end) { | 93 | if ((mp3buf + (2*length)+4) >= &mp3end) { |
92 | rolo_error("Not enough room to load file"); | 94 | rolo_error("Not enough room to load file"); |
93 | return -1; | 95 | return -1; |
94 | } | 96 | } |
diff --git a/uisimulator/win32/Makefile b/uisimulator/win32/Makefile index 3885e46e6f..c20e82d07d 100644 --- a/uisimulator/win32/Makefile +++ b/uisimulator/win32/Makefile | |||
@@ -89,7 +89,7 @@ else | |||
89 | LCDSRSC = lcd-playersim.c lcd-player.c lcd-player-charset.c font-player.c | 89 | LCDSRSC = lcd-playersim.c lcd-player.c lcd-player-charset.c font-player.c |
90 | endif | 90 | endif |
91 | FIRMSRCS = $(LCDSRSC) id3.c mp3data.c usb.c mpeg.c powermgmt.c power.c \ | 91 | FIRMSRCS = $(LCDSRSC) id3.c mp3data.c usb.c mpeg.c powermgmt.c power.c \ |
92 | sprintf.c | 92 | sprintf.c buffer.c |
93 | 93 | ||
94 | APPS = main.c tree.c menu.c credits.c main_menu.c icons.c language.c \ | 94 | APPS = main.c tree.c menu.c credits.c main_menu.c icons.c language.c \ |
95 | playlist.c wps.c wps-display.c settings.c status.c \ | 95 | playlist.c wps.c wps-display.c settings.c status.c \ |
@@ -272,6 +272,9 @@ $(OBJDIR)/mpeg.o: $(FIRMWAREDIR)/mpeg.c | |||
272 | $(OBJDIR)/sprintf.o: $(COMMON)/sprintf.c | 272 | $(OBJDIR)/sprintf.o: $(COMMON)/sprintf.c |
273 | $(CC) $(CFLAGS) -c $< -o $@ | 273 | $(CC) $(CFLAGS) -c $< -o $@ |
274 | 274 | ||
275 | $(OBJDIR)/buffer.o: $(FIRMWAREDIR)/buffer.c | ||
276 | $(CC) $(CFLAGS) -c $< -o $@ | ||
277 | |||
275 | $(OBJDIR)/ctype.o: $(COMMON)/ctype.c | 278 | $(OBJDIR)/ctype.o: $(COMMON)/ctype.c |
276 | $(CC) $(CFLAGS) $(APPINCLUDES) -c $< -o $@ | 279 | $(CC) $(CFLAGS) $(APPINCLUDES) -c $< -o $@ |
277 | 280 | ||
diff --git a/uisimulator/x11/Makefile b/uisimulator/x11/Makefile index 566a475cea..14b204bb62 100644 --- a/uisimulator/x11/Makefile +++ b/uisimulator/x11/Makefile | |||
@@ -88,7 +88,7 @@ else | |||
88 | LCDSRSC = lcd-playersim.c lcd-player.c font-player.c lcd-player-charset.c | 88 | LCDSRSC = lcd-playersim.c lcd-player.c font-player.c lcd-player-charset.c |
89 | endif | 89 | endif |
90 | FIRMSRCS = $(LCDSRSC) id3.c debug.c usb.c mpeg.c power.c\ | 90 | FIRMSRCS = $(LCDSRSC) id3.c debug.c usb.c mpeg.c power.c\ |
91 | powermgmt.c panic.c mp3data.c sprintf.c | 91 | powermgmt.c panic.c mp3data.c sprintf.c buffer.c |
92 | 92 | ||
93 | APPS = main.c tree.c menu.c credits.c main_menu.c language.c\ | 93 | APPS = main.c tree.c menu.c credits.c main_menu.c language.c\ |
94 | playlist.c wps.c wps-display.c settings.c status.c icons.c\ | 94 | playlist.c wps.c wps-display.c settings.c status.c icons.c\ |
@@ -247,6 +247,9 @@ $(OBJDIR)/mpeg.o: $(FIRMWAREDIR)/mpeg.c | |||
247 | $(OBJDIR)/sprintf.o: $(COMMON)/sprintf.c | 247 | $(OBJDIR)/sprintf.o: $(COMMON)/sprintf.c |
248 | $(CC) $(CFLAGS) -c $< -o $@ | 248 | $(CC) $(CFLAGS) -c $< -o $@ |
249 | 249 | ||
250 | $(OBJDIR)/buffer.o: $(FIRMWAREDIR)/buffer.c | ||
251 | $(CC) $(CFLAGS) -c $< -o $@ | ||
252 | |||
250 | $(OBJDIR)/ctype.o: $(COMMON)/ctype.c | 253 | $(OBJDIR)/ctype.o: $(COMMON)/ctype.c |
251 | $(CC) $(CFLAGS) $(APPINCLUDES) -c $< -o $@ | 254 | $(CC) $(CFLAGS) $(APPINCLUDES) -c $< -o $@ |
252 | 255 | ||