diff --git a/alsaaudio.c b/alsaaudio.c index 1b60f57..b9d0407 100644 --- a/alsaaudio.c +++ b/alsaaudio.c @@ -528,11 +528,8 @@ alsapcm_new(PyTypeObject *type, PyObject *args, PyObject *kwds) static void alsapcm_dealloc(alsapcm_t *self) { - if (self->handle) { - snd_pcm_pause(self->handle, 1); - snd_pcm_drain(self->handle); + if (self->handle) snd_pcm_close(self->handle); - } free(self->cardname); PyObject_Del(self); } @@ -546,7 +543,8 @@ alsapcm_close(alsapcm_t *self, PyObject *args) if (self->handle) { Py_BEGIN_ALLOW_THREADS - snd_pcm_drain(self->handle); + if (self->pcmtype == SND_PCM_STREAM_PLAYBACK) + snd_pcm_drain(self->handle); snd_pcm_close(self->handle); Py_END_ALLOW_THREADS diff --git a/playbacktest.py b/playbacktest.py index 874415b..74232ca 100755 --- a/playbacktest.py +++ b/playbacktest.py @@ -49,5 +49,5 @@ if __name__ == '__main__': while data: out.write(data) data = f.read(320) - + out.close()