Commit 6f595e9a authored by Max Kellermann's avatar Max Kellermann

command/queue: add optional position parameter to "add"

parent 35c4c7e8
ver 0.23.3 (not yet released) ver 0.23.3 (not yet released)
* protocol
- add optional position parameter to "add"
* output * output
- alsa: add option "stop_dsd_silence" to work around DSD DAC noise - alsa: add option "stop_dsd_silence" to work around DSD DAC noise
* macOS: fix libfmt related build failure * macOS: fix libfmt related build failure
......
...@@ -689,11 +689,14 @@ Whenever possible, ids should be used. ...@@ -689,11 +689,14 @@ Whenever possible, ids should be used.
.. _command_add: .. _command_add:
:command:`add {URI}` :command:`add {URI} [POSITION]`
Adds the file ``URI`` to the playlist Adds the file ``URI`` to the playlist
(directories add recursively). ``URI`` (directories add recursively). ``URI``
can also be a single file. can also be a single file.
The position parameter is the same as in :ref:`addid
<command_addid>`.
Clients that are connected via local socket may add arbitrary Clients that are connected via local socket may add arbitrary
local files (URI is an absolute path). Example:: local files (URI is an absolute path). Example::
......
...@@ -44,7 +44,7 @@ version_conf = configuration_data() ...@@ -44,7 +44,7 @@ version_conf = configuration_data()
version_conf.set_quoted('PACKAGE', meson.project_name()) version_conf.set_quoted('PACKAGE', meson.project_name())
version_conf.set_quoted('PACKAGE_NAME', meson.project_name()) version_conf.set_quoted('PACKAGE_NAME', meson.project_name())
version_conf.set_quoted('VERSION', meson.project_version()) version_conf.set_quoted('VERSION', meson.project_version())
version_conf.set_quoted('PROTOCOL_VERSION', '0.23.1') version_conf.set_quoted('PROTOCOL_VERSION', '0.23.3')
configure_file(output: 'Version.h', configuration: version_conf) configure_file(output: 'Version.h', configuration: version_conf)
conf = configuration_data() conf = configuration_data()
......
...@@ -85,7 +85,7 @@ handle_not_commands(Client &client, Request request, Response &response); ...@@ -85,7 +85,7 @@ handle_not_commands(Client &client, Request request, Response &response);
* This array must be sorted! * This array must be sorted!
*/ */
static constexpr struct command commands[] = { static constexpr struct command commands[] = {
{ "add", PERMISSION_ADD, 1, 1, handle_add }, { "add", PERMISSION_ADD, 1, 2, handle_add },
{ "addid", PERMISSION_ADD, 1, 2, handle_addid }, { "addid", PERMISSION_ADD, 1, 2, handle_addid },
{ "addtagid", PERMISSION_ADD, 3, 3, handle_addtagid }, { "addtagid", PERMISSION_ADD, 3, 3, handle_addtagid },
{ "albumart", PERMISSION_READ, 2, 2, handle_album_art }, { "albumart", PERMISSION_READ, 2, 2, handle_album_art },
......
...@@ -79,6 +79,11 @@ handle_add(Client &client, Request args, [[maybe_unused]] Response &r) ...@@ -79,6 +79,11 @@ handle_add(Client &client, Request args, [[maybe_unused]] Response &r)
here */ here */
uri = ""; uri = "";
const auto old_size = partition.playlist.GetLength();
const unsigned position = args.size > 1
? ParseInsertPosition(args[1], partition.playlist)
: old_size;
const auto located_uri = LocateUri(UriPluginKind::INPUT, uri, const auto located_uri = LocateUri(UriPluginKind::INPUT, uri,
&client &client
#ifdef ENABLE_DATABASE #ifdef ENABLE_DATABASE
...@@ -89,23 +94,34 @@ handle_add(Client &client, Request args, [[maybe_unused]] Response &r) ...@@ -89,23 +94,34 @@ handle_add(Client &client, Request args, [[maybe_unused]] Response &r)
case LocatedUri::Type::ABSOLUTE: case LocatedUri::Type::ABSOLUTE:
AddUri(client, located_uri); AddUri(client, located_uri);
client.GetInstance().LookupRemoteTag(located_uri.canonical_uri); client.GetInstance().LookupRemoteTag(located_uri.canonical_uri);
return CommandResult::OK; break;
case LocatedUri::Type::PATH: case LocatedUri::Type::PATH:
AddUri(client, located_uri); AddUri(client, located_uri);
return CommandResult::OK; break;
case LocatedUri::Type::RELATIVE: case LocatedUri::Type::RELATIVE:
#ifdef ENABLE_DATABASE #ifdef ENABLE_DATABASE
AddDatabaseSelection(partition, located_uri.canonical_uri); AddDatabaseSelection(partition, located_uri.canonical_uri);
return CommandResult::OK; break;
#else #else
r.Error(ACK_ERROR_NO_EXIST, "No database"); r.Error(ACK_ERROR_NO_EXIST, "No database");
return CommandResult::ERROR; return CommandResult::ERROR;
#endif #endif
} }
gcc_unreachable(); if (position < old_size) {
const unsigned new_size = partition.playlist.GetLength();
const RangeArg move_range{old_size, new_size};
try {
partition.MoveRange(move_range, position);
} catch (...) {
/* ignore - shall we handle it? */
}
}
return CommandResult::OK;
} }
CommandResult CommandResult
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment