diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2008-07-02 09:16:26 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2008-07-02 09:16:26 +0000 |
commit | f48cf6255893db537d76752c2161773e7b927a51 (patch) | |
tree | dacc11ec9702cc993098985f626d1fb98bf0ba3b | |
parent | 580b719d9e755ecace36d7b154bba004dda88cc9 (diff) | |
download | rockbox-f48cf6255893db537d76752c2161773e7b927a51.tar.gz rockbox-f48cf6255893db537d76752c2161773e7b927a51.zip |
fix the random folder behaviour by not letting it start folders which dont have music in them (but were being started before because it has subdirs with music)
Hopefully fixes FS#7077
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17912 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/playlist.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/apps/playlist.c b/apps/playlist.c index 8f800f616b..53becb9fc1 100644 --- a/apps/playlist.c +++ b/apps/playlist.c | |||
@@ -179,7 +179,7 @@ static int get_filename(struct playlist_info* playlist, int index, int seek, | |||
179 | static int get_next_directory(char *dir); | 179 | static int get_next_directory(char *dir); |
180 | static int get_next_dir(char *dir, bool is_forward, bool recursion); | 180 | static int get_next_dir(char *dir, bool is_forward, bool recursion); |
181 | static int get_previous_directory(char *dir); | 181 | static int get_previous_directory(char *dir); |
182 | static int check_subdir_for_music(char *dir, char *subdir); | 182 | static int check_subdir_for_music(char *dir, char *subdir, bool recurse); |
183 | static int format_track_path(char *dest, char *src, int buf_length, int max, | 183 | static int format_track_path(char *dest, char *src, int buf_length, int max, |
184 | const char *dir); | 184 | const char *dir); |
185 | static void display_playlist_count(int count, const unsigned char *fmt, | 185 | static void display_playlist_count(int count, const unsigned char *fmt, |
@@ -1475,7 +1475,6 @@ static int get_next_dir(char *dir, bool is_forward, bool recursion) | |||
1475 | bool exit = false; | 1475 | bool exit = false; |
1476 | struct tree_context* tc = tree_get_context(); | 1476 | struct tree_context* tc = tree_get_context(); |
1477 | int dirfilter = *(tc->dirfilter); | 1477 | int dirfilter = *(tc->dirfilter); |
1478 | |||
1479 | if (global_settings.next_folder == FOLDER_ADVANCE_RANDOM) | 1478 | if (global_settings.next_folder == FOLDER_ADVANCE_RANDOM) |
1480 | { | 1479 | { |
1481 | int fd = open(ROCKBOX_DIR "/folder_advance_list.dat",O_RDONLY); | 1480 | int fd = open(ROCKBOX_DIR "/folder_advance_list.dat",O_RDONLY); |
@@ -1493,7 +1492,7 @@ static int get_next_dir(char *dir, bool is_forward, bool recursion) | |||
1493 | i = rand()%folder_count; | 1492 | i = rand()%folder_count; |
1494 | lseek(fd,sizeof(int) + (MAX_PATH*i),SEEK_SET); | 1493 | lseek(fd,sizeof(int) + (MAX_PATH*i),SEEK_SET); |
1495 | read(fd,buffer,MAX_PATH); | 1494 | read(fd,buffer,MAX_PATH); |
1496 | if (check_subdir_for_music(buffer,"") ==0) | 1495 | if (check_subdir_for_music(buffer, "", false) ==0) |
1497 | exit = true; | 1496 | exit = true; |
1498 | } | 1497 | } |
1499 | if (folder_count) | 1498 | if (folder_count) |
@@ -1561,7 +1560,7 @@ static int get_next_dir(char *dir, bool is_forward, bool recursion) | |||
1561 | { | 1560 | { |
1562 | if (!start_dir) | 1561 | if (!start_dir) |
1563 | { | 1562 | { |
1564 | result = check_subdir_for_music(dir, files[i].name); | 1563 | result = check_subdir_for_music(dir, files[i].name, true); |
1565 | if (result != -1) | 1564 | if (result != -1) |
1566 | { | 1565 | { |
1567 | exit = true; | 1566 | exit = true; |
@@ -1604,7 +1603,7 @@ static int get_next_dir(char *dir, bool is_forward, bool recursion) | |||
1604 | * Checks if there are any music files in the dir or any of its | 1603 | * Checks if there are any music files in the dir or any of its |
1605 | * subdirectories. May be called recursively. | 1604 | * subdirectories. May be called recursively. |
1606 | */ | 1605 | */ |
1607 | static int check_subdir_for_music(char *dir, char *subdir) | 1606 | static int check_subdir_for_music(char *dir, char *subdir, bool recurse) |
1608 | { | 1607 | { |
1609 | int result = -1; | 1608 | int result = -1; |
1610 | int dirlen = strlen(dir); | 1609 | int dirlen = strlen(dir); |
@@ -1639,8 +1638,8 @@ static int check_subdir_for_music(char *dir, char *subdir) | |||
1639 | 1638 | ||
1640 | if (has_music) | 1639 | if (has_music) |
1641 | return 0; | 1640 | return 0; |
1642 | 1641 | ||
1643 | if (has_subdir) | 1642 | if (has_subdir && recurse) |
1644 | { | 1643 | { |
1645 | for (i=0; i<num_files; i++) | 1644 | for (i=0; i<num_files; i++) |
1646 | { | 1645 | { |
@@ -1652,7 +1651,7 @@ static int check_subdir_for_music(char *dir, char *subdir) | |||
1652 | 1651 | ||
1653 | if (files[i].attr & ATTR_DIRECTORY) | 1652 | if (files[i].attr & ATTR_DIRECTORY) |
1654 | { | 1653 | { |
1655 | result = check_subdir_for_music(dir, files[i].name); | 1654 | result = check_subdir_for_music(dir, files[i].name, true); |
1656 | if (!result) | 1655 | if (!result) |
1657 | break; | 1656 | break; |
1658 | } | 1657 | } |
@@ -1675,7 +1674,6 @@ static int check_subdir_for_music(char *dir, char *subdir) | |||
1675 | gui_syncsplash(HZ*2, | 1674 | gui_syncsplash(HZ*2, |
1676 | ID2P(LANG_PLAYLIST_DIRECTORY_ACCESS_ERROR)); | 1675 | ID2P(LANG_PLAYLIST_DIRECTORY_ACCESS_ERROR)); |
1677 | } | 1676 | } |
1678 | |||
1679 | return result; | 1677 | return result; |
1680 | } | 1678 | } |
1681 | 1679 | ||