ap

An audio player suited to my tastes
Log | Files | Refs | README | LICENSE

commit 3888cc3ed6a08deaaa645f4eb12dc8fe00bd9fe2
parent 7a758649323857b21b58b7eda7aaee0830fd5769
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date:   Wed, 14 Jul 2021 17:37:41 -0700

Add status command

Diffstat:
Maps/command.c | 31+++++++++++++++++++++++++++++++
Maps/player.h | 1+
2 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/aps/command.c b/aps/command.c @@ -216,6 +216,36 @@ aps_read(struct aps *aps, int s) return end + 1; } +char * +aps_status(struct aps *aps, int s, int argc, char **argv) +{ + char *status; + + switch (aps->player.state) { + case OFF: + status = "off"; + break; + case RUNNING: + status = "running"; + break; + case STOPPED: + status = "stopped"; + break; + case SUSPENDED: + status = "suspended"; + break; + case FAILURE: + status = "failure"; + break; + default: + BUG("impossible player state"); + } + + if (respadd(aps, s, status)) + return strerror(errno); + return NULL; +} + int aps_command(struct aps *aps, int s) { @@ -240,6 +270,7 @@ aps_command(struct aps *aps, int s) { "prev", aps_prev }, { "remove", aps_remove }, { "seek", aps_seek }, + { "status", aps_status }, { "stop", aps_stop }, { "toggle", aps_toggle } }; diff --git a/aps/player.h b/aps/player.h @@ -1,4 +1,5 @@ enum pstate { + OFF = 0, /* must be false */ RUNNING = 1, STOPPED = 2, SUSPENDED = 4,