commit 8d7b1f280f9d7a7fb64e8f7f83d9cf19694ad48f sin <sin@2f30.org> 2014-12-29 02:25:33 +0000 Add cmdrepeat and cmdrandom
PROTOCOL | 7 ++----- cmd.c | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/PROTOCOL b/PROTOCOL index 06c5652..1dab0db 100644 --- a/PROTOCOL +++ b/PROTOCOL @@ -4,16 +4,13 @@ Command reference NOTE: All commands will return some optional output followed by OK on success or ERR followed by an error message on failure. -random 0|1 +random Select random playback mode. By default the daemon is in a repeat mode where it cycles through the playlist endlessly. -repeat 0|1 +repeat Set repeat mode. Just cycle through the playlist. -single 0|1 -Set single mode. Play one song, then stop. - volume 0-100 Set the output volume. This is applied equally to all outputs. diff --git a/cmd.c b/cmd.c index 35fc626..2c696f0 100644 --- a/cmd.c +++ b/cmd.c @@ -17,6 +17,30 @@ cmdstatus(int fd, char *arg) { } +static void +cmdrepeat(int fd, char *arg) +{ + if (arg[0]) { + dprintf(fd, "ERR unexpected argument\n"); + return; + } + + playlistmode(REPEAT); + dprintf(fd, "OK\n"); +} + +static void +cmdrandom(int fd, char *arg) +{ + if (arg[0]) { + dprintf(fd, "ERR unexpected argument\n"); + return; + } + + playlistmode(RANDOM); + dprintf(fd, "OK\n"); +} + static void cmdvolume(int fd, char *arg) { @@ -365,6 +389,8 @@ cmdwait(int fd, char *arg) } static Cmd cmds[] = { + { "repeat", cmdrepeat }, + { "random", cmdrandom }, { "status", cmdstatus }, { "volume", cmdvolume }, { "next", cmdnext },