Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
688880bc
Commit
688880bc
authored
Jan 25, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
queue: added queue_shuffle_order_last()
This function shuffles the last song of a range. This is used by addSongToPlaylist().
parent
1a59afa3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
5 deletions
+17
-5
playlist.c
src/playlist.c
+2
-5
queue.c
src/queue.c
+7
-0
queue.h
src/queue.h
+8
-0
No files found.
src/playlist.c
View file @
688880bc
...
@@ -442,12 +442,9 @@ addSongToPlaylist(struct song *song, unsigned *added_id)
...
@@ -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
();
...
...
src/queue.c
View file @
688880bc
...
@@ -255,6 +255,13 @@ queue_shuffle_order(struct queue *queue)
...
@@ -255,6 +255,13 @@ queue_shuffle_order(struct queue *queue)
}
}
void
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
)
queue_shuffle_range
(
struct
queue
*
queue
,
unsigned
start
,
unsigned
end
)
{
{
assert
(
start
<=
end
);
assert
(
start
<=
end
);
...
...
src/queue.h
View file @
688880bc
...
@@ -320,6 +320,14 @@ void
...
@@ -320,6 +320,14 @@ 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.
*/
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment