forked from auracaster/pyalsaaudio
Fix build (#133)
[Revisionist Note] This is a squashed commit formed from commitsf374adb,3743cf5, andcd44517, still found in the main-pre-rewrite branch. It incorporates a suggestion from PR #134.
This commit is contained in:
committed by
Oswald Buddenhagen
parent
438e52e3fc
commit
9637703ab5
11
alsaaudio.c
11
alsaaudio.c
@@ -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,13 @@ 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) {
|
||||
@@ -1477,8 +1478,8 @@ static PyObject *alsapcm_write(alsapcm_t *self, PyObject *args)
|
||||
res = snd_pcm_writei(self->handle, data, datalen/self->framesize);
|
||||
}
|
||||
}
|
||||
Py_END_ALLOW_THREADS
|
||||
}
|
||||
Py_END_ALLOW_THREADS
|
||||
|
||||
if (res == -EAGAIN) {
|
||||
rc = PyLong_FromLong(0);
|
||||
|
||||
Reference in New Issue
Block a user