From 0ae60f80f3ba7a87ede20b1738862c0e029a9360 Mon Sep 17 00:00:00 2001 From: Lars Immisch Date: Thu, 16 Jul 2020 23:36:50 +0200 Subject: [PATCH] Better pcm_type deduction in alsamixer_getvolume Closes #87 --- alsaaudio.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/alsaaudio.c b/alsaaudio.c index 1cf3ed3..75e628b 100644 --- a/alsaaudio.c +++ b/alsaaudio.c @@ -1977,6 +1977,15 @@ alsamixer_getvolume(alsamixer_t *self, PyObject *args) elem = alsamixer_find_elem(self->handle,self->controlname,self->controlid); + if (!pcmtypeobj || (pcmtypeobj == Py_None)) { + if (self->pchannels) { + pcmtype = SND_PCM_STREAM_PLAYBACK; + } + } + else { + pcmtype = SND_PCM_STREAM_CAPTURE; + } + result = PyList_New(0); for (channel = 0; channel <= SND_MIXER_SCHN_LAST; channel++) {