sad

simple audio daemon
git clone git://git.2f30.org/sad
Log | Files | Refs | LICENSE

commit 8d7b1f280f9d7a7fb64e8f7f83d9cf19694ad48f
parent 14aa84edc4b44aa18713157ed120f12f8d78d8cb
Author: sin <sin@2f30.org>
Date:   Mon, 29 Dec 2014 02:25:33 +0000

Add cmdrepeat and cmdrandom

Diffstat:
MPROTOCOL | 7++-----
Mcmd.c | 26++++++++++++++++++++++++++
2 files changed, 28 insertions(+), 5 deletions(-)

diff --git 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 @@ -18,6 +18,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) { int vol; @@ -365,6 +389,8 @@ cmdwait(int fd, char *arg) } static Cmd cmds[] = { + { "repeat", cmdrepeat }, + { "random", cmdrandom }, { "status", cmdstatus }, { "volume", cmdvolume }, { "next", cmdnext },