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:
parent
4b36096b93
commit
b79c9a6145
3 changed files with 17 additions and 4 deletions
|
|
@ -314,6 +314,14 @@ static bool playlist_options(void)
|
||||||
args[i].position = PLAYLIST_INSERT;
|
args[i].position = PLAYLIST_INSERT;
|
||||||
args[i].queue = false;
|
args[i].queue = false;
|
||||||
i++;
|
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++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -223,6 +223,7 @@ static void empty_playlist(struct playlist_info* playlist, bool resume)
|
||||||
playlist->shuffle_modified = false;
|
playlist->shuffle_modified = false;
|
||||||
playlist->deleted = false;
|
playlist->deleted = false;
|
||||||
playlist->num_inserted_tracks = 0;
|
playlist->num_inserted_tracks = 0;
|
||||||
|
playlist->started = false;
|
||||||
|
|
||||||
playlist->num_cached = 0;
|
playlist->num_cached = 0;
|
||||||
playlist->pending_control_sync = false;
|
playlist->pending_control_sync = false;
|
||||||
|
|
@ -602,7 +603,7 @@ static int add_track_to_playlist(struct playlist_info* playlist,
|
||||||
break;
|
break;
|
||||||
case PLAYLIST_INSERT_SHUFFLED:
|
case PLAYLIST_INSERT_SHUFFLED:
|
||||||
{
|
{
|
||||||
if (playlist->amount > 0)
|
if (playlist->started)
|
||||||
{
|
{
|
||||||
int offset;
|
int offset;
|
||||||
int n = playlist->amount -
|
int n = playlist->amount -
|
||||||
|
|
@ -620,7 +621,7 @@ static int add_track_to_playlist(struct playlist_info* playlist,
|
||||||
insert_position = position;
|
insert_position = position;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
position = insert_position = 0;
|
position = insert_position = (rand() % (playlist->amount+1));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -639,11 +640,12 @@ static int add_track_to_playlist(struct playlist_info* playlist,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* update stored indices if needed */
|
/* 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++;
|
playlist->index++;
|
||||||
|
|
||||||
if (playlist->amount > 0 && insert_position <= playlist->first_index &&
|
if (playlist->amount > 0 && insert_position <= playlist->first_index &&
|
||||||
position != PLAYLIST_PREPEND)
|
position != PLAYLIST_PREPEND && playlist->started)
|
||||||
{
|
{
|
||||||
playlist->first_index++;
|
playlist->first_index++;
|
||||||
|
|
||||||
|
|
@ -2313,6 +2315,8 @@ int playlist_start(int start_index, int offset)
|
||||||
#endif
|
#endif
|
||||||
audio_play(offset);
|
audio_play(offset);
|
||||||
|
|
||||||
|
playlist->started = true;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,7 @@ struct playlist_info
|
||||||
inserted tracks? */
|
inserted tracks? */
|
||||||
bool deleted; /* have any tracks been deleted? */
|
bool deleted; /* have any tracks been deleted? */
|
||||||
int num_inserted_tracks; /* number of tracks inserted */
|
int num_inserted_tracks; /* number of tracks inserted */
|
||||||
|
bool started; /* has playlist been started? */
|
||||||
|
|
||||||
/* cache of playlist control commands waiting to be flushed to
|
/* cache of playlist control commands waiting to be flushed to
|
||||||
to disk */
|
to disk */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue