diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/plugins/random_folder_advance_config.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/apps/plugins/random_folder_advance_config.c b/apps/plugins/random_folder_advance_config.c index 96938c6d09..70b721522a 100644 --- a/apps/plugins/random_folder_advance_config.c +++ b/apps/plugins/random_folder_advance_config.c | |||
@@ -31,8 +31,6 @@ static int lasttick; | |||
31 | #define RFADIR_FILE ROCKBOX_DIR "/folder_advance_dir.txt" | 31 | #define RFADIR_FILE ROCKBOX_DIR "/folder_advance_dir.txt" |
32 | #define RFA_FILE_TEXT ROCKBOX_DIR "/folder_advance_list.txt" | 32 | #define RFA_FILE_TEXT ROCKBOX_DIR "/folder_advance_list.txt" |
33 | #define MAX_REMOVED_DIRS 10 | 33 | #define MAX_REMOVED_DIRS 10 |
34 | /* The plugin code fits in less than 10k */ | ||
35 | #define MAX_SHUFFLE_SIZE (PLUGIN_BUFFER_SIZE/4 - 2500) | ||
36 | 34 | ||
37 | char *buffer = NULL; | 35 | char *buffer = NULL; |
38 | ssize_t buffer_size; | 36 | ssize_t buffer_size; |
@@ -43,7 +41,6 @@ struct file_format { | |||
43 | char folder[][MAX_PATH]; | 41 | char folder[][MAX_PATH]; |
44 | }; | 42 | }; |
45 | struct file_format *list = NULL; | 43 | struct file_format *list = NULL; |
46 | static int order[MAX_SHUFFLE_SIZE]; | ||
47 | 44 | ||
48 | void update_screen(bool clear) | 45 | void update_screen(bool clear) |
49 | { | 46 | { |
@@ -466,7 +463,19 @@ int import_list_from_file_text(void) | |||
466 | 463 | ||
467 | int start_shuffled_play(void) | 464 | int start_shuffled_play(void) |
468 | { | 465 | { |
466 | int *order; | ||
467 | size_t max_shuffle_size; | ||
469 | int i = 0; | 468 | int i = 0; |
469 | |||
470 | /* get memory for shuffling */ | ||
471 | order=rb->plugin_get_buffer(&max_shuffle_size); | ||
472 | max_shuffle_size/=sizeof(int); | ||
473 | if (order==NULL || max_shuffle_size==0) | ||
474 | { | ||
475 | rb->splashf(HZ*2, "Not enough memory for shuffling"); | ||
476 | return 0; | ||
477 | } | ||
478 | |||
470 | /* load the dat file if not already done */ | 479 | /* load the dat file if not already done */ |
471 | if ((list == NULL || list->count == 0) && (i = load_list()) != 0) | 480 | if ((list == NULL || list->count == 0) && (i = load_list()) != 0) |
472 | { | 481 | { |
@@ -482,7 +491,7 @@ int start_shuffled_play(void) | |||
482 | 491 | ||
483 | /* shuffle the thing */ | 492 | /* shuffle the thing */ |
484 | rb->srand(*rb->current_tick); | 493 | rb->srand(*rb->current_tick); |
485 | if(list->count>MAX_SHUFFLE_SIZE) | 494 | if(list->count>(int)max_shuffle_size) |
486 | { | 495 | { |
487 | rb->splashf(HZ*2, "Too many files: %d", list->count); | 496 | rb->splashf(HZ*2, "Too many files: %d", list->count); |
488 | return 0; | 497 | return 0; |