This commit is contained in:
Lars Immisch
2023-09-04 13:41:53 +01:00
parent 7cc1dadcb2
commit f374adb269

View File

@@ -1423,8 +1423,6 @@ alsapcm_read(alsapcm_t *self, PyObject *args)
static PyObject *alsapcm_write(alsapcm_t *self, PyObject *args)
{
snd_pcm_state_t state;
int res;
int datalen;
char *data;
PyObject *rc = NULL;
@@ -1464,10 +1462,11 @@ static PyObject *alsapcm_write(alsapcm_t *self, PyObject *args)
return NULL;
}
int res;
snd_pcm_state_t state = snd_pcm_state(self->handle);
if (state != SND_PCM_STATE_SETUP) {
res = snd_pcm_prepare(self->handle));
if ((state != SND_PCM_STATE_XRUN && state != SND_PCM_STATE_SETUP) ||
(res = snd_pcm_prepare(self->handle)) >= 0) {
Py_BEGIN_ALLOW_THREADS
res = snd_pcm_writei(self->handle, data, datalen/self->framesize);
if (res == -EPIPE) {