From da7d04e2fd334cc26ec98ccb390b899071568be6 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 5 Aug 2022 19:53:41 +0200 Subject: [PATCH] reduce scope of GIL releases it's pointless to enclose snd_pcm_close() and snd_pcm_pause(), as these calls don't sleep. --- alsaaudio.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/alsaaudio.c b/alsaaudio.c index b165a58..f4089b9 100644 --- a/alsaaudio.c +++ b/alsaaudio.c @@ -515,11 +515,12 @@ alsapcm_close(alsapcm_t *self, PyObject *args) if (self->handle) { - Py_BEGIN_ALLOW_THREADS - if (self->pcmtype == SND_PCM_STREAM_PLAYBACK) + if (self->pcmtype == SND_PCM_STREAM_PLAYBACK) { + Py_BEGIN_ALLOW_THREADS snd_pcm_drain(self->handle); + Py_END_ALLOW_THREADS + } snd_pcm_close(self->handle); - Py_END_ALLOW_THREADS self->handle = 0; } @@ -1476,10 +1477,7 @@ static PyObject *alsapcm_pause(alsapcm_t *self, PyObject *args) return NULL; } - Py_BEGIN_ALLOW_THREADS res = snd_pcm_pause(self->handle, enabled); - Py_END_ALLOW_THREADS - if (res < 0) { PyErr_Format(ALSAAudioError, "%s [%s]", snd_strerror(res),