Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(201877)

Delta Between Two Patch Sets: Modules/ossaudiodev.c

Issue 23001: Accept mutable bytes-like objects
Left Patch Set: Created 5 years ago
Right Patch Set: Created 4 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 /* 1 /*
2 * ossaudiodev -- Python interface to the OSS (Open Sound System) API. 2 * ossaudiodev -- Python interface to the OSS (Open Sound System) API.
3 * This is the standard audio API for Linux and some 3 * This is the standard audio API for Linux and some
4 * flavours of BSD [XXX which ones?]; it is also available 4 * flavours of BSD [XXX which ones?]; it is also available
5 * for a wide range of commercial Unices. 5 * for a wide range of commercial Unices.
6 * 6 *
7 * Originally written by Peter Bosch, March 2000, as linuxaudiodev. 7 * Originally written by Peter Bosch, March 2000, as linuxaudiodev.
8 * 8 *
9 * Renamed to ossaudiodev and rearranged/revised/hacked up 9 * Renamed to ossaudiodev and rearranged/revised/hacked up
10 * by Greg Ward <gward@python.net>, November 2002. 10 * by Greg Ward <gward@python.net>, November 2002.
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 devicename = getenv("AUDIODEV"); 109 devicename = getenv("AUDIODEV");
110 if (devicename == NULL) /* $AUDIODEV not set */ 110 if (devicename == NULL) /* $AUDIODEV not set */
111 devicename = "/dev/dsp"; 111 devicename = "/dev/dsp";
112 } 112 }
113 113
114 /* Open with O_NONBLOCK to avoid hanging on devices that only allow 114 /* Open with O_NONBLOCK to avoid hanging on devices that only allow
115 one open at a time. This does *not* affect later I/O; OSS 115 one open at a time. This does *not* affect later I/O; OSS
116 provides a special ioctl() for non-blocking read/write, which is 116 provides a special ioctl() for non-blocking read/write, which is
117 exposed via oss_nonblock() below. */ 117 exposed via oss_nonblock() below. */
118 fd = _Py_open(devicename, imode|O_NONBLOCK); 118 fd = _Py_open(devicename, imode|O_NONBLOCK);
119 119 if (fd == -1)
120 if (fd == -1) { 120 return NULL;
121 PyErr_SetFromErrnoWithFilename(PyExc_IOError, devicename);
122 return NULL;
123 }
124 121
125 /* And (try to) put it back in blocking mode so we get the 122 /* And (try to) put it back in blocking mode so we get the
126 expected write() semantics. */ 123 expected write() semantics. */
127 if (fcntl(fd, F_SETFL, 0) == -1) { 124 if (fcntl(fd, F_SETFL, 0) == -1) {
128 close(fd); 125 close(fd);
129 PyErr_SetFromErrnoWithFilename(PyExc_IOError, devicename); 126 PyErr_SetFromErrnoWithFilename(PyExc_IOError, devicename);
130 return NULL; 127 return NULL;
131 } 128 }
132 129
133 if (ioctl(fd, SNDCTL_DSP_GETFMTS, &afmts) == -1) { 130 if (ioctl(fd, SNDCTL_DSP_GETFMTS, &afmts) == -1) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 return NULL; 170 return NULL;
174 } 171 }
175 172
176 if (devicename == NULL) { 173 if (devicename == NULL) {
177 devicename = getenv("MIXERDEV"); 174 devicename = getenv("MIXERDEV");
178 if (devicename == NULL) /* MIXERDEV not set */ 175 if (devicename == NULL) /* MIXERDEV not set */
179 devicename = "/dev/mixer"; 176 devicename = "/dev/mixer";
180 } 177 }
181 178
182 fd = _Py_open(devicename, O_RDWR); 179 fd = _Py_open(devicename, O_RDWR);
183 if (fd == -1) { 180 if (fd == -1)
184 PyErr_SetFromErrnoWithFilename(PyExc_IOError, devicename); 181 return NULL;
185 return NULL;
186 }
187 182
188 if ((self = PyObject_New(oss_mixer_t, &OSSMixerType)) == NULL) { 183 if ((self = PyObject_New(oss_mixer_t, &OSSMixerType)) == NULL) {
189 close(fd); 184 close(fd);
190 return NULL; 185 return NULL;
191 } 186 }
192 187
193 self->fd = fd; 188 self->fd = fd;
194 189
195 return self; 190 return self;
196 } 191 }
(...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 _EXPORT_INT(m, SNDCTL_TMR_CONTINUE); 1307 _EXPORT_INT(m, SNDCTL_TMR_CONTINUE);
1313 _EXPORT_INT(m, SNDCTL_TMR_METRONOME); 1308 _EXPORT_INT(m, SNDCTL_TMR_METRONOME);
1314 _EXPORT_INT(m, SNDCTL_TMR_SELECT); 1309 _EXPORT_INT(m, SNDCTL_TMR_SELECT);
1315 _EXPORT_INT(m, SNDCTL_TMR_SOURCE); 1310 _EXPORT_INT(m, SNDCTL_TMR_SOURCE);
1316 _EXPORT_INT(m, SNDCTL_TMR_START); 1311 _EXPORT_INT(m, SNDCTL_TMR_START);
1317 _EXPORT_INT(m, SNDCTL_TMR_STOP); 1312 _EXPORT_INT(m, SNDCTL_TMR_STOP);
1318 _EXPORT_INT(m, SNDCTL_TMR_TEMPO); 1313 _EXPORT_INT(m, SNDCTL_TMR_TEMPO);
1319 _EXPORT_INT(m, SNDCTL_TMR_TIMEBASE); 1314 _EXPORT_INT(m, SNDCTL_TMR_TIMEBASE);
1320 return m; 1315 return m;
1321 } 1316 }
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+