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:
11
src/queue.c
11
src/queue.c
@@ -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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user