Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b804390

Browse files
committed
Release the GIL in two more methods:
* 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()
1 parent 8d1f11b commit b804390

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

Modules/ossaudiodev.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,12 @@ oss_speed(oss_audio_t *self, PyObject *args)
353353
static PyObject *
354354
oss_sync(oss_audio_t *self, PyObject *args)
355355
{
356-
return _do_ioctl_0(self->fd, args, "sync", SNDCTL_DSP_SYNC);
356+
int rv;
357+
358+
Py_BEGIN_ALLOW_THREADS
359+
rv = _do_ioctl_0(self->fd, args, "sync", SNDCTL_DSP_SYNC);
360+
Py_END_ALLOW_THREADS
361+
return rv;
357362
}
358363

359364
static PyObject *
@@ -478,7 +483,9 @@ oss_close(oss_audio_t *self, PyObject *args)
478483
return NULL;
479484

480485
if (self->fd >= 0) {
486+
Py_BEGIN_ALLOW_THREADS
481487
close(self->fd);
488+
Py_END_ALLOW_THREADS
482489
self->fd = -1;
483490
}
484491
Py_INCREF(Py_None);

0 commit comments

Comments
 (0)