summaryrefslogtreecommitdiff
path: root/playlist.c
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2011-10-23 16:41:03 +0200
committerGravatar waker <wakeroid@gmail.com>2011-10-23 16:41:03 +0200
commitc4063208d93804d8836ed8c9fa423c6c931b724d (patch)
tree00f3d42f064a026217c4939494a3c967ac0ab14c /playlist.c
parent7c7436da5f2e7d230e379c444c77298b99ed90ac (diff)
minor optimization to shuffle albums
Diffstat (limited to 'playlist.c')
-rw-r--r--playlist.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/playlist.c b/playlist.c
index 3a2ebf45..b3d11f25 100644
--- a/playlist.c
+++ b/playlist.c
@@ -2728,12 +2728,17 @@ plt_reshuffle (playlist_t *playlist, playItem_t **ppmin, playItem_t **ppmax) {
playItem_t *pmin = NULL;
playItem_t *pmax = NULL;
playItem_t *prev = NULL;
+ const char *alb = NULL;
+ const char *art = NULL;
for (playItem_t *it = playlist->head[PL_MAIN]; it; it = it->next[PL_MAIN]) {
- if (pl_order == PLAYBACK_ORDER_SHUFFLE_ALBUMS && prev && pl_find_meta_raw (prev, "album") == pl_find_meta_raw (it, "album") && pl_find_meta_raw (prev, "artist") == pl_find_meta_raw (it, "artist")) {
+ if (pl_order == PLAYBACK_ORDER_SHUFFLE_ALBUMS && prev && alb == pl_find_meta_raw (it, "album") && art == pl_find_meta_raw (it, "artist")) {
it->shufflerating = prev->shufflerating;
}
else {
+ prev = it;
it->shufflerating = rand ();
+ alb = pl_find_meta_raw (it, "album");
+ art = pl_find_meta_raw (it, "artist");
}
if (!pmin || it->shufflerating < pmin->shufflerating) {
pmin = it;
@@ -2742,7 +2747,6 @@ plt_reshuffle (playlist_t *playlist, playItem_t **ppmin, playItem_t **ppmax) {
pmax = it;
}
it->played = 0;
- prev = it;
}
if (ppmin) {
*ppmin = pmin;