Removed
Link Here
|
1 |
--- drivers/oss/oss_driver.c.orig 2017-01-10 10:20:51 UTC |
2 |
+++ drivers/oss/oss_driver.c |
3 |
@@ -23,6 +23,7 @@ |
4 |
|
5 |
#include <config.h> |
6 |
|
7 |
+#define __BSD_VISIBLE 1 |
8 |
#ifdef USE_BARRIER |
9 |
/* |
10 |
* POSIX conformance level should be globally defined somewhere, possibly |
11 |
@@ -172,7 +173,9 @@ static void set_period_size (oss_driver_ |
12 |
((double)driver->period_size / |
13 |
(double)driver->sample_rate) * 1e6; |
14 |
driver->last_wait_ust = 0; |
15 |
- driver->last_periodtime = driver->engine->get_microseconds (); |
16 |
+ driver->last_periodtime = driver->engine ? |
17 |
+ driver->engine->get_microseconds() : |
18 |
+ jack_get_microseconds(); |
19 |
driver->next_periodtime = 0; |
20 |
driver->iodelay = 0.0F; |
21 |
} |
22 |
@@ -180,7 +183,9 @@ static void set_period_size (oss_driver_ |
23 |
|
24 |
static inline void update_times (oss_driver_t *driver) |
25 |
{ |
26 |
- driver->last_periodtime = driver->engine->get_microseconds (); |
27 |
+ driver->last_periodtime = driver->engine ? |
28 |
+ driver->engine->get_microseconds() : |
29 |
+ jack_get_microseconds(); |
30 |
if (driver->next_periodtime > 0) { |
31 |
driver->iodelay = (float) |
32 |
((long double)driver->last_periodtime - |
33 |
@@ -211,6 +216,7 @@ static void copy_and_convert_in (jack_sa |
34 |
int dstidx; |
35 |
signed short *s16src = (signed short*)src; |
36 |
signed int *s32src = (signed int*)src; |
37 |
+ unsigned char *s24src = (unsigned char *) src; |
38 |
double *f64src = (double*)src; |
39 |
jack_sample_t scale; |
40 |
|
41 |
@@ -225,10 +231,13 @@ static void copy_and_convert_in (jack_sa |
42 |
} |
43 |
break; |
44 |
case 24: |
45 |
- scale = 1.0f / 0x7fffff; |
46 |
+ scale = 1.0f / 0x7fffffff; |
47 |
for (dstidx = 0; dstidx < nframes; dstidx++) { |
48 |
dst[dstidx] = (jack_sample_t) |
49 |
- s32src[srcidx] * scale; |
50 |
+ ((signed int)( |
51 |
+ (s24src[3 * srcidx + 2] << 24) | |
52 |
+ (s24src[3 * srcidx + 1] << 16) | |
53 |
+ (s24src[3 * srcidx + 0] << 8))) * scale; |
54 |
srcidx += chcount; |
55 |
} |
56 |
break; |
57 |
@@ -256,6 +265,7 @@ static void copy_and_convert_out (void * |
58 |
int srcidx; |
59 |
int dstidx; |
60 |
signed short *s16dst = (signed short*)dst; |
61 |
+ unsigned char *s24dst = (unsigned char *) dst; |
62 |
signed int *s32dst = (signed int*)dst; |
63 |
double *f64dst = (double*)dst; |
64 |
jack_sample_t scale; |
65 |
@@ -273,12 +283,15 @@ static void copy_and_convert_out (void * |
66 |
} |
67 |
break; |
68 |
case 24: |
69 |
- scale = 0x7fffff; |
70 |
+ scale = 0x7fffffff; |
71 |
for (srcidx = 0; srcidx < nframes; srcidx++) { |
72 |
- s32dst[dstidx] = (signed int) |
73 |
- (src[srcidx] >= 0.0f) ? |
74 |
- (src[srcidx] * scale + 0.5f) : |
75 |
- (src[srcidx] * scale - 0.5f); |
76 |
+ signed int sample = |
77 |
+ (src[srcidx] >= 0.0f) ? |
78 |
+ (src[srcidx] * scale + 0.5f) : |
79 |
+ (src[srcidx] * scale - 0.5f) ; |
80 |
+ s24dst[3*dstidx + 2] = sample >> 24; |
81 |
+ s24dst[3*dstidx + 1] = sample >> 16; |
82 |
+ s24dst[3*dstidx + 0] = sample >> 8; |
83 |
dstidx += chcount; |
84 |
} |
85 |
break; |
86 |
@@ -429,7 +442,11 @@ static int oss_driver_detach (oss_driver |
87 |
|
88 |
static int oss_driver_start (oss_driver_t *driver) |
89 |
{ |
90 |
- int flags = 0; |
91 |
+#if defined(OPTION_COOKEDMODE) |
92 |
+ int cookedmode = 1; |
93 |
+#else |
94 |
+ int cookedmode = 0; |
95 |
+#endif |
96 |
int format; |
97 |
int channels; |
98 |
int samplerate; |
99 |
@@ -441,19 +458,7 @@ static int oss_driver_start (oss_driver_ |
100 |
const char *indev = driver->indev; |
101 |
const char *outdev = driver->outdev; |
102 |
|
103 |
- switch (driver->bits) { |
104 |
- case 24: |
105 |
- case 32: |
106 |
- samplesize = sizeof(int); |
107 |
- break; |
108 |
- case 64: |
109 |
- samplesize = sizeof(double); |
110 |
- break; |
111 |
- case 16: |
112 |
- default: |
113 |
- samplesize = sizeof(short); |
114 |
- break; |
115 |
- } |
116 |
+ samplesize = driver->bits / 8; |
117 |
driver->trigger = 0; |
118 |
if (strcmp (indev, outdev) != 0) { |
119 |
if (driver->capture_channels > 0) { |
120 |
@@ -464,7 +469,7 @@ static int oss_driver_start (oss_driver_ |
121 |
indev, __FILE__, __LINE__, errno); |
122 |
} |
123 |
#ifndef OSS_NO_COOKED_MODE |
124 |
- ioctl (infd, SNDCTL_DSP_COOKEDMODE, &flags); |
125 |
+ ioctl (infd, SNDCTL_DSP_COOKEDMODE, &cookedmode); |
126 |
#endif |
127 |
fragsize = driver->period_size * |
128 |
driver->capture_channels * samplesize; |
129 |
@@ -479,7 +484,7 @@ static int oss_driver_start (oss_driver_ |
130 |
outdev, __FILE__, __LINE__, errno); |
131 |
} |
132 |
#ifndef OSS_NO_COOKED_MODE |
133 |
- ioctl (outfd, SNDCTL_DSP_COOKEDMODE, &flags); |
134 |
+ ioctl (outfd, SNDCTL_DSP_COOKEDMODE, &cookedmode); |
135 |
#endif |
136 |
fragsize = driver->period_size * |
137 |
driver->playback_channels * samplesize; |
138 |
@@ -497,7 +502,7 @@ static int oss_driver_start (oss_driver_ |
139 |
return -1; |
140 |
} |
141 |
#ifndef OSS_NO_COOKED_MODE |
142 |
- ioctl (infd, SNDCTL_DSP_COOKEDMODE, &flags); |
143 |
+ ioctl (infd, SNDCTL_DSP_COOKEDMODE, &cookedmode); |
144 |
#endif |
145 |
} else if (driver->capture_channels == 0 && |
146 |
driver->playback_channels != 0) { |
147 |
@@ -510,7 +515,7 @@ static int oss_driver_start (oss_driver_ |
148 |
return -1; |
149 |
} |
150 |
#ifndef OSS_NO_COOKED_MODE |
151 |
- ioctl (outfd, SNDCTL_DSP_COOKEDMODE, &flags); |
152 |
+ ioctl (outfd, SNDCTL_DSP_COOKEDMODE, &cookedmode); |
153 |
#endif |
154 |
} else { |
155 |
infd = outfd = open (indev, O_RDWR | O_EXCL); |
156 |
@@ -521,7 +526,7 @@ static int oss_driver_start (oss_driver_ |
157 |
return -1; |
158 |
} |
159 |
#ifndef OSS_NO_COOKED_MODE |
160 |
- ioctl (infd, SNDCTL_DSP_COOKEDMODE, &flags); |
161 |
+ ioctl (infd, SNDCTL_DSP_COOKEDMODE, &cookedmode); |
162 |
#endif |
163 |
} |
164 |
if (infd >= 0 && outfd >= 0) { |
165 |
@@ -705,7 +710,9 @@ static int oss_driver_start (oss_driver_ |
166 |
sem_post (&driver->sem_start); |
167 |
} |
168 |
|
169 |
- driver->last_periodtime = driver->engine->get_microseconds (); |
170 |
+ driver->last_periodtime = driver->engine ? |
171 |
+ driver->engine->get_microseconds() : |
172 |
+ jack_get_microseconds(); |
173 |
driver->next_periodtime = 0; |
174 |
driver->iodelay = 0.0F; |
175 |
|
176 |
@@ -1143,6 +1150,23 @@ jack_driver_t * driver_initialize (jack_ |
177 |
pnode = jack_slist_next (pnode); |
178 |
} |
179 |
|
180 |
+ switch (bits) |
181 |
+ { |
182 |
+ case 16: /* native-endian 16-bit integer */ |
183 |
+ driver->format = AFMT_S16_NE; |
184 |
+ break; |
185 |
+ case 24: /* little-endian 24-bit integer */ |
186 |
+ driver->format = AFMT_S24_LE; |
187 |
+ break; |
188 |
+ case 32: /* native-endian 32-bit integer */ |
189 |
+ driver->format = AFMT_S32_NE; |
190 |
+ break; |
191 |
+ default: |
192 |
+ free(driver); |
193 |
+ jack_error("OSS: invalid number of bits: %d", |
194 |
+ __FILE__, __LINE__, bits); |
195 |
+ return NULL; |
196 |
+ } |
197 |
driver->sample_rate = sample_rate; |
198 |
driver->period_size = period_size; |
199 |
driver->nperiods = nperiods; |
200 |
@@ -1163,58 +1187,6 @@ jack_driver_t * driver_initialize (jack_ |
201 |
} |
202 |
driver->infd = -1; |
203 |
driver->outfd = -1; |
204 |
- switch (driver->bits) { |
205 |
-# ifndef OSS_ENDIAN |
206 |
-# ifdef __GNUC__ |
207 |
-# if (defined(__i386__) || defined(__alpha__) || defined(__arm__) || defined(__x86_64__) || (defined(__sh__) && !defined(__LITTLE_ENDIAN__))) |
208 |
-# define OSS_LITTLE_ENDIAN 1234 |
209 |
-# define OSS_ENDIAN OSS_LITTLE_ENDIAN |
210 |
-# else |
211 |
-# define OSS_BIG_ENDIAN 4321 |
212 |
-# define OSS_ENDIAN OSS_BIG_ENDIAN |
213 |
-# endif |
214 |
-# else /* __GNUC__ */ |
215 |
-# if (defined(_AIX) || defined(AIX) || defined(sparc) || defined(__hppa) || defined(PPC) || defined(__powerpc__) && !defined(i386) && !defined(__i386) && !defined(__i386__)) |
216 |
-# define OSS_BIG_ENDIAN 4321 |
217 |
-# define OSS_ENDIAN OSS_BIG_ENDIAN |
218 |
-# else |
219 |
-# define OSS_LITTLE_ENDIAN 1234 |
220 |
-# define OSS_ENDIAN OSS_LITTLE_ENDIAN |
221 |
-# endif |
222 |
-# endif /* __GNUC__ */ |
223 |
-# endif /* OSS_ENDIAN */ |
224 |
-# if (OSS_ENDIAN == 1234) |
225 |
- /* little-endian architectures */ |
226 |
- case 24: /* little-endian LSB aligned 24-bits in 32-bits integer */ |
227 |
- driver->format = 0x00008000; |
228 |
- break; |
229 |
- case 32: /* little-endian 32-bit integer */ |
230 |
- driver->format = 0x00001000; |
231 |
- break; |
232 |
- case 64: /* native-endian 64-bit float */ |
233 |
- driver->format = 0x00004000; |
234 |
- break; |
235 |
- case 16: /* little-endian 16-bit integer */ |
236 |
- default: |
237 |
- driver->format = 0x00000010; |
238 |
- break; |
239 |
- /* big-endian architectures */ |
240 |
-# else |
241 |
- case 24: /* big-endian LSB aligned 24-bits in 32-bits integer */ |
242 |
- break; |
243 |
- driver->format = 0x00010000; |
244 |
- case 32: /* big-endian 32-bit integer */ |
245 |
- driver->format = 0x00002000; |
246 |
- break; |
247 |
- case 64: /* native-endian 64-bit float */ |
248 |
- driver->format = 0x00004000; |
249 |
- break; |
250 |
- case 16: /* big-endian 16-bit integer */ |
251 |
- default: |
252 |
- driver->format = 0x00000020; |
253 |
-# endif |
254 |
- } |
255 |
- |
256 |
driver->indevbuf = driver->outdevbuf = NULL; |
257 |
|
258 |
driver->capture_ports = NULL; |