aboutsummaryrefslogtreecommitdiffstats
path: root/src/command/PlayerCommands.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/command/PlayerCommands.cxx')
-rw-r--r--src/command/PlayerCommands.cxx95
1 files changed, 53 insertions, 42 deletions
diff --git a/src/command/PlayerCommands.cxx b/src/command/PlayerCommands.cxx
index 12c71dfd4..cd7f42289 100644
--- a/src/command/PlayerCommands.cxx
+++ b/src/command/PlayerCommands.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2013 The Music Player Daemon Project
+ * Copyright (C) 2003-2014 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -20,18 +20,21 @@
#include "config.h"
#include "PlayerCommands.hxx"
#include "CommandError.hxx"
-#include "Playlist.hxx"
+#include "queue/Playlist.hxx"
#include "PlaylistPrint.hxx"
-#include "UpdateGlue.hxx"
-#include "Client.hxx"
-#include "Volume.hxx"
-#include "OutputAll.hxx"
+#include "client/Client.hxx"
+#include "mixer/Volume.hxx"
#include "Partition.hxx"
+#include "Instance.hxx"
#include "protocol/Result.hxx"
#include "protocol/ArgParser.hxx"
#include "AudioFormat.hxx"
#include "ReplayGainConfig.hxx"
+#ifdef ENABLE_DATABASE
+#include "db/update/Service.hxx"
+#endif
+
#define COMMAND_STATUS_STATE "state"
#define COMMAND_STATUS_REPEAT "repeat"
#define COMMAND_STATUS_SINGLE "single"
@@ -53,7 +56,7 @@
#define COMMAND_STATUS_UPDATING_DB "updating_db"
CommandResult
-handle_play(Client &client, int argc, char *argv[])
+handle_play(Client &client, unsigned argc, char *argv[])
{
int song = -1;
@@ -64,7 +67,7 @@ handle_play(Client &client, int argc, char *argv[])
}
CommandResult
-handle_playid(Client &client, int argc, char *argv[])
+handle_playid(Client &client, unsigned argc, char *argv[])
{
int id = -1;
@@ -77,7 +80,7 @@ handle_playid(Client &client, int argc, char *argv[])
CommandResult
handle_stop(Client &client,
- gcc_unused int argc, gcc_unused char *argv[])
+ gcc_unused unsigned argc, gcc_unused char *argv[])
{
client.partition.Stop();
return CommandResult::OK;
@@ -85,7 +88,7 @@ handle_stop(Client &client,
CommandResult
handle_currentsong(Client &client,
- gcc_unused int argc, gcc_unused char *argv[])
+ gcc_unused unsigned argc, gcc_unused char *argv[])
{
playlist_print_current(client, client.playlist);
return CommandResult::OK;
@@ -93,7 +96,7 @@ handle_currentsong(Client &client,
CommandResult
handle_pause(Client &client,
- int argc, char *argv[])
+ unsigned argc, char *argv[])
{
if (argc == 2) {
bool pause_flag;
@@ -109,10 +112,9 @@ handle_pause(Client &client,
CommandResult
handle_status(Client &client,
- gcc_unused int argc, gcc_unused char *argv[])
+ gcc_unused unsigned argc, gcc_unused char *argv[])
{
const char *state = nullptr;
- int updateJobId;
int song;
const auto player_status = client.player_control.GetStatus();
@@ -140,7 +142,7 @@ handle_status(Client &client,
COMMAND_STATUS_PLAYLIST_LENGTH ": %i\n"
COMMAND_STATUS_MIXRAMPDB ": %f\n"
COMMAND_STATUS_STATE ": %s\n",
- volume_level_get(),
+ volume_level_get(client.partition.outputs),
playlist.GetRepeat(),
playlist.GetRandom(),
playlist.GetSingle(),
@@ -173,9 +175,11 @@ handle_status(Client &client,
COMMAND_STATUS_TIME ": %i:%i\n"
"elapsed: %1.3f\n"
COMMAND_STATUS_BITRATE ": %u\n",
- (int)(player_status.elapsed_time + 0.5),
- (int)(player_status.total_time + 0.5),
- player_status.elapsed_time,
+ player_status.elapsed_time.RoundS(),
+ player_status.total_time.IsNegative()
+ ? 0u
+ : unsigned(player_status.total_time.RoundS()),
+ player_status.elapsed_time.ToDoubleS(),
player_status.bit_rate);
if (player_status.audio_format.IsDefined()) {
@@ -188,11 +192,17 @@ handle_status(Client &client,
}
}
- if ((updateJobId = isUpdatingDB())) {
+#ifdef ENABLE_DATABASE
+ const UpdateService *update_service = client.partition.instance.update;
+ unsigned updateJobId = update_service != nullptr
+ ? update_service->GetId()
+ : 0;
+ if (updateJobId != 0) {
client_printf(client,
COMMAND_STATUS_UPDATING_DB ": %i\n",
updateJobId);
}
+#endif
Error error = client.player_control.LockGetError();
if (error.IsDefined())
@@ -213,7 +223,7 @@ handle_status(Client &client,
CommandResult
handle_next(Client &client,
- gcc_unused int argc, gcc_unused char *argv[])
+ gcc_unused unsigned argc, gcc_unused char *argv[])
{
playlist &playlist = client.playlist;
@@ -230,14 +240,14 @@ handle_next(Client &client,
CommandResult
handle_previous(Client &client,
- gcc_unused int argc, gcc_unused char *argv[])
+ gcc_unused unsigned argc, gcc_unused char *argv[])
{
client.partition.PlayPrevious();
return CommandResult::OK;
}
CommandResult
-handle_repeat(Client &client, gcc_unused int argc, char *argv[])
+handle_repeat(Client &client, gcc_unused unsigned argc, char *argv[])
{
bool status;
if (!check_bool(client, &status, argv[1]))
@@ -248,7 +258,7 @@ handle_repeat(Client &client, gcc_unused int argc, char *argv[])
}
CommandResult
-handle_single(Client &client, gcc_unused int argc, char *argv[])
+handle_single(Client &client, gcc_unused unsigned argc, char *argv[])
{
bool status;
if (!check_bool(client, &status, argv[1]))
@@ -259,7 +269,7 @@ handle_single(Client &client, gcc_unused int argc, char *argv[])
}
CommandResult
-handle_consume(Client &client, gcc_unused int argc, char *argv[])
+handle_consume(Client &client, gcc_unused unsigned argc, char *argv[])
{
bool status;
if (!check_bool(client, &status, argv[1]))
@@ -270,33 +280,34 @@ handle_consume(Client &client, gcc_unused int argc, char *argv[])
}
CommandResult
-handle_random(Client &client, gcc_unused int argc, char *argv[])
+handle_random(Client &client, gcc_unused unsigned argc, char *argv[])
{
bool status;
if (!check_bool(client, &status, argv[1]))
return CommandResult::ERROR;
client.partition.SetRandom(status);
- audio_output_all_set_replay_gain_mode(replay_gain_get_real_mode(client.partition.GetRandom()));
+ client.partition.outputs.SetReplayGainMode(replay_gain_get_real_mode(client.partition.GetRandom()));
return CommandResult::OK;
}
CommandResult
handle_clearerror(gcc_unused Client &client,
- gcc_unused int argc, gcc_unused char *argv[])
+ gcc_unused unsigned argc, gcc_unused char *argv[])
{
client.player_control.ClearError();
return CommandResult::OK;
}
CommandResult
-handle_seek(Client &client, gcc_unused int argc, char *argv[])
+handle_seek(Client &client, gcc_unused unsigned argc, char *argv[])
{
- unsigned song, seek_time;
+ unsigned song;
+ SongTime seek_time;
if (!check_unsigned(client, &song, argv[1]))
return CommandResult::ERROR;
- if (!check_unsigned(client, &seek_time, argv[2]))
+ if (!ParseCommandArg(client, seek_time, argv[2]))
return CommandResult::ERROR;
PlaylistResult result =
@@ -305,13 +316,14 @@ handle_seek(Client &client, gcc_unused int argc, char *argv[])
}
CommandResult
-handle_seekid(Client &client, gcc_unused int argc, char *argv[])
+handle_seekid(Client &client, gcc_unused unsigned argc, char *argv[])
{
- unsigned id, seek_time;
+ unsigned id;
+ SongTime seek_time;
if (!check_unsigned(client, &id, argv[1]))
return CommandResult::ERROR;
- if (!check_unsigned(client, &seek_time, argv[2]))
+ if (!ParseCommandArg(client, seek_time, argv[2]))
return CommandResult::ERROR;
PlaylistResult result =
@@ -320,12 +332,12 @@ handle_seekid(Client &client, gcc_unused int argc, char *argv[])
}
CommandResult
-handle_seekcur(Client &client, gcc_unused int argc, char *argv[])
+handle_seekcur(Client &client, gcc_unused unsigned argc, char *argv[])
{
const char *p = argv[1];
bool relative = *p == '+' || *p == '-';
- int seek_time;
- if (!check_int(client, &seek_time, p))
+ SignedSongTime seek_time;
+ if (!ParseCommandArg(client, seek_time, p))
return CommandResult::ERROR;
PlaylistResult result =
@@ -334,7 +346,7 @@ handle_seekcur(Client &client, gcc_unused int argc, char *argv[])
}
CommandResult
-handle_crossfade(Client &client, gcc_unused int argc, char *argv[])
+handle_crossfade(Client &client, gcc_unused unsigned argc, char *argv[])
{
unsigned xfade_time;
@@ -346,7 +358,7 @@ handle_crossfade(Client &client, gcc_unused int argc, char *argv[])
}
CommandResult
-handle_mixrampdb(Client &client, gcc_unused int argc, char *argv[])
+handle_mixrampdb(Client &client, gcc_unused unsigned argc, char *argv[])
{
float db;
@@ -358,7 +370,7 @@ handle_mixrampdb(Client &client, gcc_unused int argc, char *argv[])
}
CommandResult
-handle_mixrampdelay(Client &client, gcc_unused int argc, char *argv[])
+handle_mixrampdelay(Client &client, gcc_unused unsigned argc, char *argv[])
{
float delay_secs;
@@ -371,7 +383,7 @@ handle_mixrampdelay(Client &client, gcc_unused int argc, char *argv[])
CommandResult
handle_replay_gain_mode(Client &client,
- gcc_unused int argc, char *argv[])
+ gcc_unused unsigned argc, char *argv[])
{
if (!replay_gain_set_mode_string(argv[1])) {
command_error(client, ACK_ERROR_ARG,
@@ -379,14 +391,13 @@ handle_replay_gain_mode(Client &client,
return CommandResult::ERROR;
}
- audio_output_all_set_replay_gain_mode(replay_gain_get_real_mode(client.playlist.queue.random));
-
+ client.partition.outputs.SetReplayGainMode(replay_gain_get_real_mode(client.playlist.queue.random));
return CommandResult::OK;
}
CommandResult
handle_replay_gain_status(Client &client,
- gcc_unused int argc, gcc_unused char *argv[])
+ gcc_unused unsigned argc, gcc_unused char *argv[])
{
client_printf(client, "replay_gain_mode: %s\n",
replay_gain_get_mode_string());