annotate loadtools/bpunify.c @ 964:a96cb97b66a2

ringtools/imy: fix duplicate definition of tdma_durations[] The bug was reported by Vadim Yanitskiy <fixeria@osmocom.org>, although the present fix is slightly different from the contributed patch: because main.c doesn't need this tdma_durations[] array at all, let's simply remove the reference to this array from main.c rather than turn it into an extern. I no longer remember my original thought flow that resulted (by mistake) in tdma_durations[] being multiply defined in main.c and durations.c. My intent might have been to define all globals in main.c and have the reference in durations.c be an extern - and I missed that extern - but without clear memory, I have no certainty. In any case, having this data array defined in the same module that fills it (durations.c) is sensible, so let's make it the new way.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 31 Aug 2023 19:38:18 +0000
parents 850b4f066d75
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
895
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * fc-buzplay: this module implements the unified 'play' command.
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <sys/types.h>
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <ctype.h>
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <string.h>
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <strings.h>
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <stdlib.h>
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 set_bu_volume(vol)
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 unsigned vol;
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 {
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 char *targv[3], argbuf[16];
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 sprintf(argbuf, "%u", vol - 1);
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 targv[0] = "buzlev";
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 targv[1] = argbuf;
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 targv[2] = 0;
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 tpinterf_make_cmd(targv);
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 if (tpinterf_send_cmd() < 0)
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 return(-1);
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 return tpinterf_pass_output(1);
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 }
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 cmd_play(argc, argv)
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 char **argv;
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 {
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 char *filename, *tail;
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 int pwt_mode, rc;
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 unsigned global_vol;
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 filename = argv[1];
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 tail = rindex(filename, '.');
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 if (!tail) {
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 unknown: fprintf(stderr,
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 "unable to intuit format of %s, use play-bu or play-pwt\n",
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 filename);
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 return(-1);
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 }
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 if (!strcmp(tail, ".buz"))
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 pwt_mode = 0;
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 else if (!strcmp(tail, ".pwt"))
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 pwt_mode = 1;
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 else
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 goto unknown;
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 if (argv[2]) {
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 global_vol = strtoul(argv[2], 0, 0);
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 if (global_vol < 1 || global_vol > 64) {
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 fprintf(stderr,
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 "error: invalid global volume argument\n");
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 return(-1);
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 }
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 } else
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 global_vol = 64;
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 if (pwt_mode)
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 return buzplay_pwt_file(filename, global_vol);
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 else {
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 rc = set_bu_volume(global_vol);
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 if (rc)
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 return(rc);
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 return buzplay_bu_file(filename);
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 }
850b4f066d75 fc-buzplay: unified play command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 }