forked from auracaster/pyalsaaudio
Fix issue #133
This commit is contained in:
@@ -1423,8 +1423,6 @@ alsapcm_read(alsapcm_t *self, PyObject *args)
|
|||||||
|
|
||||||
static PyObject *alsapcm_write(alsapcm_t *self, PyObject *args)
|
static PyObject *alsapcm_write(alsapcm_t *self, PyObject *args)
|
||||||
{
|
{
|
||||||
snd_pcm_state_t state;
|
|
||||||
int res;
|
|
||||||
int datalen;
|
int datalen;
|
||||||
char *data;
|
char *data;
|
||||||
PyObject *rc = NULL;
|
PyObject *rc = NULL;
|
||||||
@@ -1464,10 +1462,11 @@ static PyObject *alsapcm_write(alsapcm_t *self, PyObject *args)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int res;
|
||||||
snd_pcm_state_t state = snd_pcm_state(self->handle);
|
snd_pcm_state_t state = snd_pcm_state(self->handle);
|
||||||
|
|
||||||
if (state != SND_PCM_STATE_SETUP) {
|
if ((state != SND_PCM_STATE_XRUN && state != SND_PCM_STATE_SETUP) ||
|
||||||
res = snd_pcm_prepare(self->handle));
|
(res = snd_pcm_prepare(self->handle)) >= 0) {
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
res = snd_pcm_writei(self->handle, data, datalen/self->framesize);
|
res = snd_pcm_writei(self->handle, data, datalen/self->framesize);
|
||||||
if (res == -EPIPE) {
|
if (res == -EPIPE) {
|
||||||
|
|||||||
Reference in New Issue
Block a user