Index: apps/playlist.c =================================================================== --- apps/playlist.c (revision 19591) +++ apps/playlist.c (working copy) @@ -674,8 +674,8 @@ * PLAYLIST_INSERT_LAST - Add track to end of playlist * PLAYLIST_INSERT_SHUFFLED - Add track at some random point between the * current playing track and end of playlist - * PLAYLIST_REPLACE - Erase current playlist, Cue the current track - * and inster this track at the end. + * PLAYLIST_REPLACE - Erase current playlist, cue the current track + * and insert this track at the end. */ static int add_track_to_playlist(struct playlist_info* playlist, const char *filename, int position, @@ -1079,7 +1079,8 @@ /* * returns the index of the track that is "steps" away from current playing - * track. + * track. "steps" can be positive (search forward), negative (search backward) + * or zero (get the current item). */ static int get_next_index(const struct playlist_info* playlist, int steps, int repeat_mode) @@ -1093,15 +1094,18 @@ if (repeat_mode == -1) repeat_mode = global_settings.repeat_mode; - if (repeat_mode == REPEAT_SHUFFLE && playlist->amount <= 1) - repeat_mode = REPEAT_ALL; + if (global_settings.playlist_shuffle && repeat_mode == REPEAT_ALL) { + if (playlist->amount == 1) + repeat_mode = REPEAT_ALL; + else + /* Treat repeat shuffle just like repeat off. At end of playlist, + play will be resumed in playlist_next() */ + repeat_mode = REPEAT_OFF; + } steps = calculate_step_count(playlist, steps); switch (repeat_mode) { - case REPEAT_SHUFFLE: - /* Treat repeat shuffle just like repeat off. At end of playlist, - play will be resumed in playlist_next() */ case REPEAT_OFF: { current_index = rotate_index(playlist, current_index); @@ -2437,8 +2441,11 @@ int index = get_next_index(playlist, steps, -1); - if (index < 0 && steps >= 0 && global_settings.repeat_mode == REPEAT_SHUFFLE) - index = get_next_index(playlist, steps, REPEAT_ALL); + if (index < 0 + && global_settings.playlist_shuffle + && global_settings.repeat_mode == REPEAT_ALL + && steps <= playlist->amount) + return 1; return (index >= 0); } @@ -2498,25 +2505,23 @@ struct playlist_info* playlist = ¤t_playlist; int index; - if ( (steps > 0) -#ifdef AB_REPEAT_ENABLE - && (global_settings.repeat_mode != REPEAT_AB) -#endif - && (global_settings.repeat_mode != REPEAT_ONE) ) - { - int i, j; + if ((steps > 0) + || (global_settings.repeat_mode == REPEAT_OFF) + || (global_settings.repeat_mode == REPEAT_ALL)) { + int i, n; - /* We need to delete all the queued songs */ - for (i=0, j=steps; iindices[index] & PLAYLIST_QUEUE_MASK) - { - remove_track_from_playlist(playlist, index, true); - steps--; /* one less track */ + /* Remove all queued items between the current one + and the one 'steps' steps away */ + for (i = 0, n = 0; i < steps; i++) { + int idx = get_next_index(playlist, i, -1); + if (playlist->indices[idx] & PLAYLIST_QUEUE_MASK) { + remove_track_from_playlist(playlist, idx, true); + n++; } } + + /* We removed n items on the playlist */ + steps -= n; } index = get_next_index(playlist, steps, -1); @@ -2524,8 +2529,9 @@ if (index < 0) { /* end of playlist... or is it */ - if (global_settings.repeat_mode == REPEAT_SHUFFLE && - playlist->amount > 1) + if (global_settings.playlist_shuffle + && global_settings.repeat_mode == REPEAT_ALL + && playlist->amount > 1) { /* Repeat shuffle mode. Re-shuffle playlist and resume play */ playlist->first_index = 0; Index: apps/playlist.h =================================================================== --- apps/playlist.h (revision 19591) +++ apps/playlist.h (working copy) @@ -89,7 +89,7 @@ int buffer_end_pos; /* last position where buffer was written */ int index; /* index of current playing track */ int first_index; /* index of first song in playlist */ - int amount; /* number of tracks in the index */ + int amount; /* number of tracks in the playlist */ int last_insert_pos; /* last position we inserted a track */ int seed; /* shuffle seed */ bool shuffle_modified; /* has playlist been shuffled with Index: apps/settings.h =================================================================== --- apps/settings.h (revision 19591) +++ apps/settings.h (working copy) @@ -129,7 +129,6 @@ REPEAT_OFF, REPEAT_ALL, REPEAT_ONE, - REPEAT_SHUFFLE, #ifdef AB_REPEAT_ENABLE REPEAT_AB, #endif Index: apps/playlist_viewer.c =================================================================== --- apps/playlist_viewer.c (revision 19591) +++ apps/playlist_viewer.c (working copy) @@ -463,7 +463,7 @@ audio_stop(); else { - /* Start playing new track except if it's the lasttrack + /* Start playing new track except if it's the last track in the playlist and repeat mode is disabled */ current_track = playlist_buffer_get_track(&viewer.buffer, index); Index: apps/settings_list.c =================================================================== --- apps/settings_list.c (revision 19591) +++ apps/settings_list.c (working copy) @@ -482,18 +482,17 @@ SYSTEM_SETTING(NVRAM(4), resume_index, -1), SYSTEM_SETTING(NVRAM(4), resume_offset, -1), CHOICE_SETTING(0, repeat_mode, LANG_REPEAT, REPEAT_OFF, "repeat", - "off,all,one,shuffle" + "off,all,one" #ifdef AB_REPEAT_ENABLE ",ab" #endif , NULL, #ifdef AB_REPEAT_ENABLE - 5, -#else 4, +#else + 3, #endif - ID2P(LANG_OFF), ID2P(LANG_ALL), ID2P(LANG_REPEAT_ONE), - ID2P(LANG_SHUFFLE) + ID2P(LANG_OFF), ID2P(LANG_ALL), ID2P(LANG_REPEAT_ONE) #ifdef AB_REPEAT_ENABLE ,ID2P(LANG_REPEAT_AB) #endif