diff options
-rw-r--r-- | apps/playlist.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/apps/playlist.c b/apps/playlist.c index 78d41ea45e..c0e943cf37 100644 --- a/apps/playlist.c +++ b/apps/playlist.c | |||
@@ -1298,9 +1298,12 @@ static int add_track_to_playlist_unlocked(struct playlist_info* playlist, | |||
1298 | } | 1298 | } |
1299 | case PLAYLIST_INSERT_LAST_SHUFFLED: | 1299 | case PLAYLIST_INSERT_LAST_SHUFFLED: |
1300 | { | 1300 | { |
1301 | int playlist_end = playlist->first_index > 0 ? | ||
1302 | playlist->first_index : playlist->amount; | ||
1303 | |||
1301 | int newpos = playlist->last_shuffled_start + | 1304 | int newpos = playlist->last_shuffled_start + |
1302 | rand() % (playlist->amount - playlist->last_shuffled_start + 1); | 1305 | rand() % (playlist_end - playlist->last_shuffled_start + 1); |
1303 | 1306 | ||
1304 | position = insert_position = newpos; | 1307 | position = insert_position = newpos; |
1305 | break; | 1308 | break; |
1306 | } | 1309 | } |
@@ -3557,13 +3560,14 @@ out: | |||
3557 | return result; | 3560 | return result; |
3558 | } | 3561 | } |
3559 | 3562 | ||
3560 | /* set playlist->last_shuffle_start to playlist->amount for | 3563 | /* set playlist->last_shuffle_start to playlist end for |
3561 | PLAYLIST_INSERT_LAST_SHUFFLED command purposes*/ | 3564 | PLAYLIST_INSERT_LAST_SHUFFLED command purposes*/ |
3562 | void playlist_set_last_shuffled_start(void) | 3565 | void playlist_set_last_shuffled_start(void) |
3563 | { | 3566 | { |
3564 | struct playlist_info* playlist = ¤t_playlist; | 3567 | struct playlist_info* playlist = ¤t_playlist; |
3565 | playlist_write_lock(playlist); | 3568 | playlist_write_lock(playlist); |
3566 | playlist->last_shuffled_start = playlist->amount; | 3569 | playlist->last_shuffled_start = playlist->first_index > 0 ? |
3570 | playlist->first_index : playlist->amount; | ||
3567 | playlist_write_unlock(playlist); | 3571 | playlist_write_unlock(playlist); |
3568 | } | 3572 | } |
3569 | 3573 | ||