FreeCalypso > hg > freecalypso-tools
annotate loadtools/bpunify.c @ 1012:11391cb6bdc0
patch from fixeria: doc change from SE K2x0 to K2xx
Since their discovery in late 2022, Sony Ericsson K200 and K220 phones
were collectively referred to as SE K2x0 in FreeCalypso documentation.
However, now that SE K205 has been discovered as yet another member
of the same family (same PCBA in different case), it makes more sense
to refer to the whole family as SE K2xx.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 23 Sep 2024 12:23:20 +0000 |
parents | 850b4f066d75 |
children |
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 } |