diff options
Diffstat (limited to 'apps/playlist.c')
-rw-r--r-- | apps/playlist.c | 20 |
1 files changed, 12 insertions, 8 deletions
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) |