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
9fe459f6
Commit
9fe459f6
authored
Feb 13, 2009
by
Romain Bignon
Committed by
Max Kellermann
Feb 13, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added the shufflerange command
This command shuffles a range of songs.
parent
beaf860a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
26 deletions
+32
-26
protocol.xml
doc/protocol.xml
+3
-0
command.c
src/command.c
+7
-2
playlist.h
src/playlist.h
+1
-1
playlist_edit.c
src/playlist_edit.c
+21
-23
No files found.
doc/protocol.xml
View file @
9fe459f6
...
...
@@ -782,11 +782,14 @@ OK
<term>
<cmdsynopsis>
<command>
shuffle
</command>
<arg><replaceable>
SONGRANGE
</replaceable></arg>
</cmdsynopsis>
</term>
<listitem>
<para>
Shuffles the current playlist.
<varname>
SONGRANGE
</varname>
is optional and specifies
a range of songs.
</para>
</listitem>
</varlistentry>
...
...
src/command.c
View file @
9fe459f6
...
...
@@ -656,7 +656,12 @@ static enum command_return
handle_shuffle
(
G_GNUC_UNUSED
struct
client
*
client
,
G_GNUC_UNUSED
int
argc
,
G_GNUC_UNUSED
char
*
argv
[])
{
shufflePlaylist
(
&
g_playlist
);
unsigned
start
=
0
,
end
=
queue_length
(
&
g_playlist
.
queue
);
if
(
argc
==
2
&&
!
check_range
(
client
,
&
start
,
&
end
,
argv
[
1
],
need_range
))
return
COMMAND_RETURN_ERROR
;
shufflePlaylist
(
&
g_playlist
,
start
,
end
);
return
COMMAND_RETURN_OK
;
}
...
...
@@ -1566,7 +1571,7 @@ static const struct command commands[] = {
{
"seek"
,
PERMISSION_CONTROL
,
2
,
2
,
handle_seek
},
{
"seekid"
,
PERMISSION_CONTROL
,
2
,
2
,
handle_seekid
},
{
"setvol"
,
PERMISSION_CONTROL
,
1
,
1
,
handle_setvol
},
{
"shuffle"
,
PERMISSION_CONTROL
,
0
,
0
,
handle_shuffle
},
{
"shuffle"
,
PERMISSION_CONTROL
,
0
,
1
,
handle_shuffle
},
{
"stats"
,
PERMISSION_READ
,
0
,
0
,
handle_stats
},
{
"status"
,
PERMISSION_READ
,
0
,
0
,
handle_status
},
#ifdef ENABLE_SQLITE
...
...
src/playlist.h
View file @
9fe459f6
...
...
@@ -151,7 +151,7 @@ void syncPlayerAndPlaylist(struct playlist *playlist);
void
previousSongInPlaylist
(
struct
playlist
*
playlist
);
void
shufflePlaylist
(
struct
playlist
*
playlist
);
void
shufflePlaylist
(
struct
playlist
*
playlist
,
unsigned
start
,
unsigned
end
);
void
deleteASongFromPlaylist
(
struct
playlist
*
playlist
,
const
struct
song
*
song
);
...
...
src/playlist_edit.c
View file @
9fe459f6
...
...
@@ -353,42 +353,40 @@ moveSongInPlaylistById(struct playlist *playlist, unsigned id1, int to)
return
moveSongInPlaylist
(
playlist
,
song
,
to
);
}
void
shufflePlaylist
(
struct
playlist
*
playlist
)
void
shufflePlaylist
(
struct
playlist
*
playlist
,
unsigned
start
,
unsigned
end
)
{
const
struct
song
*
queued
;
unsigned
i
;
if
(
queue_length
(
&
playlist
->
queue
)
<=
1
)
if
(
end
-
1
<=
start
||
end
>
queue_length
(
&
playlist
->
queue
)
)
return
;
queued
=
playlist_get_queued_song
(
playlist
);
if
(
playlist
->
playing
&&
playlist
->
current
>=
0
)
{
unsigned
current_position
;
current_position
=
queue_order_to_position
(
&
playlist
->
queue
,
playlist
->
current
);
if
(
playlist
->
playing
)
{
if
(
playlist
->
current
>=
0
)
if
(
current_position
>=
start
&&
current_position
<
end
)
{
/* put current playing song first */
queue_swap
(
&
playlist
->
queue
,
0
,
queue_order_to_position
(
&
playlist
->
queue
,
playlist
->
current
));
if
(
playlist
->
queue
.
random
)
{
playlist
->
current
=
queue_position_to_order
(
&
playlist
->
queue
,
0
);
}
else
playlist
->
current
=
0
;
/* start shuffle after the current song */
i
=
1
;
queue_swap
(
&
playlist
->
queue
,
start
,
current_position
);
if
(
playlist
->
queue
.
random
)
{
playlist
->
current
=
queue_position_to_order
(
&
playlist
->
queue
,
start
);
}
else
playlist
->
current
=
start
;
/* start shuffle after the current song */
start
++
;
}
}
else
{
/* no playback currently: shuffle everything, and
reset playlist->current */
/* no playback currently: reset playlist->current */
i
=
0
;
playlist
->
current
=
-
1
;
}
/* shuffle the rest of the list */
queue_shuffle_range
(
&
playlist
->
queue
,
i
,
queue_length
(
&
playlist
->
queue
));
queue_shuffle_range
(
&
playlist
->
queue
,
start
,
end
);
incrPlaylistVersion
(
playlist
);
...
...
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