annotate pcm/user_cmd.c @ 10:5cf7818a7d08

pcm: implement play command
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 23 Jun 2024 19:45:52 +0000
parents e3d16d490ce2
children e149ca1dd14f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5
7233c10af3ad pcm: hook in stdin select mechanism
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
7233c10af3ad pcm: hook in stdin select mechanism
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * In this module we handle user-issued stdin commands during
7233c10af3ad pcm: hook in stdin select mechanism
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * itt-pcm-one running session.
7233c10af3ad pcm: hook in stdin select mechanism
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
7233c10af3ad pcm: hook in stdin select mechanism
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
7233c10af3ad pcm: hook in stdin select mechanism
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdint.h>
7233c10af3ad pcm: hook in stdin select mechanism
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdbool.h>
7233c10af3ad pcm: hook in stdin select mechanism
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdio.h>
7233c10af3ad pcm: hook in stdin select mechanism
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdlib.h>
7233c10af3ad pcm: hook in stdin select mechanism
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <string.h>
7233c10af3ad pcm: hook in stdin select mechanism
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
7233c10af3ad pcm: hook in stdin select mechanism
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include <osmocom/core/select.h>
7233c10af3ad pcm: hook in stdin select mechanism
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
7233c10af3ad pcm: hook in stdin select mechanism
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 #include "globals.h"
7233c10af3ad pcm: hook in stdin select mechanism
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
6
631f2db08538 pcm: implement print-rx and record commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 5
diff changeset
16 static struct cmdtab {
631f2db08538 pcm: implement print-rx and record commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 5
diff changeset
17 char *cmd;
631f2db08538 pcm: implement print-rx and record commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 5
diff changeset
18 void (*func)(int argc, char **argv);
631f2db08538 pcm: implement print-rx and record commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 5
diff changeset
19 } cmdtab[] = {
9
e3d16d490ce2 pcm: implement dmw-on and dmw-off commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 8
diff changeset
20 {"dmw-on", cmd_dmw_on},
e3d16d490ce2 pcm: implement dmw-on and dmw-off commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 8
diff changeset
21 {"dmw-off", cmd_dmw_off},
8
70aa8cbdbde9 pcm: implement pcm-fill command
Mychaela Falconia <falcon@freecalypso.org>
parents: 6
diff changeset
22 {"pcm-fill", cmd_pcm_fill},
10
5cf7818a7d08 pcm: implement play command
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
23 {"play", cmd_play_file},
6
631f2db08538 pcm: implement print-rx and record commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 5
diff changeset
24 {"print-rx", cmd_print_rx},
631f2db08538 pcm: implement print-rx and record commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 5
diff changeset
25 {"record", cmd_record_start},
631f2db08538 pcm: implement print-rx and record commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 5
diff changeset
26 {"record-stop", cmd_record_stop},
631f2db08538 pcm: implement print-rx and record commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 5
diff changeset
27 /* table search terminator */
631f2db08538 pcm: implement print-rx and record commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 5
diff changeset
28 {NULL, NULL}
631f2db08538 pcm: implement print-rx and record commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 5
diff changeset
29 };
631f2db08538 pcm: implement print-rx and record commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 5
diff changeset
30
5
7233c10af3ad pcm: hook in stdin select mechanism
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 void handle_user_cmd(int argc, char **argv)
7233c10af3ad pcm: hook in stdin select mechanism
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 {
6
631f2db08538 pcm: implement print-rx and record commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 5
diff changeset
33 struct cmdtab *tp;
631f2db08538 pcm: implement print-rx and record commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 5
diff changeset
34
631f2db08538 pcm: implement print-rx and record commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 5
diff changeset
35 for (tp = cmdtab; tp->cmd; tp++)
631f2db08538 pcm: implement print-rx and record commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 5
diff changeset
36 if (!strcmp(tp->cmd, argv[0]))
631f2db08538 pcm: implement print-rx and record commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 5
diff changeset
37 break;
631f2db08538 pcm: implement print-rx and record commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 5
diff changeset
38 if (!tp->func) {
631f2db08538 pcm: implement print-rx and record commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 5
diff changeset
39 printf("error: unknown or unimplemented command\n");
631f2db08538 pcm: implement print-rx and record commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 5
diff changeset
40 return;
631f2db08538 pcm: implement print-rx and record commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 5
diff changeset
41 }
631f2db08538 pcm: implement print-rx and record commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 5
diff changeset
42 tp->func(argc, argv);
5
7233c10af3ad pcm: hook in stdin select mechanism
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 }