You can try to clear the ALSA configuration, for example,
ALSA lib pcm.c:2212:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear ALSA lib pcm.c:2212:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe ALSA lib pcm.c:2212:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
called by /usr/share/alsa/alsa.conf :
pcm.rear cards.pcm.rear pcm.center_lfe cards.pcm.center_lfe pcm.side cards.pcm.side
As soon as you comment on these lines, this error message will disappear. You can also check ~/.asoundrc and /etc/asound.conf .
However, some of these messages say that something is wrong with your configuration, although they do not pose any real problems. I do not recommend you clear alsa.conf , because initially from ALSA it can be overwritten by updating alsa-lib.
There is a way to suppress a message in Python, here is a sample code:
#!/usr/bin/env python from ctypes import * import pyaudio # From alsa-lib Git 3fd4ab9be0db7c7430ebd258f2717a976381715d # $ grep -rn snd_lib_error_handler_t # include/error.h:59:typedef void (*snd_lib_error_handler_t)(const char *file, int line, const char *function, int err, const char *fmt, ...) /* __attribute__ ((format (printf, 5, 6))) */; # Define our error handler type ERROR_HANDLER_FUNC = CFUNCTYPE(None, c_char_p, c_int, c_char_p, c_int, c_char_p) def py_error_handler(filename, line, function, err, fmt): print 'messages are yummy' c_error_handler = ERROR_HANDLER_FUNC(py_error_handler) asound = cdll.LoadLibrary('libasound.so') # Set error handler asound.snd_lib_error_set_handler(c_error_handler) # Initialize PyAudio p = pyaudio.PyAudio() p.terminate() print '-'*40 # Reset to default error handler asound.snd_lib_error_set_handler(None) # Re-initialize p = pyaudio.PyAudio() p.terminate()
Output from my computer:
messages are yummy messages are yummy messages are yummy messages are yummy messages are yummy messages are yummy ---------------------------------------- ALSA lib pcm_dmix.c:1018:(snd_pcm_dmix_open) unable to open slave ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side ALSA lib pcm_dmix.c:957:(snd_pcm_dmix_open) The dmix plugin supports only playback stream ALSA lib pcm_dmix.c:1018:(snd_pcm_dmix_open) unable to open slave
These messages are printed by alsa-lib, not PyAudio or PortAudio. The code directly uses the alsa-lib snd_lib_error_set_handler to set the py_error_handler error py_error_handler , which you can use to delete any message.
I checked the other ALSA bindings of Python, pyalsa and PyAlsaAudio, they do not support the installation of an error handler. However, there is a problem in PortAudio, all ALSA error messages seem to have been suppressed before.