Aurelien Larcher
2021-01-08 b5a8497ec9558d0061024ac4b49f445bbe7d1094
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
This patch is needed to make Python understand it can build the OSS plugin.  
Some OSS ioctls are not supported on Solaris, so they are ifdef'd out.  As
the patch is Solaris-specific, it is not suitable for upstream.
--- Python-3.9.1/setup.py
+++ Python-3.9.1/setup.py
@@ -1601,7 +1601,7 @@ class PyBuildExt(build_ext):
             self.missing.extend(['resource', 'termios'])
 
         # Platform-specific libraries
-        if HOST_PLATFORM.startswith(('linux', 'freebsd', 'gnukfreebsd')):
+        if HOST_PLATFORM.startswith(('sunos5', 'linux', 'freebsd', 'gnukfreebsd')):
             self.add(Extension('ossaudiodev', ['ossaudiodev.c']))
         elif not AIX:
             self.missing.append('ossaudiodev')
--- Python-3.9.1/Modules/ossaudiodev.c
+++ Python-3.9.1/Modules/ossaudiodev.c
@@ -1210,6 +1210,7 @@ PyInit_ossaudiodev(void)
     _EXPORT_INT(m, SOUND_MIXER_MONITOR);
 #endif
 
+#ifndef __sun
     /* Expose all the ioctl numbers for masochists who like to do this
        stuff directly. */
     _EXPORT_INT(m, SNDCTL_COPR_HALT);
@@ -1222,6 +1223,7 @@ PyInit_ossaudiodev(void)
     _EXPORT_INT(m, SNDCTL_COPR_SENDMSG);
     _EXPORT_INT(m, SNDCTL_COPR_WCODE);
     _EXPORT_INT(m, SNDCTL_COPR_WDATA);
+#endif
 #ifdef SNDCTL_DSP_BIND_CHANNEL
     _EXPORT_INT(m, SNDCTL_DSP_BIND_CHANNEL);
 #endif
@@ -1243,8 +1245,12 @@ PyInit_ossaudiodev(void)
     _EXPORT_INT(m, SNDCTL_DSP_GETSPDIF);
 #endif
     _EXPORT_INT(m, SNDCTL_DSP_GETTRIGGER);
+#ifdef SNDCTL_DSP_MAPINBUF
     _EXPORT_INT(m, SNDCTL_DSP_MAPINBUF);
+#endif
+#ifdef SNDCTL_DSP_MAPOUTBUF
     _EXPORT_INT(m, SNDCTL_DSP_MAPOUTBUF);
+#endif
     _EXPORT_INT(m, SNDCTL_DSP_NONBLOCK);
     _EXPORT_INT(m, SNDCTL_DSP_POST);
 #ifdef SNDCTL_DSP_PROFILE
@@ -1264,6 +1270,7 @@ PyInit_ossaudiodev(void)
     _EXPORT_INT(m, SNDCTL_DSP_STEREO);
     _EXPORT_INT(m, SNDCTL_DSP_SUBDIVIDE);
     _EXPORT_INT(m, SNDCTL_DSP_SYNC);
+#ifndef __sun
     _EXPORT_INT(m, SNDCTL_FM_4OP_ENABLE);
     _EXPORT_INT(m, SNDCTL_FM_LOAD_INSTR);
     _EXPORT_INT(m, SNDCTL_MIDI_INFO);
@@ -1305,5 +1312,6 @@ PyInit_ossaudiodev(void)
     _EXPORT_INT(m, SNDCTL_TMR_STOP);
     _EXPORT_INT(m, SNDCTL_TMR_TEMPO);
     _EXPORT_INT(m, SNDCTL_TMR_TIMEBASE);
+#endif
     return m;
 }