comparison ater/play_cmd.c @ 27:2742dbea95f1

ater: implement play command
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 24 Jun 2024 20:31:29 +0000
parents
children 1dda11905e85
comparison
equal deleted inserted replaced
26:237687e2be6c 27:2742dbea95f1
1 /*
2 * Here we implement user commands controlling file play functionality.
3 */
4
5 #include <stdint.h>
6 #include <stdbool.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <string.h>
10
11 #include <osmocom/core/select.h>
12
13 #include "globals.h"
14 #include "submux.h"
15 #include "read_file.h"
16
17 void cmd_play_file(int argc, char **argv)
18 {
19 int nr, rc;
20 struct ater_subslot *at;
21
22 if (argc != 3) {
23 usage: fprintf(stderr, "usage: %s 0|1|2|3 play-file.tul\n", argv[0]);
24 return;
25 }
26 if (argv[1][0] < '0' || argv[1][0] > '3' || argv[1][1])
27 goto usage;
28 nr = argv[1][0] - '0';
29 at = &subslots[nr];
30 if (!at->is_active) {
31 fprintf(stderr, "error: subslot %d is not active\n", nr);
32 return;
33 }
34 if (at->play_buffer) {
35 fprintf(stderr, "error: file play already in progress\n");
36 return;
37 }
38 rc = read_binary_file(argv[2], at->is_efr, &at->play_buffer,
39 &at->play_buf_total);
40 if (rc < 0)
41 return; /* error msg already printed */
42 at->play_buf_ptr = 0;
43 at->play_wait_align = true;
44 }