summaryrefslogtreecommitdiff
path: root/src/command
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2017-02-20 12:44:09 +0100
committerMax Kellermann <max@musicpd.org>2017-02-25 09:24:19 +0100
commit668724de4e94c3191f0f593ba261c91d076728fc (patch)
tree165bbbcece4f38e769c5625114f572a6c102a354 /src/command
parent71ce1a25dd08a730acd51378618b73ab6174bd13 (diff)
Client: replace playlist and player_control with getter methods
Prepare to convert "partition" to a mutable pointer.
Diffstat (limited to 'src/command')
-rw-r--r--src/command/PlayerCommands.cxx36
-rw-r--r--src/command/PlaylistCommands.cxx6
-rw-r--r--src/command/QueueCommands.cxx18
-rw-r--r--src/command/TagCommands.cxx4
4 files changed, 34 insertions, 30 deletions
diff --git a/src/command/PlayerCommands.cxx b/src/command/PlayerCommands.cxx
index f87a14f12..4d0d580a7 100644
--- a/src/command/PlayerCommands.cxx
+++ b/src/command/PlayerCommands.cxx
@@ -86,18 +86,20 @@ handle_stop(Client &client, gcc_unused Request args, gcc_unused Response &r)
CommandResult
handle_currentsong(Client &client, gcc_unused Request args, Response &r)
{
- playlist_print_current(r, client.playlist);
+ playlist_print_current(r, client.GetPlaylist());
return CommandResult::OK;
}
CommandResult
handle_pause(Client &client, Request args, gcc_unused Response &r)
{
+ auto &pc = client.GetPlayerControl();
+
if (!args.IsEmpty()) {
bool pause_flag = args.ParseBool(0);
- client.player_control.LockSetPause(pause_flag);
+ pc.LockSetPause(pause_flag);
} else
- client.player_control.LockPause();
+ pc.LockPause();
return CommandResult::OK;
}
@@ -105,10 +107,12 @@ handle_pause(Client &client, Request args, gcc_unused Response &r)
CommandResult
handle_status(Client &client, gcc_unused Request args, Response &r)
{
+ auto &pc = client.GetPlayerControl();
+
const char *state = nullptr;
int song;
- const auto player_status = client.player_control.LockGetStatus();
+ const auto player_status = pc.LockGetStatus();
switch (player_status.state) {
case PlayerState::STOP:
@@ -122,7 +126,7 @@ handle_status(Client &client, gcc_unused Request args, Response &r)
break;
}
- const playlist &playlist = client.playlist;
+ const playlist &playlist = client.GetPlaylist();
r.Format("volume: %i\n"
COMMAND_STATUS_REPEAT ": %i\n"
COMMAND_STATUS_RANDOM ": %i\n"
@@ -139,16 +143,16 @@ handle_status(Client &client, gcc_unused Request args, Response &r)
playlist.GetConsume(),
(unsigned long)playlist.GetVersion(),
playlist.GetLength(),
- client.player_control.GetMixRampDb(),
+ pc.GetMixRampDb(),
state);
- if (client.player_control.GetCrossFade() > 0)
+ if (pc.GetCrossFade() > 0)
r.Format(COMMAND_STATUS_CROSSFADE ": %i\n",
- int(client.player_control.GetCrossFade() + 0.5));
+ int(pc.GetCrossFade() + 0.5));
- if (client.player_control.GetMixRampDelay() > 0)
+ if (pc.GetMixRampDelay() > 0)
r.Format(COMMAND_STATUS_MIXRAMPDELAY ": %f\n",
- client.player_control.GetMixRampDelay());
+ pc.GetMixRampDelay());
song = playlist.GetCurrentPosition();
if (song >= 0) {
@@ -189,7 +193,7 @@ handle_status(Client &client, gcc_unused Request args, Response &r)
#endif
try {
- client.player_control.LockCheckRethrowError();
+ pc.LockCheckRethrowError();
} catch (...) {
r.Format(COMMAND_STATUS_ERROR ": %s\n",
FullMessage(std::current_exception()).c_str());
@@ -207,7 +211,7 @@ handle_status(Client &client, gcc_unused Request args, Response &r)
CommandResult
handle_next(Client &client, gcc_unused Request args, gcc_unused Response &r)
{
- playlist &playlist = client.playlist;
+ playlist &playlist = client.GetPlaylist();
/* single mode is not considered when this is user who
* wants to change song. */
@@ -267,7 +271,7 @@ CommandResult
handle_clearerror(Client &client, gcc_unused Request args,
gcc_unused Response &r)
{
- client.player_control.LockClearError();
+ client.GetPlayerControl().LockClearError();
return CommandResult::OK;
}
@@ -306,7 +310,7 @@ CommandResult
handle_crossfade(Client &client, Request args, gcc_unused Response &r)
{
unsigned xfade_time = args.ParseUnsigned(0);
- client.player_control.SetCrossFade(xfade_time);
+ client.GetPlayerControl().SetCrossFade(xfade_time);
return CommandResult::OK;
}
@@ -314,7 +318,7 @@ CommandResult
handle_mixrampdb(Client &client, Request args, gcc_unused Response &r)
{
float db = args.ParseFloat(0);
- client.player_control.SetMixRampDb(db);
+ client.GetPlayerControl().SetMixRampDb(db);
return CommandResult::OK;
}
@@ -322,7 +326,7 @@ CommandResult
handle_mixrampdelay(Client &client, Request args, gcc_unused Response &r)
{
float delay_secs = args.ParseFloat(0);
- client.player_control.SetMixRampDelay(delay_secs);
+ client.GetPlayerControl().SetMixRampDelay(delay_secs);
return CommandResult::OK;
}
diff --git a/src/command/PlaylistCommands.cxx b/src/command/PlaylistCommands.cxx
index bedbe5740..0d7458d66 100644
--- a/src/command/PlaylistCommands.cxx
+++ b/src/command/PlaylistCommands.cxx
@@ -58,7 +58,7 @@ print_spl_list(Response &r, const PlaylistVector &list)
CommandResult
handle_save(Client &client, Request args, gcc_unused Response &r)
{
- spl_save_playlist(args.front(), client.playlist);
+ spl_save_playlist(args.front(), client.GetPlaylist());
return CommandResult::OK;
}
@@ -72,8 +72,8 @@ handle_load(Client &client, Request args, gcc_unused Response &r)
const SongLoader loader(client);
playlist_open_into_queue(args.front(),
range.start, range.end,
- client.playlist,
- client.player_control, loader);
+ client.GetPlaylist(),
+ client.GetPlayerControl(), loader);
return CommandResult::OK;
}
diff --git a/src/command/QueueCommands.cxx b/src/command/QueueCommands.cxx
index 07d63844c..d1beafbdf 100644
--- a/src/command/QueueCommands.cxx
+++ b/src/command/QueueCommands.cxx
@@ -164,8 +164,8 @@ handle_rangeid(Client &client, Request args, Response &r)
return CommandResult::ERROR;
}
- client.partition.playlist.SetSongIdRange(client.partition.pc,
- id, start, end);
+ client.GetPlaylist().SetSongIdRange(client.GetPlayerControl(),
+ id, start, end);
return CommandResult::OK;
}
@@ -188,7 +188,7 @@ handle_deleteid(Client &client, Request args, gcc_unused Response &r)
CommandResult
handle_playlist(Client &client, gcc_unused Request args, Response &r)
{
- playlist_print_uris(r, client.playlist);
+ playlist_print_uris(r, client.GetPlaylist());
return CommandResult::OK;
}
@@ -212,7 +212,7 @@ handle_plchanges(Client &client, Request args, Response &r)
{
uint32_t version = ParseCommandArgU32(args.front());
RangeArg range = args.ParseOptional(1, RangeArg::All());
- playlist_print_changes_info(r, client.playlist, version,
+ playlist_print_changes_info(r, client.GetPlaylist(), version,
range.start, range.end);
return CommandResult::OK;
}
@@ -222,7 +222,7 @@ handle_plchangesposid(Client &client, Request args, Response &r)
{
uint32_t version = ParseCommandArgU32(args.front());
RangeArg range = args.ParseOptional(1, RangeArg::All());
- playlist_print_changes_position(r, client.playlist, version,
+ playlist_print_changes_position(r, client.GetPlaylist(), version,
range.start, range.end);
return CommandResult::OK;
}
@@ -232,7 +232,7 @@ handle_playlistinfo(Client &client, Request args, Response &r)
{
RangeArg range = args.ParseOptional(0, RangeArg::All());
- playlist_print_info(r, client.playlist,
+ playlist_print_info(r, client.GetPlaylist(),
range.start, range.end);
return CommandResult::OK;
}
@@ -242,9 +242,9 @@ handle_playlistid(Client &client, Request args, Response &r)
{
if (!args.IsEmpty()) {
unsigned id = args.ParseUnsigned(0);
- playlist_print_id(r, client.playlist, id);
+ playlist_print_id(r, client.GetPlaylist(), id);
} else {
- playlist_print_info(r, client.playlist,
+ playlist_print_info(r, client.GetPlaylist(),
0, std::numeric_limits<unsigned>::max());
}
@@ -261,7 +261,7 @@ handle_playlist_match(Client &client, Request args, Response &r,
return CommandResult::ERROR;
}
- playlist_print_find(r, client.playlist, filter);
+ playlist_print_find(r, client.GetPlaylist(), filter);
return CommandResult::OK;
}
diff --git a/src/command/TagCommands.cxx b/src/command/TagCommands.cxx
index 9c4bab46c..5dcd3355e 100644
--- a/src/command/TagCommands.cxx
+++ b/src/command/TagCommands.cxx
@@ -40,7 +40,7 @@ handle_addtagid(Client &client, Request args, Response &r)
const char *const value = args[2];
- client.partition.playlist.AddSongIdTag(song_id, tag_type, value);
+ client.GetPlaylist().AddSongIdTag(song_id, tag_type, value);
return CommandResult::OK;
}
@@ -60,6 +60,6 @@ handle_cleartagid(Client &client, Request args, Response &r)
}
}
- client.partition.playlist.ClearSongIdTag(song_id, tag_type);
+ client.GetPlaylist().ClearSongIdTag(song_id, tag_type);
return CommandResult::OK;
}