After updating pyaudio to 0.2.13 using this update: https://bodhi.fedoraproject.org/updates/FEDORA-2023-f675d09ee6 With the updated python3-pyaudio, it works but not reliably. It sometimes hangs, pretty often actually. The attached script makes it rather easy to reproduce the hang. It should do 99 beeps, but does the full amount of beeps not always, quite often it hangs like this: $ python3 ~/tmp/audio-test/pyaudio-test-trigger-hang.py ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.front.0:CARD=0' ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:5704:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM front ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.surround51.0:CARD=0' ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:5704:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM surround21 ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.surround51.0:CARD=0' ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:5704:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM surround21 ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.surround40.0:CARD=0' ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:5704:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM surround40 ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.surround51.0:CARD=0' ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:5704:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM surround41 ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.surround51.0:CARD=0' ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:5704:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM surround50 ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.surround51.0:CARD=0' ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:5704:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM surround51 ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.surround71.0:CARD=0' ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:5704:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM surround71 ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2' ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:5704:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM iec958 ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2' ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:5704:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM spdif ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2' ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:5704:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM spdif ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline ALSA lib pcm_dmix.c:999:(snd_pcm_dmix_open) unable to open slave and here at this `ALSA lib pcm_dmix.c:999:(snd_pcm_dmix_open) unable to open slave` message it hangs, there is no more sound and the script never finishes. I can stop it here with Control-C only because I added: # Make Control-C work when it hangs: signal.signal(signal.SIGINT, signal.SIG_DFL) to the script. When it hangs, stopping the script with Control-C and starting it again, usually reproduces the hang immediately. Using aplay /usr/share/ibus-typing-booster/data/coin9.wav in a different terminal while this test script is hanging does not work, aplay then hangs as well. But after stopping the test script with Control-C, running aplay /usr/share/ibus-typing-booster/data/coin9.wav once seems to "fix" the problem, aplay produces the correct sound and the next run of the test script usually works as well. Reproducible: Always
Created attachment 1988650 [details] pyaudio-test-trigger-hang.py Test script to reproduce the problem.
Comment copied from: https://bugzilla.redhat.com/show_bug.cgi?id=2238132#c12 Christian Krause> I can reproduce similar issues (see below). Anyway, I suggest a new bug report as well. Let's keep using this one for the update and fixing the issue that the package didn't work at all. Christian Krause> Christian Krause> Just to double-check: Do you see the same issues with your own local builds of pyaudio? Christian Krause> Christian Krause> > I can quite easily reproduce the hang using your latest build on Fedora 38: Christian Krause> > https://koji.fedoraproject.org/koji/buildinfo?buildID=2287903 Christian Krause> Christian Krause> A few notes from my tests: Christian Krause> - works worse if there are other active audio players (e.g. a browser): lots of stutter, sometimes hanging pyaudio Christian Krause> - I tried using mpg123 with portaudio plugin (to test the underlying portaudio library): issues couldn't be reproduced
Hi @mfabian I did a little bit of investigation: In many examples the open call to create a stream used an additional parameter: "frames_per_buffer" (reference: https://www.portaudio.com/docs/v19-doxydocs/portaudio_8h.html#a443ad16338191af364e3be988014cbbe). The value should correspond with the number of frames which are read (and written) at the same time. So in the example you attached to the bug report, try something like this: stream = p.open( format=p.get_format_from_width(wf.getsampwidth()), channels=wf.getnchannels(), rate=wf.getframerate(), output=True, frames_per_buffer=1024 ) For me, that fixed it. Please let me know whether it solves the issue on your side as well.
Most likely the problem is fixed by a slightly different usage of the API of pyaudio (see comment #3). Since there was no feedback since a month, I'll close the bug as WORKSFORME now.
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 120 days