ap

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

commit 75e7d1d81f814895bf1623eb3d9072c967c0fbf7
parent 298cfaa8b0af6cb052885fda03c65cc91d96aeec
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date:   Thu, 26 Aug 2021 13:46:56 -0700

Add truncate command

The truncate command is very useful for filtering the queue and,
while it's trivial to get similar results using existing commands,
I want apc to remain ignorant of commands.

Diffstat:
Maps/command.c | 8++++++++
Maps/command.h | 1+
Maps/main.c | 3++-
3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/aps/command.c b/aps/command.c @@ -264,3 +264,11 @@ aps_player(struct aps *aps, int s, int argc, char **argv) return NULL; } +char * +aps_truncate(struct aps *aps, int fd, int argc, char **argv) +{ + while (aps->queue) + queue_remove(aps, aps->queue); + return aps_add(aps, fd, argc, argv); +} + diff --git a/aps/command.h b/aps/command.h @@ -17,3 +17,4 @@ char *aps_previous(struct aps *, int, int, char **); char *aps_status(struct aps *, int, int, char **); char *aps_loglevel(struct aps *, int, int, char **); char *aps_player(struct aps *, int, int, char **); +char *aps_truncate(struct aps *, int, int, char **); diff --git a/aps/main.c b/aps/main.c @@ -49,7 +49,8 @@ static struct command commands[] = { { "seek", aps_seek }, { "status", aps_status }, { "stop", aps_stop }, - { "toggle", aps_toggle } + { "toggle", aps_toggle }, + { "truncate", aps_truncate } }; void