]> granicus.if.org Git - python/commitdiff
Use fcntl() to put the audio device *back* into blocking mode after
authorGreg Ward <gward@python.net>
Fri, 4 Apr 2003 01:47:42 +0000 (01:47 +0000)
committerGreg Ward <gward@python.net>
Fri, 4 Apr 2003 01:47:42 +0000 (01:47 +0000)
opening it in non-blocking mode.  Both Guido and David Hammerton have
reported that this fixes their problems with ossaudiodev -- hooray!

Modules/ossaudiodev.c

index 077784088d1c5d90fef10b1b21cc0e7a05ec6046..948ffe7e1e6c41377b17f1ef58b5b18ba32938ab 100644 (file)
@@ -139,6 +139,15 @@ newossobject(PyObject *arg)
         PyErr_SetFromErrnoWithFilename(PyExc_IOError, basedev);
         return NULL;
     }
+
+    /* And (try to) put it back in blocking mode so we get the
+       expected write() semantics. */
+    if (fcntl(fd, F_SETFL, 0) == -1) {
+        close(fd);
+        PyErr_SetFromErrnoWithFilename(PyExc_IOError, basedev);
+        return NULL;
+    }
+
     if (ioctl(fd, SNDCTL_DSP_GETFMTS, &afmts) == -1) {
         PyErr_SetFromErrnoWithFilename(PyExc_IOError, basedev);
         return NULL;