From 58a5d30826a1196948cff89135e9ac3c2a3e5333 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 11 Feb 2009 18:02:50 +0100 Subject: [PATCH] playlist: don't preserve "current" song after "random" toggle When MPD is not playing, it may still remember which is the "current" song. When you switch to "random" mode, MPD will always start playing exactly this song. This defies the goal of "random" mode a little. Clear the "current" song when MPD is not playing during the "random" mode switch. --- src/playlist.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/playlist.c b/src/playlist.c index 4bdc0b4a8..138a92d01 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -300,7 +300,8 @@ void setPlaylistRandomStatus(struct playlist *playlist, bool status) /* shuffle the queue order, but preserve playlist->current */ - int current_position = playlist->current >= 0 + int current_position = + playlist->playing && playlist->current >= 0 ? (int)queue_order_to_position(&playlist->queue, playlist->current) : -1; @@ -316,7 +317,8 @@ void setPlaylistRandomStatus(struct playlist *playlist, bool status) current_position); queue_swap_order(&playlist->queue, 0, current_order); playlist->current = 0; - } + } else + playlist->current = -1; } else orderPlaylist(playlist);