summaryrefslogtreecommitdiff
path: root/apps/playlist.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/playlist.c')
-rw-r--r--apps/playlist.c40
1 files changed, 27 insertions, 13 deletions
diff --git a/apps/playlist.c b/apps/playlist.c
index 1e96ebf46b..0c4fe9785b 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -664,19 +664,21 @@ int playlist_remove_all_tracks(struct playlist_info *playlist)
664 664
665 665
666/* 666/*
667 * Add track to playlist at specified position. There are five special 667 * Add track to playlist at specified position. There are seven special
668 * positions that can be specified: 668 * positions that can be specified:
669 * PLAYLIST_PREPEND - Add track at beginning of playlist 669 * PLAYLIST_PREPEND - Add track at beginning of playlist
670 * PLAYLIST_INSERT - Add track after current song. NOTE: If 670 * PLAYLIST_INSERT - Add track after current song. NOTE: If
671 * there are already inserted tracks then track 671 * there are already inserted tracks then track
672 * is added to the end of the insertion list 672 * is added to the end of the insertion list
673 * PLAYLIST_INSERT_FIRST - Add track immediately after current song, no 673 * PLAYLIST_INSERT_FIRST - Add track immediately after current song, no
674 * matter what other tracks have been inserted 674 * matter what other tracks have been inserted
675 * PLAYLIST_INSERT_LAST - Add track to end of playlist 675 * PLAYLIST_INSERT_LAST - Add track to end of playlist
676 * PLAYLIST_INSERT_SHUFFLED - Add track at some random point between the 676 * PLAYLIST_INSERT_SHUFFLED - Add track at some random point between the
677 * current playing track and end of playlist 677 * current playing track and end of playlist
678 * PLAYLIST_REPLACE - Erase current playlist, Cue the current track 678 * PLAYLIST_INSERT_LAST_SHUFFLED - Add tracks in random order to the end of
679 * and inster this track at the end. 679 * the playlist.
680 * PLAYLIST_REPLACE - Erase current playlist, Cue the current track
681 * and inster this track at the end.
680 */ 682 */
681static int add_track_to_playlist(struct playlist_info* playlist, 683static int add_track_to_playlist(struct playlist_info* playlist,
682 const char *filename, int position, 684 const char *filename, int position,
@@ -753,6 +755,12 @@ static int add_track_to_playlist(struct playlist_info* playlist,
753 position = insert_position = (rand() % (playlist->amount+1)); 755 position = insert_position = (rand() % (playlist->amount+1));
754 break; 756 break;
755 } 757 }
758 case PLAYLIST_INSERT_LAST_SHUFFLED:
759 {
760 position = insert_position = playlist->last_shuffled_start +
761 rand() % (playlist->amount - playlist->last_shuffled_start + 1);
762 break;
763 }
756 case PLAYLIST_REPLACE: 764 case PLAYLIST_REPLACE:
757 if (playlist_remove_all_tracks(playlist) < 0) 765 if (playlist_remove_all_tracks(playlist) < 0)
758 return -1; 766 return -1;
@@ -2639,7 +2647,13 @@ int playlist_amount(void)
2639{ 2647{
2640 return playlist_amount_ex(NULL); 2648 return playlist_amount_ex(NULL);
2641} 2649}
2642 2650/* set playlist->last_shuffle_start to playlist->amount for
2651 PLAYLIST_INSERT_LAST_SHUFFLED command purposes*/
2652void playlist_set_last_shuffled_start(void)
2653{
2654 struct playlist_info* playlist = &current_playlist;
2655 playlist->last_shuffled_start = playlist->amount;
2656}
2643/* 2657/*
2644 * Create a new playlist If playlist is not NULL then we're loading a 2658 * Create a new playlist If playlist is not NULL then we're loading a
2645 * playlist off disk for viewing/editing. The index_buffer is used to store 2659 * playlist off disk for viewing/editing. The index_buffer is used to store