changeset 29:1dda11905e85

ater: implement play-stop command
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 24 Jun 2024 20:42:23 +0000
parents fa341317c844
children 5dd30224b70a
files ater/play_cmd.c ater/user_cmd.c
diffstat 2 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ater/play_cmd.c	Mon Jun 24 20:38:58 2024 +0000
+++ b/ater/play_cmd.c	Mon Jun 24 20:42:23 2024 +0000
@@ -42,3 +42,28 @@
 	at->play_buf_ptr = 0;
 	at->play_wait_align = true;
 }
+
+void cmd_play_stop(int argc, char **argv)
+{
+	int nr;
+	struct ater_subslot *at;
+
+	if (argc != 2) {
+usage:		fprintf(stderr, "usage: %s 0|1|2|3\n", argv[0]);
+		return;
+	}
+	if (argv[1][0] < '0' || argv[1][0] > '3' || argv[1][1])
+		goto usage;
+	nr = argv[1][0] - '0';
+	at = &subslots[nr];
+	if (!at->is_active) {
+		fprintf(stderr, "error: subslot %d is not active\n", nr);
+		return;
+	}
+	if (!at->play_buffer) {
+		fprintf(stderr, "error: no file play in progress\n");
+		return;
+	}
+	free(at->play_buffer);
+	at->play_buffer = NULL;
+}
--- a/ater/user_cmd.c	Mon Jun 24 20:38:58 2024 +0000
+++ b/ater/user_cmd.c	Mon Jun 24 20:42:23 2024 +0000
@@ -20,6 +20,7 @@
 	{"activ", cmd_activate},
 	{"deact", cmd_deact},
 	{"play", cmd_play_file},
+	{"play-stop", cmd_play_stop},
 	{"print-rx", cmd_print_rx},
 	{"record", cmd_record_start},
 	{"record-stop", cmd_record_stop},