diff options
| author | Hardeep Sidhu <dyp@pobox.com> | 2006-04-19 02:22:23 +0000 |
|---|---|---|
| committer | Hardeep Sidhu <dyp@pobox.com> | 2006-04-19 02:22:23 +0000 |
| commit | b79c9a61454fbf79a641cf353846ec7690af52f5 (patch) | |
| tree | 3ae53d4926e694aec9bb241b8c08103b2a329f64 | |
| parent | 4b36096b930bef45ba14d09bf0e59ac9c87c3e81 (diff) | |
| download | rockbox-b79c9a61454fbf79a641cf353846ec7690af52f5.zip rockbox-b79c9a61454fbf79a641cf353846ec7690af52f5.tar.gz rockbox-b79c9a61454fbf79a641cf353846ec7690af52f5.tar.bz2 rockbox-b79c9a61454fbf79a641cf353846ec7690af52f5.tar.xz | |
Allow insert shuffled option for directories when playlist is empty. Based on patch #3011 by Jonathan Gordon.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9728 a1c6a512-1295-4272-9138-f99709370657
| -rw-r--r-- | apps/onplay.c | 8 | ||||
| -rw-r--r-- | apps/playlist.c | 12 | ||||
| -rw-r--r-- | apps/playlist.h | 1 |
3 files changed, 17 insertions, 4 deletions
diff --git a/apps/onplay.c b/apps/onplay.c index 5dcbe6e..6ff99d7 100644 --- a/apps/onplay.c +++ b/apps/onplay.c @@ -314,6 +314,14 @@ static bool playlist_options(void) args[i].position = PLAYLIST_INSERT; args[i].queue = false; i++; + + if (selected_file_attr & ATTR_DIRECTORY) + { + items[i].desc = ID2P(LANG_INSERT_SHUFFLED); + args[i].position = PLAYLIST_INSERT_SHUFFLED; + args[i].queue = false; + i++; + } } } diff --git a/apps/playlist.c b/apps/playlist.c index f11cb04..86e963a 100644 --- a/apps/playlist.c +++ b/apps/playlist.c @@ -223,6 +223,7 @@ static void empty_playlist(struct playlist_info* playlist, bool resume) playlist->shuffle_modified = false; playlist->deleted = false; playlist->num_inserted_tracks = 0; + playlist->started = false; playlist->num_cached = 0; playlist->pending_control_sync = false; @@ -602,7 +603,7 @@ static int add_track_to_playlist(struct playlist_info* playlist, break; case PLAYLIST_INSERT_SHUFFLED: { - if (playlist->amount > 0) + if (playlist->started) { int offset; int n = playlist->amount - @@ -620,7 +621,7 @@ static int add_track_to_playlist(struct playlist_info* playlist, insert_position = position; } else - position = insert_position = 0; + position = insert_position = (rand() % (playlist->amount+1)); break; } } @@ -639,11 +640,12 @@ static int add_track_to_playlist(struct playlist_info* playlist, } /* update stored indices if needed */ - if (playlist->amount > 0 && insert_position <= playlist->index) + if (playlist->amount > 0 && insert_position <= playlist->index && + playlist->started) playlist->index++; if (playlist->amount > 0 && insert_position <= playlist->first_index && - position != PLAYLIST_PREPEND) + position != PLAYLIST_PREPEND && playlist->started) { playlist->first_index++; @@ -2313,6 +2315,8 @@ int playlist_start(int start_index, int offset) #endif audio_play(offset); + playlist->started = true; + return 0; } diff --git a/apps/playlist.h b/apps/playlist.h index 3aa5406..1a5bb3d 100644 --- a/apps/playlist.h +++ b/apps/playlist.h @@ -90,6 +90,7 @@ struct playlist_info inserted tracks? */ bool deleted; /* have any tracks been deleted? */ int num_inserted_tracks; /* number of tracks inserted */ + bool started; /* has playlist been started? */ /* cache of playlist control commands waiting to be flushed to to disk */ |