diff options
author | Max Kellermann <max@duempel.org> | 2009-01-23 00:08:40 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-01-23 00:08:40 +0100 |
commit | 3a1de741bbb8cf412a72d53793d205a139c101ac (patch) | |
tree | 434675ff438787592d7f9abe14496bf0dcbb1906 /src/queue.c | |
parent | fb2ef107d1b43d5ba34918059113ec68293d379e (diff) | |
download | mpd-3a1de741bbb8cf412a72d53793d205a139c101ac.tar.gz mpd-3a1de741bbb8cf412a72d53793d205a139c101ac.tar.xz mpd-3a1de741bbb8cf412a72d53793d205a139c101ac.zip |
queue: added queue_shuffle_order()
The function shuffles the virtual order of songs, but does not move
them physically. This is used in random mode.
The new function replaces playlist.c's randomizeOrder() function,
which was aware of playlist.current and playlist.queued. The latter
is always -1 anyway, and the former as preserved by the caller, by
converting playlist.current to a position, and then back to an order
number.
Diffstat (limited to '')
-rw-r--r-- | src/queue.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/queue.c b/src/queue.c index e7ecb3d3a..30ecafeaa 100644 --- a/src/queue.c +++ b/src/queue.c @@ -243,6 +243,17 @@ queue_finish(struct queue *queue) } void +queue_shuffle_order(struct queue *queue) +{ + assert(queue->random); + + for (unsigned i = 0; i < queue->length; i++) + queue_swap_order(queue, i, + g_rand_int_range(queue->rand, i, + queue->length)); +} + +void queue_shuffle_range(struct queue *queue, unsigned start, unsigned end) { assert(start <= end); |