diff options
-rw-r--r-- | apps/playlist.c | 18 |
1 files changed, 12 insertions, 6 deletions
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 @@ | |||
40 | static struct playlist_info playlist; | 40 | static struct playlist_info playlist; |
41 | 41 | ||
42 | #define QUEUE_FILE ROCKBOX_DIR "/.queue_file" | 42 | #define QUEUE_FILE ROCKBOX_DIR "/.queue_file" |
43 | #define PLAYLIST_BUFFER_SIZE (&mp3end - &mp3buf[0]) | 43 | |
44 | #define PLAYLIST_BUFFER_SIZE (AVERAGE_FILENAME_LENGTH*MAX_FILES_IN_DIR) | ||
45 | static unsigned char playlist_buffer[PLAYLIST_BUFFER_SIZE]; | ||
44 | 46 | ||
45 | extern unsigned char mp3buf[],mp3end; | 47 | extern unsigned char mp3buf[],mp3end; |
46 | static unsigned char* playlist_buffer = mp3buf; | ||
47 | static int playlist_end_pos = 0; | 48 | static int playlist_end_pos = 0; |
48 | 49 | ||
49 | static char now_playing[MAX_PATH+1]; | 50 | static char now_playing[MAX_PATH+1]; |
@@ -643,15 +644,20 @@ void add_indices_to_playlist(void) | |||
643 | int i = 0; | 644 | int i = 0; |
644 | int count = 0; | 645 | int count = 0; |
645 | int next_tick = current_tick + HZ; | 646 | int next_tick = current_tick + HZ; |
647 | unsigned char* buffer = playlist_buffer; | ||
648 | int buflen = PLAYLIST_BUFFER_SIZE; | ||
646 | bool store_index; | 649 | bool store_index; |
647 | 650 | unsigned char *p; | |
648 | unsigned char *p = playlist_buffer; | ||
649 | char line[16]; | 651 | char line[16]; |
650 | 652 | ||
651 | if(!playlist.in_ram) { | 653 | if(!playlist.in_ram) { |
652 | fd = open(playlist.filename, O_RDONLY); | 654 | fd = open(playlist.filename, O_RDONLY); |
653 | if(-1 == fd) | 655 | if(-1 == fd) |
654 | return; /* failure */ | 656 | return; /* failure */ |
657 | |||
658 | /* use mp3 buffer for maximum load speed */ | ||
659 | buflen = (&mp3end - &mp3buf[0]); | ||
660 | buffer = mp3buf; | ||
655 | } | 661 | } |
656 | 662 | ||
657 | store_index = true; | 663 | store_index = true; |
@@ -663,13 +669,13 @@ void add_indices_to_playlist(void) | |||
663 | if(playlist.in_ram) { | 669 | if(playlist.in_ram) { |
664 | nread = playlist_end_pos; | 670 | nread = playlist_end_pos; |
665 | } else { | 671 | } else { |
666 | nread = read(fd, playlist_buffer, PLAYLIST_BUFFER_SIZE); | 672 | nread = read(fd, buffer, buflen); |
667 | /* Terminate on EOF */ | 673 | /* Terminate on EOF */ |
668 | if(nread <= 0) | 674 | if(nread <= 0) |
669 | break; | 675 | break; |
670 | } | 676 | } |
671 | 677 | ||
672 | p = playlist_buffer; | 678 | p = buffer; |
673 | 679 | ||
674 | for(count=0; count < nread; count++,p++) { | 680 | for(count=0; count < nread; count++,p++) { |
675 | 681 | ||