* Helper functions
*/
+/* Check if a given file descriptor is valid (i.e. hasn't been closed).
+ * If true, return 1. Otherwise, raise ValueError and return 0.
+ */
+static int _is_fd_valid(int fd)
+{
+ /* the FD is set to -1 in oss_close()/oss_mixer_close() */
+ if (fd >= 0) {
+ return 1;
+ } else {
+ PyErr_SetString(PyExc_ValueError,
+ "Operation on closed OSS device.");
+ return 0;
+ }
+}
+
/* _do_ioctl_1() is a private helper function used for the OSS ioctls --
- SNDCTL_DSP_{SETFMT,CHANNELS,SPEED} -- that that are called from C
+ SNDCTL_DSP_{SETFMT,CHANNELS,SPEED} -- that are called from C
like this:
ioctl(fd, SNDCTL_DSP_cmd, &arg)