summaryrefslogtreecommitdiff
path: root/audio/arts/patches/patch-ab
blob: b213df8a127f7e0feadb89a437b77a00c8506bb7 (plain)
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
$NetBSD: patch-ab,v 1.2 2002/07/17 07:54:04 skrll Exp $

--- artsc/artsdsp.c.orig	Mon Jun 24 17:55:50 2002
+++ artsc/artsdsp.c
@@ -127,6 +127,9 @@
 
 static void artsdsp_doinit()
 {
+#if defined(__NetBSD__)
+	void *handle;
+#endif
 	const char *env;
 	artsdsp_init = 1;
 
@@ -139,6 +142,18 @@
 	mmapemu = env && !strcmp(env,"1");
 
 	/* resolve original symbols */
+#if defined(__NetBSD__)
+	handle = dlopen(NULL, DL_LAZY);
+	orig_open = (orig_open_ptr)dlsym(handle,"open");
+	orig_close = (orig_close_ptr)dlsym(handle,"close");
+	orig_write = (orig_write_ptr)dlsym(handle,"write");
+	orig_ioctl = (orig_ioctl_ptr)dlsym(handle,"_oss_ioctl");
+	orig_mmap = (orig_mmap_ptr)dlsym(handle,"mmap");
+	orig_munmap = (orig_munmap_ptr)dlsym(handle,"munmap");
+	orig_fopen = (orig_fopen_ptr)dlsym(handle,"fopen");
+	orig_access = (orig_access_ptr)dlsym(handle,"access");
+	(void) dlclose(handle);
+#else
 	orig_open = (orig_open_ptr)dlsym(RTLD_NEXT,"open");
 	orig_close = (orig_close_ptr)dlsym(RTLD_NEXT,"close");
 	orig_write = (orig_write_ptr)dlsym(RTLD_NEXT,"write");
@@ -147,6 +162,7 @@
 	orig_munmap = (orig_munmap_ptr)dlsym(RTLD_NEXT,"munmap");
 	orig_fopen = (orig_fopen_ptr)dlsym(RTLD_NEXT,"fopen");
 	orig_access = (orig_access_ptr)dlsym(RTLD_NEXT,"access");
+#endif
 }
 
 static void artsdspdebug(const char *fmt,...)
@@ -231,13 +247,18 @@
   return sndfd;
 }
 
+#if defined(__NetBSD__)
+int _oss_ioctl (int fd, unsigned long request, void *argp)
+#else
 int ioctl (int fd, ioctl_request_t request, ...)
+#endif
 {
   static int channels;
   static int bits;
   static int speed;
   int space, size, latency, odelay;
 
+#if !defined(__NetBSD__)
   /*
    * FreeBSD needs ioctl with varargs. However I have no idea how to "forward"
    * the variable args ioctl to the orig_ioctl routine. So I expect the ioctl
@@ -249,6 +270,7 @@
   va_start(args,request);
   argp = va_arg(args, void *);
   va_end(args);
+#endif
 
   CHECK_INIT();