annotate ffstools/tiaud/mkvol.c @ 407:19e5a3e2f9c0

fcup-settime: moved time() retrieval a little closer to the output A fundamental problem with all simple time transfer tools is that there is always some delay between the time retrieval on the source system and that transmitted time being set on the destination, and the resulting time on the destination system is off by that delay amount. This delay cannot be fully eliminated when working in a simple environment like ours, but we should make our best effort to minimize it. In the present case, moving the atinterf_init() call before the time() retrieval should make a teensy-tiny improvement.
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 11 Aug 2018 21:52:17 +0000
parents 1f3b28d66d53
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
241
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This program generates an audio volume file for uploading into Calypso
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * device FFS; TI's Audio Service requires every *.cfg file to be accompanied
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * by a corresponding *.vol file.
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 */
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <sys/types.h>
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <sys/file.h>
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdio.h>
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <stdlib.h>
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <unistd.h>
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 u_char bin[4];
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 write_bin_output(filename)
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 char *filename;
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 {
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 int fd;
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0666);
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 if (fd < 0) {
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 perror(filename);
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 exit(1);
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 }
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 write(fd, &bin, sizeof bin);
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 close(fd);
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 }
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 main(argc, argv)
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 char **argv;
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 {
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 if (argc != 3) {
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 fprintf(stderr, "usage: %s volume outfile\n", argv[0]);
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 exit(1);
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 }
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 bin[0] = atoi(argv[1]);
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 write_bin_output(argv[2]);
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 exit(0);
1f3b28d66d53 tiaud-mkvol program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 }