queue: added queue_shuffle_order_last()
This function shuffles the last song of a range. This is used by addSongToPlaylist().
This commit is contained in:
@@ -442,12 +442,9 @@ addSongToPlaylist(struct song *song, unsigned *added_id)
|
|||||||
start = playlist.queued + 1;
|
start = playlist.queued + 1;
|
||||||
else
|
else
|
||||||
start = playlist.current + 1;
|
start = playlist.current + 1;
|
||||||
if (start < queue_length(&playlist.queue)) {
|
if (start < queue_length(&playlist.queue))
|
||||||
unsigned swap = g_rand_int_range(g_rand, start,
|
queue_shuffle_order_last(&playlist.queue, start,
|
||||||
queue_length(&playlist.queue));
|
queue_length(&playlist.queue));
|
||||||
queue_swap_order(&playlist.queue,
|
|
||||||
queue_length(&playlist.queue) - 1, swap);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
incrPlaylistVersion();
|
incrPlaylistVersion();
|
||||||
|
@@ -254,6 +254,13 @@ queue_shuffle_order(struct queue *queue)
|
|||||||
queue->length));
|
queue->length));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
void
|
||||||
queue_shuffle_range(struct queue *queue, unsigned start, unsigned end)
|
queue_shuffle_range(struct queue *queue, unsigned start, unsigned end)
|
||||||
{
|
{
|
||||||
|
@@ -319,6 +319,14 @@ queue_restore_order(struct queue *queue)
|
|||||||
void
|
void
|
||||||
queue_shuffle_order(struct queue *queue);
|
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
|
* Shuffles a (position) range in the queue. The songs are physically
|
||||||
* shuffled, not by using the "order" mapping.
|
* shuffled, not by using the "order" mapping.
|
||||||
|
Reference in New Issue
Block a user