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
627d590c
Commit
627d590c
authored
Jan 24, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
command: use queue_print_*()
Replaced several wrapper functions from playlist.c, and make command.c use the queue print functions directly.
parent
d449d6ab
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
82 deletions
+51
-82
command.c
src/command.c
+43
-15
playlist.c
src/playlist.c
+0
-48
playlist.h
src/playlist.h
+0
-19
queue_print.h
src/queue_print.h
+8
-0
No files found.
src/command.c
View file @
627d590c
...
...
@@ -20,6 +20,7 @@
#include "player_control.h"
#include "playlist.h"
#include "playlist_print.h"
#include "queue_print.h"
#include "ls.h"
#include "directory.h"
#include "directory_print.h"
...
...
@@ -419,13 +420,12 @@ handle_currentsong(struct client *client,
G_GNUC_UNUSED
int
argc
,
G_GNUC_UNUSED
char
*
argv
[])
{
int
song
=
getPlaylistCurrentSong
();
enum
playlist_result
result
;
const
struct
queue
*
queue
=
playlist_get_queue
()
;
if
(
song
<
0
)
return
COMMAND_RETURN_OK
;
if
(
song
>=
0
)
queue_print_info
(
client
,
queue
,
song
,
song
+
1
)
;
result
=
playlistInfo
(
client
,
song
,
song
+
1
);
return
print_playlist_result
(
client
,
result
);
return
PLAYLIST_RESULT_SUCCESS
;
}
static
enum
command_return
...
...
@@ -639,7 +639,9 @@ static enum command_return
handle_playlist
(
struct
client
*
client
,
G_GNUC_UNUSED
int
argc
,
G_GNUC_UNUSED
char
*
argv
[])
{
showPlaylist
(
client
);
const
struct
queue
*
queue
=
playlist_get_queue
();
queue_print_uris
(
client
,
queue
,
0
,
queue_length
(
queue
));
return
COMMAND_RETURN_OK
;
}
...
...
@@ -757,47 +759,73 @@ static enum command_return
handle_plchanges
(
struct
client
*
client
,
G_GNUC_UNUSED
int
argc
,
char
*
argv
[])
{
uint32_t
version
;
const
struct
queue
*
queue
=
playlist_get_queue
();
if
(
!
check_uint32
(
client
,
&
version
,
argv
[
1
],
need_positive
))
return
COMMAND_RETURN_ERROR
;
return
playlistChanges
(
client
,
version
);
queue_print_changes_info
(
client
,
queue
,
version
);
return
COMMAND_RETURN_OK
;
}
static
enum
command_return
handle_plchangesposid
(
struct
client
*
client
,
G_GNUC_UNUSED
int
argc
,
char
*
argv
[])
{
uint32_t
version
;
const
struct
queue
*
queue
=
playlist_get_queue
();
if
(
!
check_uint32
(
client
,
&
version
,
argv
[
1
],
need_positive
))
return
COMMAND_RETURN_ERROR
;
return
playlistChangesPosId
(
client
,
version
);
queue_print_changes_position
(
client
,
queue
,
version
);
return
COMMAND_RETURN_OK
;
}
static
enum
command_return
handle_playlistinfo
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
{
unsigned
start
=
0
,
end
=
UINT_MAX
;
enum
playlist_result
result
;
const
struct
queue
*
queue
=
playlist_get_queue
()
;
if
(
argc
==
2
&&
!
check_range
(
client
,
&
start
,
&
end
,
argv
[
1
],
need_range
))
return
COMMAND_RETURN_ERROR
;
result
=
playlistInfo
(
client
,
start
,
end
);
return
print_playlist_result
(
client
,
result
);
if
(
end
>
queue_length
(
queue
))
end
=
queue_length
(
queue
);
if
(
start
>
end
)
return
print_playlist_result
(
client
,
PLAYLIST_RESULT_BAD_RANGE
);
queue_print_info
(
client
,
queue
,
start
,
end
);
return
COMMAND_RETURN_OK
;
}
static
enum
command_return
handle_playlistid
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
{
int
id
=
-
1
;
enum
playlist_result
result
;
int
id
=
-
1
,
start
;
unsigned
end
;
const
struct
queue
*
queue
=
playlist_get_queue
();
if
(
argc
==
2
&&
!
check_int
(
client
,
&
id
,
argv
[
1
],
need_positive
))
return
COMMAND_RETURN_ERROR
;
result
=
playlistId
(
client
,
id
);
return
print_playlist_result
(
client
,
result
);
if
(
id
>=
0
)
{
start
=
queue_id_to_position
(
queue
,
id
);
if
(
start
<
0
)
return
print_playlist_result
(
client
,
PLAYLIST_RESULT_NO_SUCH_SONG
);
end
=
start
+
1
;
}
else
{
start
=
0
;
end
=
queue_length
(
queue
);
}
queue_print_info
(
client
,
queue
,
start
,
end
);
return
COMMAND_RETURN_OK
;
}
static
enum
command_return
...
...
src/playlist.c
View file @
627d590c
...
...
@@ -157,12 +157,6 @@ void clearPlaylist(void)
incrPlaylistVersion
();
}
void
showPlaylist
(
struct
client
*
client
)
{
queue_print_uris
(
client
,
&
playlist
.
queue
,
0
,
queue_length
(
&
playlist
.
queue
));
}
void
savePlaylistState
(
FILE
*
fp
)
{
fprintf
(
fp
,
"%s"
,
PLAYLIST_STATE_FILE_STATE
);
...
...
@@ -288,48 +282,6 @@ void readPlaylistState(FILE *fp)
setPlaylistRandomStatus
(
random_mode
);
}
int
playlistChanges
(
struct
client
*
client
,
uint32_t
version
)
{
queue_print_changes_info
(
client
,
&
playlist
.
queue
,
version
);
return
0
;
}
int
playlistChangesPosId
(
struct
client
*
client
,
uint32_t
version
)
{
queue_print_changes_position
(
client
,
&
playlist
.
queue
,
version
);
return
0
;
}
enum
playlist_result
playlistInfo
(
struct
client
*
client
,
unsigned
start
,
unsigned
end
)
{
if
(
end
>
queue_length
(
&
playlist
.
queue
))
end
=
queue_length
(
&
playlist
.
queue
);
if
(
start
>
end
)
return
PLAYLIST_RESULT_BAD_RANGE
;
queue_print_info
(
client
,
&
playlist
.
queue
,
start
,
end
);
return
PLAYLIST_RESULT_SUCCESS
;
}
enum
playlist_result
playlistId
(
struct
client
*
client
,
int
id
)
{
int
begin
=
0
;
unsigned
end
=
queue_length
(
&
playlist
.
queue
);
if
(
id
>=
0
)
{
begin
=
queue_id_to_position
(
&
playlist
.
queue
,
id
);
if
(
begin
<
0
)
return
PLAYLIST_RESULT_NO_SUCH_SONG
;
end
=
begin
+
1
;
}
queue_print_info
(
client
,
&
playlist
.
queue
,
begin
,
end
);
return
PLAYLIST_RESULT_SUCCESS
;
}
/**
* Queue a song, addressed by its order number.
*/
...
...
src/playlist.h
View file @
627d590c
...
...
@@ -120,25 +120,10 @@ enum playlist_result addToPlaylist(const char *file, unsigned *added_id);
enum
playlist_result
addSongToPlaylist
(
struct
song
*
song
,
unsigned
*
added_id
);
void
showPlaylist
(
struct
client
*
client
);
enum
playlist_result
deleteFromPlaylist
(
unsigned
song
);
enum
playlist_result
deleteFromPlaylistById
(
unsigned
song
);
/**
* Send detailed information about a range of songs in the playlist to
* a client.
*
* @param client the client which has requested information
* @param start the index of the first song (including)
* @param end the index of the last song (excluding)
*/
enum
playlist_result
playlistInfo
(
struct
client
*
client
,
unsigned
start
,
unsigned
end
);
enum
playlist_result
playlistId
(
struct
client
*
client
,
int
song
);
void
stopPlaylist
(
void
);
enum
playlist_result
playPlaylist
(
int
song
);
...
...
@@ -190,10 +175,6 @@ enum playlist_result seekSongInPlaylistById(unsigned id, float seek_time);
void
playlistVersionChange
(
void
);
int
playlistChanges
(
struct
client
*
client
,
uint32_t
version
);
int
playlistChangesPosId
(
struct
client
*
client
,
uint32_t
version
);
void
searchForSongsInPlaylist
(
struct
client
*
client
,
unsigned
numItems
,
const
LocateTagItem
*
items
);
...
...
src/queue_print.h
View file @
627d590c
...
...
@@ -33,6 +33,14 @@ void
queue_print_song_info
(
struct
client
*
client
,
const
struct
queue
*
queue
,
unsigned
position
);
/**
* Send detailed information about a range of songs in the queue to a
* client.
*
* @param client the client which has requested information
* @param start the index of the first song (including)
* @param end the index of the last song (excluding)
*/
void
queue_print_info
(
struct
client
*
client
,
const
struct
queue
*
queue
,
unsigned
start
,
unsigned
end
);
...
...
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