[mpd] implement oneshot for single mode as noop for 0.21 protocol

Signed-off-by: Fabian Groffen <grobian@gentoo.org>
This commit is contained in:
Fabian Groffen 2024-08-05 20:36:53 +02:00 committed by ejurgensen
parent 8eae74257d
commit c0331f527e
1 changed files with 6 additions and 1 deletions

View File

@ -1214,7 +1214,8 @@ mpd_command_setvol(struct evbuffer *evbuf, int argc, char **argv, char **errmsg,
/* /*
* Command handler function for 'single' * Command handler function for 'single'
* Sets the repeat mode, expects argument argv[1] to be an integer. * Sets the repeat mode, expects argument argv[1] to be an integer or
* "oneshot" for 0.21 protocol.
* The server only allows single-mode in combination with repeat, therefore * The server only allows single-mode in combination with repeat, therefore
* the command single translates (depending on the current repeat mode) into: * the command single translates (depending on the current repeat mode) into:
* a) if repeat off: * a) if repeat off:
@ -1226,6 +1227,7 @@ mpd_command_setvol(struct evbuffer *evbuf, int argc, char **argv, char **errmsg,
* c) if repeat song: * c) if repeat song:
* 0 = repeat all * 0 = repeat all
* 1 = repeat song * 1 = repeat song
* Thus "oneshot" is accepted, but ignored under all circumstances.
*/ */
static int static int
mpd_command_single(struct evbuffer *evbuf, int argc, char **argv, char **errmsg, struct mpd_client_ctx *ctx) mpd_command_single(struct evbuffer *evbuf, int argc, char **argv, char **errmsg, struct mpd_client_ctx *ctx)
@ -1237,6 +1239,9 @@ mpd_command_single(struct evbuffer *evbuf, int argc, char **argv, char **errmsg,
ret = safe_atoi32(argv[1], &enable); ret = safe_atoi32(argv[1], &enable);
if (ret < 0) if (ret < 0)
{ {
/* 0.21 protocol: accept "oneshot" mode */
if (strcmp(argv[1], "oneshot") == 0)
return 0;
*errmsg = safe_asprintf("Argument doesn't convert to integer: '%s'", argv[1]); *errmsg = safe_asprintf("Argument doesn't convert to integer: '%s'", argv[1]);
return ACK_ERROR_ARG; return ACK_ERROR_ARG;
} }