1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Hardeep Sidhu 2006-04-19 02:22:23 +00:00
parent 4b36096b93
commit b79c9a6145
3 changed files with 17 additions and 4 deletions

View file

@ -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++;
}
}
}

View file

@ -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;
}

View file

@ -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 */