1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
$NetBSD: patch-aa,v 1.9 2012/05/14 14:56:51 obache Exp $
SNDDSP_GETODELAY isn't defined on NetBSD-4.x.
ioctl() takes u_long argument on NetBSD.
On NetBSD<6.99.7, use third parameter in ioctl instead of varargs.
stat() system call has been versioned, use latest version when dlopen()ing.
Try more typical device names.
SOUND_PCM_* is not available on SunOS.
--- src/utils/padsp.c.orig 2009-09-18 20:21:44.000000000 +0000
+++ src/utils/padsp.c
@@ -49,6 +49,9 @@
#ifdef __linux__
#include <linux/sockios.h>
#endif
+#ifdef __NetBSD__
+#include <sys/param.h>
+#endif
#include <pulse/pulseaudio.h>
#include <pulse/gccmacro.h>
@@ -60,6 +63,10 @@
# define SIOCINQ FIONREAD
#endif
+#if !defined(SNDCTL_DSP_GETODELAY)
+# define SNDCTL_DSP_GETODELAY _IOR ('P', 23, int)
+#endif
+
/* make sure gcc doesn't redefine open and friends as macros */
#undef open
#undef open64
@@ -115,7 +122,11 @@ static pthread_mutex_t func_mutex = PTHR
static PA_LLIST_HEAD(fd_info, fd_infos) = NULL;
+#ifdef __NetBSD__
+static int (*_ioctl)(int, u_long, void *) = NULL;
+#else
static int (*_ioctl)(int, int, void*) = NULL;
+#endif
static int (*_close)(int) = NULL;
static int (*_open)(const char *, int, mode_t) = NULL;
static FILE* (*_fopen)(const char *path, const char *mode) = NULL;
@@ -141,6 +152,15 @@ static inline fnptr dlsym_fn(void *handl
return (fnptr) (long) dlsym(handle, symbol);
}
+#ifdef __NetBSD__
+#define LOAD_IOCTL_FUNC() \
+do { \
+ pthread_mutex_lock(&func_mutex); \
+ if (!_ioctl) \
+ _ioctl = (int (*)(int, u_long, void*)) dlsym_fn(RTLD_NEXT, "ioctl"); \
+ pthread_mutex_unlock(&func_mutex); \
+} while(0)
+#else
#define LOAD_IOCTL_FUNC() \
do { \
pthread_mutex_lock(&func_mutex); \
@@ -148,6 +168,7 @@ do { \
_ioctl = (int (*)(int, int, void*)) dlsym_fn(RTLD_NEXT, "ioctl"); \
pthread_mutex_unlock(&func_mutex); \
} while(0)
+#endif
#define LOAD_OPEN_FUNC() \
do { \
@@ -181,11 +202,16 @@ do { \
pthread_mutex_unlock(&func_mutex); \
} while(0)
+#ifdef __NetBSD__
+#define STAT_FUNC "__stat30"
+#else
+#define STAT_FUNC "stat"
+#endif
#define LOAD_STAT_FUNC() \
do { \
pthread_mutex_lock(&func_mutex); \
if (!_stat) \
- _stat = (int (*)(const char *, struct stat *)) dlsym_fn(RTLD_NEXT, "stat"); \
+ _stat = (int (*)(const char *, struct stat *)) dlsym_fn(RTLD_NEXT, STAT_FUNC); \
pthread_mutex_unlock(&func_mutex); \
} while(0)
@@ -1458,7 +1484,8 @@ static int real_open(const char *filenam
return _open(filename, flags, mode);
}
- if (filename && dsp_cloak_enable() && (strcmp(filename, "/dev/dsp") == 0 || strcmp(filename, "/dev/adsp") == 0))
+ if (filename && dsp_cloak_enable() && (strcmp(filename, "/dev/dsp") == 0 || strcmp(filename, "/dev/adsp") == 0 ||
+ strcmp(filename, "/dev/sound") == 0 || strcmp(filename, "/dev/audio") == 0))
r = dsp_open(flags, &_errno);
else if (filename && mixer_cloak_enable() && strcmp(filename, "/dev/mixer") == 0)
r = mixer_open(flags, &_errno);
@@ -2224,6 +2251,7 @@ static int dsp_ioctl(fd_info *i, unsigne
break;
}
+#ifndef __sun
case SOUND_PCM_READ_RATE:
debug(DEBUG_LEVEL_NORMAL, __FILE__": SOUND_PCM_READ_RATE\n");
@@ -2247,7 +2275,7 @@ static int dsp_ioctl(fd_info *i, unsigne
*(int*) argp = pa_sample_size(&i->sample_spec)*8;
pa_threaded_mainloop_unlock(i->mainloop);
break;
-
+#endif
case SNDCTL_DSP_GETOPTR: {
count_info *info;
@@ -2317,21 +2345,29 @@ fail:
return ret;
}
-#ifdef sun
+#ifdef __sun
int ioctl(int fd, int request, ...) {
+#elif defined(__NetBSD__) && (__NetBSD_Version__ < 699000700)
+int ioctl(int fd, u_long request, void *_argp) {
#else
int ioctl(int fd, unsigned long request, ...) {
#endif
fd_info *i;
+#if !(defined(__NetBSD__) && (__NetBSD_Version__ < 699000700))
va_list args;
+#endif
void *argp;
int r, _errno = 0;
debug(DEBUG_LEVEL_VERBOSE, __FILE__": ioctl()\n");
+#if defined(__NetBSD__) && (__NetBSD_Version__ < 699000700)
+ argp = _argp;
+#else
va_start(args, request);
argp = va_arg(args, void *);
va_end(args);
+#endif
if (!function_enter()) {
LOAD_IOCTL_FUNC();
@@ -2390,6 +2426,8 @@ int access(const char *pathname, int mod
if (!pathname ||
(strcmp(pathname, "/dev/dsp") != 0 &&
strcmp(pathname, "/dev/adsp") != 0 &&
+ strcmp(pathname, "/dev/sound") != 0 &&
+ strcmp(pathname, "/dev/audio") != 0 &&
strcmp(pathname, "/dev/sndstat") != 0 &&
strcmp(pathname, "/dev/mixer") != 0 )) {
LOAD_ACCESS_FUNC();
@@ -2418,6 +2456,8 @@ int stat(const char *pathname, struct st
if (!pathname ||
!buf ||
( strcmp(pathname, "/dev/dsp") != 0 &&
+ strcmp(pathname, "/dev/sound") != 0 &&
+ strcmp(pathname, "/dev/audio") != 0 &&
strcmp(pathname, "/dev/adsp") != 0 &&
strcmp(pathname, "/dev/sndstat") != 0 &&
strcmp(pathname, "/dev/mixer") != 0 )) {
@@ -2475,6 +2515,8 @@ int stat64(const char *pathname, struct
if (!pathname ||
!buf ||
( strcmp(pathname, "/dev/dsp") != 0 &&
+ strcmp(pathname, "/dev/sound") != 0 &&
+ strcmp(pathname, "/dev/audio") != 0 &&
strcmp(pathname, "/dev/adsp") != 0 &&
strcmp(pathname, "/dev/sndstat") != 0 &&
strcmp(pathname, "/dev/mixer") != 0 )) {
@@ -2520,6 +2562,8 @@ int open64(const char *filename, int fla
if (!filename ||
( strcmp(filename, "/dev/dsp") != 0 &&
+ strcmp(filename, "/dev/sound") != 0 &&
+ strcmp(filename, "/dev/audio") != 0 &&
strcmp(filename, "/dev/adsp") != 0 &&
strcmp(filename, "/dev/sndstat") != 0 &&
strcmp(filename, "/dev/mixer") != 0 )) {
@@ -2540,6 +2584,8 @@ int __xstat(int ver, const char *pathnam
if (!pathname ||
!buf ||
( strcmp(pathname, "/dev/dsp") != 0 &&
+ strcmp(pathname, "/dev/sound") != 0 &&
+ strcmp(pathname, "/dev/audio") != 0 &&
strcmp(pathname, "/dev/adsp") != 0 &&
strcmp(pathname, "/dev/sndstat") != 0 &&
strcmp(pathname, "/dev/mixer") != 0 )) {
@@ -2563,6 +2609,8 @@ int __xstat64(int ver, const char *pathn
if (!pathname ||
!buf ||
( strcmp(pathname, "/dev/dsp") != 0 &&
+ strcmp(pathname, "/dev/sound") != 0 &&
+ strcmp(pathname, "/dev/audio") != 0 &&
strcmp(pathname, "/dev/adsp") != 0 &&
strcmp(pathname, "/dev/sndstat") != 0 &&
strcmp(pathname, "/dev/mixer") != 0 )) {
@@ -2592,6 +2640,8 @@ FILE* fopen(const char *filename, const
if (!filename ||
!mode ||
( strcmp(filename, "/dev/dsp") != 0 &&
+ strcmp(filename, "/dev/sound") != 0 &&
+ strcmp(filename, "/dev/audio") != 0 &&
strcmp(filename, "/dev/adsp") != 0 &&
strcmp(filename, "/dev/sndstat") != 0 &&
strcmp(filename, "/dev/mixer") != 0 )) {
@@ -2635,6 +2685,8 @@ FILE *fopen64(const char *filename, cons
if (!filename ||
!mode ||
( strcmp(filename, "/dev/dsp") != 0 &&
+ strcmp(filename, "/dev/sound") != 0 &&
+ strcmp(filename, "/dev/audio") != 0 &&
strcmp(filename, "/dev/adsp") != 0 &&
strcmp(filename, "/dev/sndstat") != 0 &&
strcmp(filename, "/dev/mixer") != 0 )) {
|