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.
This commit is contained in:
Max Kellermann
2009-01-23 00:08:40 +01:00
parent fb2ef107d1
commit 3a1de741bb
3 changed files with 53 additions and 35 deletions

View File

@@ -242,6 +242,17 @@ queue_finish(struct queue *queue)
g_rand_free(queue->rand);
}
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)
{