2012-08-25 12:59:54 +02:00
|
|
|
/*
|
2019-06-17 11:17:30 +02:00
|
|
|
* Copyright 2003-2019 The Music Player Daemon Project
|
2012-08-25 12:59:54 +02:00
|
|
|
* http://www.musicpd.org
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "PlayerCommands.hxx"
|
2015-08-11 22:11:28 +02:00
|
|
|
#include "Request.hxx"
|
2012-09-25 12:10:12 +02:00
|
|
|
#include "CommandError.hxx"
|
2014-02-27 17:12:42 +01:00
|
|
|
#include "queue/Playlist.hxx"
|
2012-08-29 20:17:13 +02:00
|
|
|
#include "PlaylistPrint.hxx"
|
2018-02-05 17:13:00 +01:00
|
|
|
#include "SingleMode.hxx"
|
2014-01-24 00:26:53 +01:00
|
|
|
#include "client/Client.hxx"
|
2015-08-06 22:10:25 +02:00
|
|
|
#include "client/Response.hxx"
|
2014-01-24 16:25:21 +01:00
|
|
|
#include "mixer/Volume.hxx"
|
2013-01-07 10:55:05 +01:00
|
|
|
#include "Partition.hxx"
|
2014-01-29 20:16:43 +01:00
|
|
|
#include "Instance.hxx"
|
2016-03-05 19:16:39 +01:00
|
|
|
#include "Idle.hxx"
|
2013-08-03 21:00:50 +02:00
|
|
|
#include "AudioFormat.hxx"
|
2017-01-17 22:04:31 +01:00
|
|
|
#include "util/StringBuffer.hxx"
|
2016-09-08 10:52:35 +02:00
|
|
|
#include "util/ScopeExit.hxx"
|
2016-12-29 14:28:03 +01:00
|
|
|
#include "util/Exception.hxx"
|
2012-08-25 12:59:54 +02:00
|
|
|
|
2014-01-30 20:29:48 +01:00
|
|
|
#ifdef ENABLE_DATABASE
|
|
|
|
#include "db/update/Service.hxx"
|
|
|
|
#endif
|
|
|
|
|
2018-09-22 19:08:03 +02:00
|
|
|
#include <cmath>
|
|
|
|
|
2012-08-25 12:59:54 +02:00
|
|
|
#define COMMAND_STATUS_STATE "state"
|
|
|
|
#define COMMAND_STATUS_REPEAT "repeat"
|
|
|
|
#define COMMAND_STATUS_SINGLE "single"
|
|
|
|
#define COMMAND_STATUS_CONSUME "consume"
|
|
|
|
#define COMMAND_STATUS_RANDOM "random"
|
|
|
|
#define COMMAND_STATUS_PLAYLIST "playlist"
|
|
|
|
#define COMMAND_STATUS_PLAYLIST_LENGTH "playlistlength"
|
|
|
|
#define COMMAND_STATUS_SONG "song"
|
|
|
|
#define COMMAND_STATUS_SONGID "songid"
|
|
|
|
#define COMMAND_STATUS_NEXTSONG "nextsong"
|
|
|
|
#define COMMAND_STATUS_NEXTSONGID "nextsongid"
|
|
|
|
#define COMMAND_STATUS_TIME "time"
|
|
|
|
#define COMMAND_STATUS_BITRATE "bitrate"
|
|
|
|
#define COMMAND_STATUS_ERROR "error"
|
|
|
|
#define COMMAND_STATUS_CROSSFADE "xfade"
|
|
|
|
#define COMMAND_STATUS_MIXRAMPDB "mixrampdb"
|
|
|
|
#define COMMAND_STATUS_MIXRAMPDELAY "mixrampdelay"
|
|
|
|
#define COMMAND_STATUS_AUDIO "audio"
|
|
|
|
#define COMMAND_STATUS_UPDATING_DB "updating_db"
|
|
|
|
|
2013-10-20 13:10:54 +02:00
|
|
|
CommandResult
|
2015-12-18 09:50:48 +01:00
|
|
|
handle_play(Client &client, Request args, gcc_unused Response &r)
|
2012-08-25 12:59:54 +02:00
|
|
|
{
|
2015-12-18 09:50:48 +01:00
|
|
|
int song = args.ParseOptional(0, -1);
|
2015-11-11 19:57:37 +01:00
|
|
|
|
2017-02-25 09:58:58 +01:00
|
|
|
client.GetPartition().PlayPosition(song);
|
2016-09-08 10:29:49 +02:00
|
|
|
return CommandResult::OK;
|
2012-08-25 12:59:54 +02:00
|
|
|
}
|
|
|
|
|
2013-10-20 13:10:54 +02:00
|
|
|
CommandResult
|
2015-12-18 09:50:48 +01:00
|
|
|
handle_playid(Client &client, Request args, gcc_unused Response &r)
|
2012-08-25 12:59:54 +02:00
|
|
|
{
|
2015-12-18 09:50:48 +01:00
|
|
|
int id = args.ParseOptional(0, -1);
|
2015-11-11 19:57:37 +01:00
|
|
|
|
2017-02-25 09:58:58 +01:00
|
|
|
client.GetPartition().PlayId(id);
|
2016-09-08 10:29:49 +02:00
|
|
|
return CommandResult::OK;
|
2012-08-25 12:59:54 +02:00
|
|
|
}
|
|
|
|
|
2013-10-20 13:10:54 +02:00
|
|
|
CommandResult
|
2015-08-13 12:48:31 +02:00
|
|
|
handle_stop(Client &client, gcc_unused Request args, gcc_unused Response &r)
|
2012-08-25 12:59:54 +02:00
|
|
|
{
|
2017-02-25 09:58:58 +01:00
|
|
|
client.GetPartition().Stop();
|
2013-10-20 13:10:54 +02:00
|
|
|
return CommandResult::OK;
|
2012-08-25 12:59:54 +02:00
|
|
|
}
|
|
|
|
|
2013-10-20 13:10:54 +02:00
|
|
|
CommandResult
|
2015-08-13 12:48:31 +02:00
|
|
|
handle_currentsong(Client &client, gcc_unused Request args, Response &r)
|
2012-08-25 12:59:54 +02:00
|
|
|
{
|
2017-02-20 12:44:09 +01:00
|
|
|
playlist_print_current(r, client.GetPlaylist());
|
2013-10-20 13:10:54 +02:00
|
|
|
return CommandResult::OK;
|
2012-08-25 12:59:54 +02:00
|
|
|
}
|
|
|
|
|
2013-10-20 13:10:54 +02:00
|
|
|
CommandResult
|
2015-12-18 09:50:48 +01:00
|
|
|
handle_pause(Client &client, Request args, gcc_unused Response &r)
|
2012-08-25 12:59:54 +02:00
|
|
|
{
|
2017-02-20 12:44:09 +01:00
|
|
|
auto &pc = client.GetPlayerControl();
|
|
|
|
|
2017-11-10 19:24:33 +01:00
|
|
|
if (!args.empty()) {
|
2015-12-18 09:50:48 +01:00
|
|
|
bool pause_flag = args.ParseBool(0);
|
2017-02-20 12:44:09 +01:00
|
|
|
pc.LockSetPause(pause_flag);
|
2012-08-25 12:59:54 +02:00
|
|
|
} else
|
2017-02-20 12:44:09 +01:00
|
|
|
pc.LockPause();
|
2012-08-25 12:59:54 +02:00
|
|
|
|
2013-10-20 13:10:54 +02:00
|
|
|
return CommandResult::OK;
|
2012-08-25 12:59:54 +02:00
|
|
|
}
|
|
|
|
|
2013-10-20 13:10:54 +02:00
|
|
|
CommandResult
|
2015-08-13 12:48:31 +02:00
|
|
|
handle_status(Client &client, gcc_unused Request args, Response &r)
|
2012-08-25 12:59:54 +02:00
|
|
|
{
|
2017-02-20 12:44:09 +01:00
|
|
|
auto &pc = client.GetPlayerControl();
|
|
|
|
|
2013-10-28 23:58:17 +01:00
|
|
|
const char *state = nullptr;
|
2012-08-25 12:59:54 +02:00
|
|
|
int song;
|
|
|
|
|
2017-02-20 12:44:09 +01:00
|
|
|
const auto player_status = pc.LockGetStatus();
|
2012-08-25 12:59:54 +02:00
|
|
|
|
|
|
|
switch (player_status.state) {
|
2013-09-27 22:07:20 +02:00
|
|
|
case PlayerState::STOP:
|
2012-08-25 12:59:54 +02:00
|
|
|
state = "stop";
|
|
|
|
break;
|
2013-09-27 22:07:20 +02:00
|
|
|
case PlayerState::PAUSE:
|
2012-08-25 12:59:54 +02:00
|
|
|
state = "pause";
|
|
|
|
break;
|
2013-09-27 22:07:20 +02:00
|
|
|
case PlayerState::PLAY:
|
2012-08-25 12:59:54 +02:00
|
|
|
state = "play";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-02-20 12:44:09 +01:00
|
|
|
const playlist &playlist = client.GetPlaylist();
|
2017-09-04 08:37:37 +02:00
|
|
|
|
|
|
|
const auto volume = volume_level_get(client.GetPartition().outputs);
|
|
|
|
if (volume >= 0)
|
|
|
|
r.Format("volume: %i\n", volume);
|
|
|
|
|
|
|
|
r.Format(COMMAND_STATUS_REPEAT ": %i\n"
|
2015-08-06 22:10:25 +02:00
|
|
|
COMMAND_STATUS_RANDOM ": %i\n"
|
2018-02-05 17:13:00 +01:00
|
|
|
COMMAND_STATUS_SINGLE ": %s\n"
|
2015-08-06 22:10:25 +02:00
|
|
|
COMMAND_STATUS_CONSUME ": %i\n"
|
|
|
|
COMMAND_STATUS_PLAYLIST ": %li\n"
|
|
|
|
COMMAND_STATUS_PLAYLIST_LENGTH ": %i\n"
|
|
|
|
COMMAND_STATUS_MIXRAMPDB ": %f\n"
|
|
|
|
COMMAND_STATUS_STATE ": %s\n",
|
|
|
|
playlist.GetRepeat(),
|
|
|
|
playlist.GetRandom(),
|
2018-02-05 17:13:00 +01:00
|
|
|
SingleToString(playlist.GetSingle()),
|
2015-08-06 22:10:25 +02:00
|
|
|
playlist.GetConsume(),
|
|
|
|
(unsigned long)playlist.GetVersion(),
|
|
|
|
playlist.GetLength(),
|
2017-02-20 12:44:09 +01:00
|
|
|
pc.GetMixRampDb(),
|
2015-08-06 22:10:25 +02:00
|
|
|
state);
|
2012-08-25 12:59:54 +02:00
|
|
|
|
2018-09-22 19:24:34 +02:00
|
|
|
if (pc.GetCrossFade() > FloatDuration::zero())
|
2018-09-22 19:08:03 +02:00
|
|
|
r.Format(COMMAND_STATUS_CROSSFADE ": %lu\n",
|
2018-09-22 19:24:34 +02:00
|
|
|
std::lround(pc.GetCrossFade().count()));
|
2013-10-30 17:49:47 +01:00
|
|
|
|
2018-09-22 19:24:34 +02:00
|
|
|
if (pc.GetMixRampDelay() > FloatDuration::zero())
|
2015-08-06 22:10:25 +02:00
|
|
|
r.Format(COMMAND_STATUS_MIXRAMPDELAY ": %f\n",
|
2018-09-22 19:24:34 +02:00
|
|
|
pc.GetMixRampDelay().count());
|
2013-10-30 17:49:47 +01:00
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
song = playlist.GetCurrentPosition();
|
2012-08-25 12:59:54 +02:00
|
|
|
if (song >= 0) {
|
2015-08-06 22:10:25 +02:00
|
|
|
r.Format(COMMAND_STATUS_SONG ": %i\n"
|
|
|
|
COMMAND_STATUS_SONGID ": %u\n",
|
|
|
|
song, playlist.PositionToId(song));
|
2012-08-25 12:59:54 +02:00
|
|
|
}
|
|
|
|
|
2013-09-27 22:07:20 +02:00
|
|
|
if (player_status.state != PlayerState::STOP) {
|
2015-08-06 22:10:25 +02:00
|
|
|
r.Format(COMMAND_STATUS_TIME ": %i:%i\n"
|
|
|
|
"elapsed: %1.3f\n"
|
|
|
|
COMMAND_STATUS_BITRATE ": %u\n",
|
|
|
|
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);
|
2013-04-08 22:11:42 +02:00
|
|
|
|
2014-11-25 17:46:43 +01:00
|
|
|
if (!player_status.total_time.IsNegative())
|
2015-08-06 22:10:25 +02:00
|
|
|
r.Format("duration: %1.3f\n",
|
|
|
|
player_status.total_time.ToDoubleS());
|
2014-11-25 17:46:43 +01:00
|
|
|
|
2017-01-17 22:04:31 +01:00
|
|
|
if (player_status.audio_format.IsDefined())
|
2015-08-06 22:10:25 +02:00
|
|
|
r.Format(COMMAND_STATUS_AUDIO ": %s\n",
|
2017-01-17 22:04:31 +01:00
|
|
|
ToString(player_status.audio_format).c_str());
|
2012-08-25 12:59:54 +02:00
|
|
|
}
|
|
|
|
|
2014-01-30 20:29:48 +01:00
|
|
|
#ifdef ENABLE_DATABASE
|
2017-02-25 10:00:05 +01:00
|
|
|
const UpdateService *update_service = client.GetInstance().update;
|
2014-01-29 20:16:43 +01:00
|
|
|
unsigned updateJobId = update_service != nullptr
|
|
|
|
? update_service->GetId()
|
|
|
|
: 0;
|
|
|
|
if (updateJobId != 0) {
|
2015-08-06 22:10:25 +02:00
|
|
|
r.Format(COMMAND_STATUS_UPDATING_DB ": %i\n",
|
|
|
|
updateJobId);
|
2012-08-25 12:59:54 +02:00
|
|
|
}
|
2014-01-30 20:29:48 +01:00
|
|
|
#endif
|
2012-08-25 12:59:54 +02:00
|
|
|
|
2016-09-08 10:21:34 +02:00
|
|
|
try {
|
2017-02-20 12:44:09 +01:00
|
|
|
pc.LockCheckRethrowError();
|
2016-09-08 10:21:34 +02:00
|
|
|
} catch (...) {
|
2016-12-29 14:28:03 +01:00
|
|
|
r.Format(COMMAND_STATUS_ERROR ": %s\n",
|
2017-07-05 12:25:55 +02:00
|
|
|
GetFullMessage(std::current_exception()).c_str());
|
2016-09-08 10:21:34 +02:00
|
|
|
}
|
2012-08-25 12:59:54 +02:00
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
song = playlist.GetNextPosition();
|
2015-08-06 22:10:25 +02:00
|
|
|
if (song >= 0)
|
|
|
|
r.Format(COMMAND_STATUS_NEXTSONG ": %i\n"
|
|
|
|
COMMAND_STATUS_NEXTSONGID ": %u\n",
|
|
|
|
song, playlist.PositionToId(song));
|
2012-08-25 12:59:54 +02:00
|
|
|
|
2013-10-20 13:10:54 +02:00
|
|
|
return CommandResult::OK;
|
2012-08-25 12:59:54 +02:00
|
|
|
}
|
|
|
|
|
2013-10-20 13:10:54 +02:00
|
|
|
CommandResult
|
2015-08-13 12:48:31 +02:00
|
|
|
handle_next(Client &client, gcc_unused Request args, gcc_unused Response &r)
|
2012-08-25 12:59:54 +02:00
|
|
|
{
|
2017-02-20 12:44:09 +01:00
|
|
|
playlist &playlist = client.GetPlaylist();
|
2013-01-04 23:07:11 +01:00
|
|
|
|
2012-08-25 12:59:54 +02:00
|
|
|
/* single mode is not considered when this is user who
|
|
|
|
* wants to change song. */
|
2018-02-05 17:13:00 +01:00
|
|
|
const SingleMode single = playlist.queue.single;
|
|
|
|
playlist.queue.single = SingleMode::OFF;
|
2012-08-25 12:59:54 +02:00
|
|
|
|
2016-09-08 10:52:35 +02:00
|
|
|
AtScopeExit(&playlist, single) {
|
|
|
|
playlist.queue.single = single;
|
|
|
|
};
|
2015-11-11 19:57:37 +01:00
|
|
|
|
2017-02-25 09:58:58 +01:00
|
|
|
client.GetPartition().PlayNext();
|
2016-09-08 10:29:49 +02:00
|
|
|
return CommandResult::OK;
|
2012-08-25 12:59:54 +02:00
|
|
|
}
|
|
|
|
|
2013-10-20 13:10:54 +02:00
|
|
|
CommandResult
|
2015-08-13 12:48:31 +02:00
|
|
|
handle_previous(Client &client, gcc_unused Request args,
|
|
|
|
gcc_unused Response &r)
|
2012-08-25 12:59:54 +02:00
|
|
|
{
|
2017-02-25 09:58:58 +01:00
|
|
|
client.GetPartition().PlayPrevious();
|
2016-09-08 10:29:49 +02:00
|
|
|
return CommandResult::OK;
|
2012-08-25 12:59:54 +02:00
|
|
|
}
|
|
|
|
|
2013-10-20 13:10:54 +02:00
|
|
|
CommandResult
|
2015-12-18 09:50:48 +01:00
|
|
|
handle_repeat(Client &client, Request args, gcc_unused Response &r)
|
2012-08-25 12:59:54 +02:00
|
|
|
{
|
2015-12-18 09:50:48 +01:00
|
|
|
bool status = args.ParseBool(0);
|
2017-02-25 09:58:58 +01:00
|
|
|
client.GetPartition().SetRepeat(status);
|
2013-10-20 13:10:54 +02:00
|
|
|
return CommandResult::OK;
|
2012-08-25 12:59:54 +02:00
|
|
|
}
|
|
|
|
|
2013-10-20 13:10:54 +02:00
|
|
|
CommandResult
|
2015-12-18 09:50:48 +01:00
|
|
|
handle_single(Client &client, Request args, gcc_unused Response &r)
|
2012-08-25 12:59:54 +02:00
|
|
|
{
|
2018-02-05 17:13:00 +01:00
|
|
|
auto new_mode = SingleFromString(args.front());
|
|
|
|
client.GetPartition().SetSingle(new_mode);
|
2013-10-20 13:10:54 +02:00
|
|
|
return CommandResult::OK;
|
2012-08-25 12:59:54 +02:00
|
|
|
}
|
|
|
|
|
2013-10-20 13:10:54 +02:00
|
|
|
CommandResult
|
2015-12-18 09:50:48 +01:00
|
|
|
handle_consume(Client &client, Request args, gcc_unused Response &r)
|
2012-08-25 12:59:54 +02:00
|
|
|
{
|
2015-12-18 09:50:48 +01:00
|
|
|
bool status = args.ParseBool(0);
|
2017-02-25 09:58:58 +01:00
|
|
|
client.GetPartition().SetConsume(status);
|
2013-10-20 13:10:54 +02:00
|
|
|
return CommandResult::OK;
|
2012-08-25 12:59:54 +02:00
|
|
|
}
|
|
|
|
|
2013-10-20 13:10:54 +02:00
|
|
|
CommandResult
|
2015-12-18 09:50:48 +01:00
|
|
|
handle_random(Client &client, Request args, gcc_unused Response &r)
|
2012-08-25 12:59:54 +02:00
|
|
|
{
|
2015-12-18 09:50:48 +01:00
|
|
|
bool status = args.ParseBool(0);
|
2017-02-25 09:58:58 +01:00
|
|
|
auto &partition = client.GetPartition();
|
|
|
|
partition.SetRandom(status);
|
|
|
|
partition.UpdateEffectiveReplayGainMode();
|
2013-10-20 13:10:54 +02:00
|
|
|
return CommandResult::OK;
|
2012-08-25 12:59:54 +02:00
|
|
|
}
|
|
|
|
|
2013-10-20 13:10:54 +02:00
|
|
|
CommandResult
|
2015-08-13 12:48:31 +02:00
|
|
|
handle_clearerror(Client &client, gcc_unused Request args,
|
|
|
|
gcc_unused Response &r)
|
2012-08-25 12:59:54 +02:00
|
|
|
{
|
2017-02-20 12:44:09 +01:00
|
|
|
client.GetPlayerControl().LockClearError();
|
2013-10-20 13:10:54 +02:00
|
|
|
return CommandResult::OK;
|
2012-08-25 12:59:54 +02:00
|
|
|
}
|
|
|
|
|
2013-10-20 13:10:54 +02:00
|
|
|
CommandResult
|
2016-09-08 10:29:49 +02:00
|
|
|
handle_seek(Client &client, Request args, gcc_unused Response &r)
|
2012-08-25 12:59:54 +02:00
|
|
|
{
|
2015-12-18 09:50:48 +01:00
|
|
|
unsigned song = args.ParseUnsigned(0);
|
|
|
|
SongTime seek_time = args.ParseSongTime(1);
|
2012-08-25 12:59:54 +02:00
|
|
|
|
2017-02-25 09:58:58 +01:00
|
|
|
client.GetPartition().SeekSongPosition(song, seek_time);
|
2016-09-08 10:29:49 +02:00
|
|
|
return CommandResult::OK;
|
2012-08-25 12:59:54 +02:00
|
|
|
}
|
|
|
|
|
2013-10-20 13:10:54 +02:00
|
|
|
CommandResult
|
2016-09-08 10:29:49 +02:00
|
|
|
handle_seekid(Client &client, Request args, gcc_unused Response &r)
|
2012-08-25 12:59:54 +02:00
|
|
|
{
|
2015-12-18 09:50:48 +01:00
|
|
|
unsigned id = args.ParseUnsigned(0);
|
|
|
|
SongTime seek_time = args.ParseSongTime(1);
|
2012-08-25 12:59:54 +02:00
|
|
|
|
2017-02-25 09:58:58 +01:00
|
|
|
client.GetPartition().SeekSongId(id, seek_time);
|
2016-09-08 10:29:49 +02:00
|
|
|
return CommandResult::OK;
|
2012-08-25 12:59:54 +02:00
|
|
|
}
|
|
|
|
|
2013-10-20 13:10:54 +02:00
|
|
|
CommandResult
|
2016-09-08 10:29:49 +02:00
|
|
|
handle_seekcur(Client &client, Request args, gcc_unused Response &r)
|
2012-08-25 12:59:54 +02:00
|
|
|
{
|
2014-12-06 00:08:08 +01:00
|
|
|
const char *p = args.front();
|
2012-08-25 12:59:54 +02:00
|
|
|
bool relative = *p == '+' || *p == '-';
|
2015-12-18 09:50:48 +01:00
|
|
|
SignedSongTime seek_time = ParseCommandArgSignedSongTime(p);
|
2012-08-25 12:59:54 +02:00
|
|
|
|
2017-02-25 09:58:58 +01:00
|
|
|
client.GetPartition().SeekCurrent(seek_time, relative);
|
2016-09-08 10:29:49 +02:00
|
|
|
return CommandResult::OK;
|
2012-08-25 12:59:54 +02:00
|
|
|
}
|
|
|
|
|
2013-10-20 13:10:54 +02:00
|
|
|
CommandResult
|
2015-12-18 09:50:48 +01:00
|
|
|
handle_crossfade(Client &client, Request args, gcc_unused Response &r)
|
2012-08-25 12:59:54 +02:00
|
|
|
{
|
2018-09-22 19:24:34 +02:00
|
|
|
FloatDuration duration{args.ParseUnsigned(0)};
|
|
|
|
client.GetPlayerControl().SetCrossFade(duration);
|
2013-10-20 13:10:54 +02:00
|
|
|
return CommandResult::OK;
|
2012-08-25 12:59:54 +02:00
|
|
|
}
|
|
|
|
|
2013-10-20 13:10:54 +02:00
|
|
|
CommandResult
|
2015-12-18 09:50:48 +01:00
|
|
|
handle_mixrampdb(Client &client, Request args, gcc_unused Response &r)
|
2012-08-25 12:59:54 +02:00
|
|
|
{
|
2015-12-18 09:50:48 +01:00
|
|
|
float db = args.ParseFloat(0);
|
2017-02-20 12:44:09 +01:00
|
|
|
client.GetPlayerControl().SetMixRampDb(db);
|
2013-10-20 13:10:54 +02:00
|
|
|
return CommandResult::OK;
|
2012-08-25 12:59:54 +02:00
|
|
|
}
|
|
|
|
|
2013-10-20 13:10:54 +02:00
|
|
|
CommandResult
|
2015-12-18 09:50:48 +01:00
|
|
|
handle_mixrampdelay(Client &client, Request args, gcc_unused Response &r)
|
2012-08-25 12:59:54 +02:00
|
|
|
{
|
2018-09-22 19:24:34 +02:00
|
|
|
FloatDuration delay_secs{args.ParseFloat(0)};
|
2017-02-20 12:44:09 +01:00
|
|
|
client.GetPlayerControl().SetMixRampDelay(delay_secs);
|
2013-10-20 13:10:54 +02:00
|
|
|
return CommandResult::OK;
|
2012-08-25 12:59:54 +02:00
|
|
|
}
|
|
|
|
|
2013-10-20 13:10:54 +02:00
|
|
|
CommandResult
|
2016-11-24 17:25:32 +01:00
|
|
|
handle_replay_gain_mode(Client &client, Request args, Response &)
|
2012-08-25 12:59:54 +02:00
|
|
|
{
|
2016-12-03 13:56:25 +01:00
|
|
|
auto new_mode = FromString(args.front());
|
2017-02-25 09:58:58 +01:00
|
|
|
auto &partition = client.GetPartition();
|
|
|
|
partition.SetReplayGainMode(new_mode);
|
|
|
|
partition.EmitIdle(IDLE_OPTIONS);
|
2013-10-20 13:10:54 +02:00
|
|
|
return CommandResult::OK;
|
2012-08-25 12:59:54 +02:00
|
|
|
}
|
|
|
|
|
2013-10-20 13:10:54 +02:00
|
|
|
CommandResult
|
2016-12-03 13:56:25 +01:00
|
|
|
handle_replay_gain_status(Client &client, gcc_unused Request args,
|
2015-08-13 12:48:31 +02:00
|
|
|
Response &r)
|
2012-08-25 12:59:54 +02:00
|
|
|
{
|
2016-12-03 13:56:25 +01:00
|
|
|
r.Format("replay_gain_mode: %s\n",
|
2017-02-25 09:58:58 +01:00
|
|
|
ToString(client.GetPartition().replay_gain_mode));
|
2013-10-20 13:10:54 +02:00
|
|
|
return CommandResult::OK;
|
2012-08-25 12:59:54 +02:00
|
|
|
}
|