# HG changeset patch # User Mychaela Falconia # Date 1719261089 0 # Node ID 2742dbea95f18d5d6a069777643fd9758ef94821 # Parent 237687e2be6cd77734a3d72cd8f7c4f60bf35c61 ater: implement play command diff -r 237687e2be6c -r 2742dbea95f1 ater/Makefile --- a/ater/Makefile Mon Jun 24 20:15:42 2024 +0000 +++ b/ater/Makefile Mon Jun 24 20:31:29 2024 +0000 @@ -1,6 +1,6 @@ PROG= itt-ater-16 -OBJS= activate.o main.o out_frame.o read_file.o read_ts.o record_ctrl.o \ - subslot_rx.o tx_func.o user_cmd.o +OBJS= activate.o main.o out_frame.o play_cmd.o read_file.o read_ts.o \ + record_ctrl.o subslot_rx.o tx_func.o user_cmd.o HDRS= globals.h out_frame.h read_file.h submux.h LIBUTIL=../libutil/libutil.a diff -r 237687e2be6c -r 2742dbea95f1 ater/globals.h --- a/ater/globals.h Mon Jun 24 20:15:42 2024 +0000 +++ b/ater/globals.h Mon Jun 24 20:31:29 2024 +0000 @@ -18,3 +18,5 @@ void cmd_print_rx(int argc, char **argv); void cmd_activate(int argc, char **argv); void cmd_deact(int argc, char **argv); +void cmd_play_file(int argc, char **argv); +void cmd_play_stop(int argc, char **argv); diff -r 237687e2be6c -r 2742dbea95f1 ater/play_cmd.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ater/play_cmd.c Mon Jun 24 20:31:29 2024 +0000 @@ -0,0 +1,44 @@ +/* + * Here we implement user commands controlling file play functionality. + */ + +#include +#include +#include +#include +#include + +#include + +#include "globals.h" +#include "submux.h" +#include "read_file.h" + +void cmd_play_file(int argc, char **argv) +{ + int nr, rc; + struct ater_subslot *at; + + if (argc != 3) { +usage: fprintf(stderr, "usage: %s 0|1|2|3 play-file.tul\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: file play already in progress\n"); + return; + } + rc = read_binary_file(argv[2], at->is_efr, &at->play_buffer, + &at->play_buf_total); + if (rc < 0) + return; /* error msg already printed */ + at->play_buf_ptr = 0; + at->play_wait_align = true; +} diff -r 237687e2be6c -r 2742dbea95f1 ater/tx_func.c --- a/ater/tx_func.c Mon Jun 24 20:15:42 2024 +0000 +++ b/ater/tx_func.c Mon Jun 24 20:31:29 2024 +0000 @@ -44,6 +44,7 @@ return; free(at->play_buffer); at->play_buffer = NULL; + printf("file play finished\n"); } static void tx_service_subslot(int nr) diff -r 237687e2be6c -r 2742dbea95f1 ater/user_cmd.c --- a/ater/user_cmd.c Mon Jun 24 20:15:42 2024 +0000 +++ b/ater/user_cmd.c Mon Jun 24 20:31:29 2024 +0000 @@ -19,6 +19,7 @@ } cmdtab[] = { {"activ", cmd_activate}, {"deact", cmd_deact}, + {"play", cmd_play_file}, {"print-rx", cmd_print_rx}, {"record", cmd_record_start}, {"record-stop", cmd_record_stop},