Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports-kde
Path: blob/main/comms/chu/files/patch-chu.c
16462 views
1
--- chu.c.orig 1999-03-17 16:42:18 UTC
2
+++ chu.c
3
@@ -20,15 +20,21 @@
4
#include <stdlib.h>
5
#include <string.h>
6
#include <math.h>
7
+#include <errno.h>
8
+#include <sys/types.h>
9
#include <sys/time.h>
10
#include <sys/resource.h>
11
#include <unistd.h>
12
13
-#define USE_TIMEX
14
+#define ADJTIME
15
+#undef USE_TIMEX
16
+#define USE_ADJTIME
17
+
18
+#ifdef ADJTIME
19
#ifdef USE_TIMEX
20
#include <sys/timex.h>
21
#endif
22
-
23
+#endif
24
#define SAMPLE_RATE 8000
25
#define SAMPLES 512
26
#define OVERLAP 50
27
@@ -389,6 +395,21 @@ void saveAdjTime()
28
}
29
}
30
31
+#ifdef USE_ADJTIME
32
+void
33
+do_adjtime(int microsec)
34
+{
35
+ struct timeval delta;
36
+ int status;
37
+
38
+ printf("do_adjtime adjustment: %d\n", microsec);
39
+ delta.tv_sec = 0;
40
+ delta.tv_usec = microsec;
41
+ status = adjtime(&delta, NULL);
42
+ printf("do_adjtime status: %d\n", status);
43
+}
44
+#endif
45
+
46
#ifdef USE_TIMEX
47
void timex_adjustment(int microsec)
48
{
49
@@ -462,7 +483,8 @@ double gettimexoffset()
50
adjtimex(&t);
51
offset = t.offset;
52
#endif
53
-
54
+#ifdef USE_ADJTIME
55
+#endif
56
return (double) offset;
57
}
58
59
@@ -655,13 +677,18 @@ void adj_time(double d)
60
tv.tv_usec += 1000000;
61
}
62
63
+#ifdef ADJTIME
64
#ifdef USE_TIMEX
65
if (fabs(d) < ((double)MAXPHASE))
66
{
67
timex_adjustment((int)-d);
68
}
69
+#else
70
+ if (fabs(d) < ((double)1000000))
71
+ do_adjtime((int)-d);
72
else
73
#endif
74
+#endif
75
{
76
printf("standard adjustment ");
77
78
@@ -1267,7 +1294,7 @@ char *parseArgs(int argc, char **argv)
79
return fname;
80
}
81
82
-void main(int argc, char **argv)
83
+int main(int argc, char **argv)
84
{
85
FILE *fp;
86
signed char buf[8192];
87
@@ -1278,7 +1305,7 @@ void main(int argc, char **argv)
88
89
fname = parseArgs(argc, argv);
90
if (fname == NULL)
91
- return;
92
+ return 0;
93
94
/* Set priority to maximum -- just long enough for us
95
to open the audio device and timestamp it. This should
96
@@ -1293,7 +1320,7 @@ void main(int argc, char **argv)
97
if (fp == NULL)
98
{
99
printf("fopen(): Unable to open file: %s %s\n", fname, strerror(errno));
100
- return;
101
+ return 0;
102
}
103
104
gettimeofday(&starttime, &tz);
105
106