# HG changeset patch # User Mychaela Falconia # Date 1719261743 0 # Node ID 1dda11905e85e828cf7ab0e0a4cc843fa59166e6 # Parent fa341317c8443875e578c878c684f858b269b78f ater: implement play-stop command diff -r fa341317c844 -r 1dda11905e85 ater/play_cmd.c --- 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; +} diff -r fa341317c844 -r 1dda11905e85 ater/user_cmd.c --- 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},