aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/playlist.c9
-rw-r--r--src/queue.c7
-rw-r--r--src/queue.h8
3 files changed, 18 insertions, 6 deletions
diff --git a/src/playlist.c b/src/playlist.c
index 2eecc3bea..6578713db 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -442,12 +442,9 @@ addSongToPlaylist(struct song *song, unsigned *added_id)
start = playlist.queued + 1;
else
start = playlist.current + 1;
- if (start < queue_length(&playlist.queue)) {
- unsigned swap = g_rand_int_range(g_rand, start,
- queue_length(&playlist.queue));
- queue_swap_order(&playlist.queue,
- queue_length(&playlist.queue) - 1, swap);
- }
+ if (start < queue_length(&playlist.queue))
+ queue_shuffle_order_last(&playlist.queue, start,
+ queue_length(&playlist.queue));
}
incrPlaylistVersion();
diff --git a/src/queue.c b/src/queue.c
index 983c5e43c..73adb2f49 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -255,6 +255,13 @@ queue_shuffle_order(struct queue *queue)
}
void
+queue_shuffle_order_last(struct queue *queue, unsigned start, unsigned end)
+{
+ queue_swap_order(queue, end - 1,
+ g_rand_int_range(queue->rand, start, end));
+}
+
+void
queue_shuffle_range(struct queue *queue, unsigned start, unsigned end)
{
assert(start <= end);
diff --git a/src/queue.h b/src/queue.h
index b355a6a3e..b43e9c1dd 100644
--- a/src/queue.h
+++ b/src/queue.h
@@ -320,6 +320,14 @@ void
queue_shuffle_order(struct queue *queue);
/**
+ * Shuffles the virtual order of the last song in the specified
+ * (order) range. This is used in random mode after a song has been
+ * appended by queue_append().
+ */
+void
+queue_shuffle_order_last(struct queue *queue, unsigned start, unsigned end);
+
+/**
* Shuffles a (position) range in the queue. The songs are physically
* shuffled, not by using the "order" mapping.
*/