]> granicus.if.org Git - python/commitdiff
Release the GIL in two more methods:
authorGreg Ward <gward@python.net>
Mon, 26 May 2003 22:47:30 +0000 (22:47 +0000)
committerGreg Ward <gward@python.net>
Mon, 26 May 2003 22:47:30 +0000 (22:47 +0000)
  * sync(), because it waits for hardware buffers to flush, which
    can take several seconds depending on cirumstances (according
    to the OSS docs)
  * close(), because it does an implicit sync()

Modules/ossaudiodev.c

index 6196d367392e794b0abfd74de1e46caf16b399d8..139c4cfa828d1e3d1383c1b686c257a43ef44a01 100644 (file)
@@ -353,7 +353,12 @@ oss_speed(oss_audio_t *self, PyObject *args)
 static PyObject *
 oss_sync(oss_audio_t *self, PyObject *args)
 {
-    return _do_ioctl_0(self->fd, args, "sync", SNDCTL_DSP_SYNC);
+    int rv;
+
+    Py_BEGIN_ALLOW_THREADS
+    rv = _do_ioctl_0(self->fd, args, "sync", SNDCTL_DSP_SYNC);
+    Py_END_ALLOW_THREADS
+    return rv;
 }
     
 static PyObject *
@@ -478,7 +483,9 @@ oss_close(oss_audio_t *self, PyObject *args)
         return NULL;
 
     if (self->fd >= 0) {
+        Py_BEGIN_ALLOW_THREADS
         close(self->fd);
+        Py_END_ALLOW_THREADS
         self->fd = -1;
     }
     Py_INCREF(Py_None);