From 07b4d6b6a9d79dab0c0fd0edca2d29b54f8dc2e5 Mon Sep 17 00:00:00 2001 From: chme Date: Sun, 25 Jan 2015 10:09:17 +0100 Subject: [PATCH] first song not shuffled --- src/player.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/player.c b/src/player.c index 94e95adc..4750e649 100644 --- a/src/player.c +++ b/src/player.c @@ -1069,7 +1069,10 @@ source_shuffle(struct player_source *head, struct player_source *tail) // Count items in queue (excluding head and tail) ps = head->shuffle_next; - nitems = 0; + if (!cur_streaming) + nitems = 1; + else + nitems = 0; while (ps != tail) { nitems++; @@ -1089,7 +1092,10 @@ source_shuffle(struct player_source *head, struct player_source *tail) } // Fill array with items in queue (excluding head and tail) - ps = head->shuffle_next; + if (cur_streaming) + ps = head->shuffle_next; + else + ps = head; i = 0; do { @@ -1114,10 +1120,19 @@ source_shuffle(struct player_source *head, struct player_source *tail) } // Insert shuffled items between head and tail - ps_array[0]->shuffle_prev = head; - ps_array[nitems - 1]->shuffle_next = tail; - head->shuffle_next = ps_array[0]; - tail->shuffle_prev = ps_array[nitems - 1]; + if (cur_streaming) + { + ps_array[0]->shuffle_prev = head; + ps_array[nitems - 1]->shuffle_next = tail; + head->shuffle_next = ps_array[0]; + tail->shuffle_prev = ps_array[nitems - 1]; + } + else + { + ps_array[0]->shuffle_prev = ps_array[nitems - 1]; + ps_array[nitems - 1]->shuffle_next = ps_array[0]; + shuffle_head = ps_array[0]; + } free(ps_array); @@ -1132,6 +1147,8 @@ source_reshuffle(void) if (cur_streaming) head = cur_streaming; + else if (shuffle) + head = shuffle_head; else head = source_head;