View | Details | Raw Unified | Return to bug 199558 | Differences between
and this patch

Collapse All | Expand All

(-)files/patch-drivers-oss-oss_driver.c (-5 / +169 lines)
Lines 1-5 Link Here
1
--- drivers/oss/oss_driver.c.orig
1
--- drivers/oss/oss_driver.c.orig	2013-10-04 02:45:25.000000000 +0200
2
+++ drivers/oss/oss_driver.c
2
+++ drivers/oss/oss_driver.c	2015-04-20 12:52:08.350806000 +0200
3
@@ -23,6 +23,7 @@
3
@@ -23,6 +23,7 @@
4
 
4
 
5
 #include <config.h>
5
 #include <config.h>
Lines 8-14 Link Here
8
 #ifdef USE_BARRIER
8
 #ifdef USE_BARRIER
9
 /*
9
 /*
10
  * POSIX conformance level should be globally defined somewhere, possibly
10
  * POSIX conformance level should be globally defined somewhere, possibly
11
@@ -181,7 +182,9 @@ static void set_period_size (oss_driver_
11
@@ -183,7 +184,9 @@
12
 		((double) driver->period_size /
12
 		((double) driver->period_size /
13
 		(double) driver->sample_rate) * 1e6;
13
 		(double) driver->sample_rate) * 1e6;
14
 	driver->last_wait_ust = 0;
14
 	driver->last_wait_ust = 0;
Lines 19-25 Link Here
19
 	driver->next_periodtime = 0;
19
 	driver->next_periodtime = 0;
20
 	driver->iodelay = 0.0F;
20
 	driver->iodelay = 0.0F;
21
 }
21
 }
22
@@ -189,7 +192,9 @@ static void set_period_size (oss_driver_
22
@@ -191,7 +194,9 @@
23
 
23
 
24
 static inline void update_times (oss_driver_t *driver)
24
 static inline void update_times (oss_driver_t *driver)
25
 {
25
 {
Lines 30-36 Link Here
30
 	if (driver->next_periodtime > 0)
30
 	if (driver->next_periodtime > 0)
31
 	{
31
 	{
32
 		driver->iodelay = (float)
32
 		driver->iodelay = (float)
33
@@ -759,7 +764,9 @@ static int oss_driver_start (oss_driver_
33
@@ -224,6 +229,7 @@
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
@@ -240,11 +246,14 @@
42
 			}
43
 			break;
44
 		case 24:
45
-			scale = 1.0f / 0x7fffff;
46
+			scale = 1.0f / 0x7fffffff;
47
 			for (dstidx = 0; dstidx < nframes; dstidx++)
48
 			{
49
 				dst[dstidx] = (jack_sample_t)
50
-					s32src[srcidx] * scale;
51
+				    ((signed int)(
52
+				    (s24src[3 * srcidx + 2] << 24) |
53
+				    (s24src[3 * srcidx + 1] << 16) |
54
+				    (s24src[3 * srcidx + 0] << 8))) * scale;
55
 				srcidx += chcount;
56
 			}
57
 			break;
58
@@ -274,6 +283,7 @@
59
 	int srcidx;
60
 	int dstidx;
61
 	signed short *s16dst = (signed short *) dst;
62
+	unsigned char *s24dst = (unsigned char *) dst;
63
 	signed int *s32dst = (signed int *) dst;
64
 	double *f64dst = (double *) dst;
65
 	jack_sample_t scale;
66
@@ -293,13 +303,17 @@
67
 			}
68
 			break;
69
 		case 24:
70
-			scale = 0x7fffff;
71
+			scale = 0x7fffffff;
72
 			for (srcidx = 0; srcidx < nframes; srcidx++)
73
 			{
74
-				s32dst[dstidx] = (signed int)
75
-					(src[srcidx] >= 0.0f) ?
76
-					(src[srcidx] * scale + 0.5f) :
77
-					(src[srcidx] * scale - 0.5f);
78
+				signed int sample =
79
+				    (src[srcidx] >= 0.0f) ?
80
+				    (src[srcidx] * scale + 0.5f) :
81
+				    (src[srcidx] * scale - 0.5f) ;
82
+
83
+				s24dst[3*dstidx + 2] = sample >> 24;
84
+				s24dst[3*dstidx + 1] = sample >> 16;
85
+				s24dst[3*dstidx + 0] = sample >> 8;
86
 				dstidx += chcount;
87
 			}
88
 			break;
89
@@ -471,20 +485,7 @@
90
 	const char *indev = driver->indev;
91
 	const char *outdev = driver->outdev;
92
 
93
-	switch (driver->bits)
94
-	{
95
-		case 24:
96
-		case 32:
97
-			samplesize = sizeof(int);
98
-			break;
99
-		case 64:
100
-			samplesize = sizeof(double);
101
-			break;
102
-		case 16:
103
-		default:
104
-			samplesize = sizeof(short);
105
-			break;
106
-	}
107
+	samplesize = driver->bits / 8;
108
 	driver->trigger = 0;
109
 	if (strcmp(indev, outdev) != 0)
110
 	{
111
@@ -762,7 +763,9 @@
34
 	if (driver->threads & 1) sem_post(&driver->sem_start);
112
 	if (driver->threads & 1) sem_post(&driver->sem_start);
35
 	if (driver->threads & 2) sem_post(&driver->sem_start);
113
 	if (driver->threads & 2) sem_post(&driver->sem_start);
36
 
114
 
Lines 41-43 Link Here
41
 	driver->next_periodtime = 0;
119
 	driver->next_periodtime = 0;
42
 	driver->iodelay = 0.0F;
120
 	driver->iodelay = 0.0F;
43
 
121
 
122
@@ -1235,7 +1238,24 @@
123
 		}
124
 		pnode = jack_slist_next(pnode);
125
 	}
126
-	
127
+
128
+	switch (bits)
129
+	{
130
+	case 16:	/* native-endian 16-bit integer */
131
+		driver->format = AFMT_S16_NE;
132
+		break;
133
+	case 24:	/* little-endian 24-bit integer */
134
+		driver->format = AFMT_S24_LE;
135
+		break;
136
+	case 32:	/* native-endian 32-bit integer */
137
+		driver->format = AFMT_S32_NE;
138
+		break;
139
+	default:
140
+		free(driver);
141
+		jack_error("OSS: invalid number of bits: %d",
142
+			__FILE__, __LINE__, bits);
143
+		return NULL;
144
+	}
145
 	driver->sample_rate = sample_rate;
146
 	driver->period_size = period_size;
147
 	driver->nperiods = nperiods;
148
@@ -1254,59 +1274,6 @@
149
 		driver->outdev = strdup(OSS_DRIVER_DEF_DEV);
150
 	driver->infd = -1;
151
 	driver->outfd = -1;
152
-	switch (driver->bits)
153
-	{
154
-#		ifndef OSS_ENDIAN
155
-#		ifdef __GNUC__
156
-#		if (defined(__i386__) || defined(__alpha__) || defined(__arm__) || defined(__x86_64__) || (defined(__sh__) && !defined(__LITTLE_ENDIAN__)))
157
-#		define OSS_LITTLE_ENDIAN 1234
158
-#		define OSS_ENDIAN OSS_LITTLE_ENDIAN
159
-#		else
160
-#		define OSS_BIG_ENDIAN 4321
161
-#		define OSS_ENDIAN OSS_BIG_ENDIAN
162
-#		endif
163
-#		else /* __GNUC__ */
164
-#		if (defined(_AIX) || defined(AIX) || defined(sparc) || defined(__hppa) || defined(PPC) || defined(__powerpc__) && !defined(i386) && !defined(__i386) && !defined(__i386__))
165
-#		define OSS_BIG_ENDIAN 4321
166
-#		define OSS_ENDIAN OSS_BIG_ENDIAN
167
-#		else
168
-#		define OSS_LITTLE_ENDIAN 1234
169
-#		define OSS_ENDIAN OSS_LITTLE_ENDIAN
170
-#		endif
171
-#		endif /* __GNUC__ */
172
-#		endif /* OSS_ENDIAN */
173
-#		if (OSS_ENDIAN == 1234)
174
-		/* little-endian architectures */
175
-		case 24:	/* little-endian LSB aligned 24-bits in 32-bits  integer */
176
-			driver->format = 0x00008000;
177
-			break;
178
-		case 32:	/* little-endian 32-bit integer */
179
-			driver->format = 0x00001000;
180
-			break;
181
-		case 64:	/* native-endian 64-bit float */
182
-			driver->format = 0x00004000;
183
-			break;
184
-		case 16:	/* little-endian 16-bit integer */
185
-		default:
186
-			driver->format = 0x00000010;
187
-			break;
188
-		/* big-endian architectures */
189
-#		else
190
-		case 24:	/* big-endian LSB aligned 24-bits in 32-bits integer */
191
-			break;
192
-			driver->format = 0x00010000;
193
-		case 32:	/* big-endian 32-bit integer */
194
-			driver->format = 0x00002000;
195
-			break;
196
-		case 64:	/* native-endian 64-bit float */
197
-			driver->format = 0x00004000;
198
-			break;
199
-		case 16:	/* big-endian 16-bit integer */
200
-		default:
201
-			driver->format = 0x00000020;
202
-#		endif
203
-	}
204
-
205
 	driver->indevbuf = driver->outdevbuf = NULL;
206
 
207
 	driver->capture_ports = NULL;

Return to bug 199558